TrajoptLib
Library for generating time-optimal trajectories for FRC robots.
Loading...
Searching...
No Matches
trajopt::Translation2< T > Class Template Reference

Represents a translation in 2D space. More...

#include <trajopt/geometry/translation2.hpp>

Public Member Functions

constexpr Translation2 ()=default
 Constructs a translation with x and y components equal to zero.
template<typename X, typename Y>
constexpr Translation2 (X x, Y y)
template<typename U>
constexpr Translation2 (T distance, const Rotation2< U > &angle)
template<typename U>
constexpr Translation2 (const Translation2< U > &other)
constexpr const T & x () const
constexpr const T & y () const
template<typename U>
constexpr auto operator+ (const Translation2< U > &other) const
template<typename U>
constexpr auto operator- (const Translation2< U > &other) const
constexpr Translation2< T > operator- () const
template<typename U>
constexpr auto operator* (const U &scalar) const
template<typename U>
constexpr auto operator/ (const U &scalar) const
template<typename U>
constexpr auto rotate_by (const Rotation2< U > &rotation) const
constexpr Rotation2< T > angle () const
template<typename U>
constexpr auto dot (const Translation2< U > &other) const
template<typename U>
constexpr auto cross (const Translation2< U > &other) const
constexpr auto norm () const
constexpr auto squared_norm () const
template<typename U>
constexpr auto distance (const Translation2< U > &other) const

Detailed Description

template<typename T>
class trajopt::Translation2< T >

Represents a translation in 2D space.

Constructor & Destructor Documentation

◆ Translation2() [1/3]

template<typename T>
template<typename X, typename Y>
trajopt::Translation2< T >::Translation2 ( X x,
Y y )
inlineconstexpr

Constructs a translation with the given x and y components.

Parameters
xThe x component of the translation.
yThe y component of the translation.

◆ Translation2() [2/3]

template<typename T>
template<typename U>
trajopt::Translation2< T >::Translation2 ( T distance,
const Rotation2< U > & angle )
inlineconstexpr

Constructs a translation with the provided distance and angle.

This is essentially converting from polar coordinates to Cartesian coordinates.

Parameters
distanceThe distance from the origin to the end of the translation.
angleThe angle between the x-axis and the translation vector.

◆ Translation2() [3/3]

template<typename T>
template<typename U>
trajopt::Translation2< T >::Translation2 ( const Translation2< U > & other)
inlineexplicitconstexpr

Coerces one translation type into another.

Parameters
otherThe other translation type.

Member Function Documentation

◆ angle()

template<typename T>
Rotation2< T > trajopt::Translation2< T >::angle ( ) const
inlineconstexpr

Returns the angle this translation forms with the positive x-axis.

Returns
The angle of the translation.

◆ cross()

template<typename T>
template<typename U>
auto trajopt::Translation2< T >::cross ( const Translation2< U > & other) const
inlineconstexpr

Returns the cross product between two translations.

Parameters
otherThe other translation.
Returns
The cross product.

◆ distance()

template<typename T>
template<typename U>
auto trajopt::Translation2< T >::distance ( const Translation2< U > & other) const
inlineconstexpr

Returns the distance between two translations in 2D space.

The distance between translations is defined as √((x₂−x₁)²+(y₂−y₁)²).

Parameters
otherThe translation to which to compute the distance.
Returns
The distance between the two translations.

◆ dot()

template<typename T>
template<typename U>
auto trajopt::Translation2< T >::dot ( const Translation2< U > & other) const
inlineconstexpr

Returns the dot product between two translations.

Parameters
otherThe other translation.
Returns
The dot product.

◆ norm()

template<typename T>
auto trajopt::Translation2< T >::norm ( ) const
inlineconstexpr

Returns the norm of the translation. This is the distance from the origin to the translation.

Returns
The norm of the translation.

◆ operator*()

template<typename T>
template<typename U>
auto trajopt::Translation2< T >::operator* ( const U & scalar) const
inlineconstexpr

Returns the translation multiplied by a scalar.

Parameters
scalarThe scalar to multiply by.
Returns
The scaled translation.

◆ operator+()

template<typename T>
template<typename U>
auto trajopt::Translation2< T >::operator+ ( const Translation2< U > & other) const
inlineconstexpr

Returns the sum of two translations in 2D space.

Parameters
otherThe translation to add.
Returns
The sum of the translations.

◆ operator-() [1/2]

template<typename T>
Translation2< T > trajopt::Translation2< T >::operator- ( ) const
inlineconstexpr

Returns the inverse of the current translation.

This is equivalent to rotating by 180 degrees, flipping the point over both axes, or negating all components of the translation.

Returns
The inverse of the current translation.

◆ operator-() [2/2]

template<typename T>
template<typename U>
auto trajopt::Translation2< T >::operator- ( const Translation2< U > & other) const
inlineconstexpr

Returns the difference between two translations.

Parameters
otherThe translation to subtract.
Returns
The difference between the two translations.

◆ operator/()

template<typename T>
template<typename U>
auto trajopt::Translation2< T >::operator/ ( const U & scalar) const
inlineconstexpr

Returns the translation divided by a scalar.

Parameters
scalarThe scalar to divide by.
Returns
The scaled translation.

◆ rotate_by()

template<typename T>
template<typename U>
auto trajopt::Translation2< T >::rotate_by ( const Rotation2< U > & rotation) const
inlineconstexpr

Applies a rotation to the translation in 2D space.

Parameters
rotationThe rotation to rotate the translation by.
Returns
The new rotated translation.

◆ squared_norm()

template<typename T>
auto trajopt::Translation2< T >::squared_norm ( ) const
inlineconstexpr

Returns the squared norm of the translation. This is the sum of squares of the translation's components.

Returns
The squared norm of the translation.

◆ x()

template<typename T>
const T & trajopt::Translation2< T >::x ( ) const
inlineconstexpr

Returns the x component of the translation.

Returns
The x component of the translation.

◆ y()

template<typename T>
const T & trajopt::Translation2< T >::y ( ) const
inlineconstexpr

Returns the y component of the translation.

Returns
The y component of the translation.

The documentation for this class was generated from the following file: