WPILibC++ 2023.4.3-108-ge5452e3
|
Represents a translation in 3D space. More...
#include <frc/geometry/Translation3d.h>
Public Member Functions | |
constexpr | Translation3d ()=default |
Constructs a Translation3d with X, Y, and Z components equal to zero. More... | |
constexpr | Translation3d (units::meter_t x, units::meter_t y, units::meter_t z) |
Constructs a Translation3d with the X, Y, and Z components equal to the provided values. More... | |
Translation3d (units::meter_t distance, const Rotation3d &angle) | |
Constructs a Translation3d with the provided distance and angle. More... | |
units::meter_t | Distance (const Translation3d &other) const |
Calculates the distance between two translations in 3D space. More... | |
constexpr units::meter_t | X () const |
Returns the X component of the translation. More... | |
constexpr units::meter_t | Y () const |
Returns the Y component of the translation. More... | |
constexpr units::meter_t | Z () const |
Returns the Z component of the translation. More... | |
units::meter_t | Norm () const |
Returns the norm, or distance from the origin to the translation. More... | |
Translation3d | RotateBy (const Rotation3d &other) const |
Applies a rotation to the translation in 3D space. More... | |
constexpr Translation2d | ToTranslation2d () const |
Returns a Translation2d representing this Translation3d projected into the X-Y plane. More... | |
constexpr Translation3d | operator+ (const Translation3d &other) const |
Returns the sum of two translations in 3D space. More... | |
constexpr Translation3d | operator- (const Translation3d &other) const |
Returns the difference between two translations. More... | |
constexpr Translation3d | operator- () const |
Returns the inverse of the current translation. More... | |
constexpr Translation3d | operator* (double scalar) const |
Returns the translation multiplied by a scalar. More... | |
constexpr Translation3d | operator/ (double scalar) const |
Returns the translation divided by a scalar. More... | |
bool | operator== (const Translation3d &other) const |
Checks equality between this Translation3d and another object. More... | |
Represents a translation in 3D space.
This object can be used to represent a point or a vector.
This assumes that you are using conventional mathematical axes. When the robot is at the origin facing in the positive X direction, forward is positive X, left is positive Y, and up is positive Z.
|
constexprdefault |
Constructs a Translation3d with X, Y, and Z components equal to zero.
|
constexpr |
Constructs a Translation3d with the X, Y, and Z components equal to the provided values.
x | The x component of the translation. |
y | The y component of the translation. |
z | The z component of the translation. |
frc::Translation3d::Translation3d | ( | units::meter_t | distance, |
const Rotation3d & | angle | ||
) |
Constructs a Translation3d with the provided distance and angle.
This is essentially converting from polar coordinates to Cartesian coordinates.
distance | The distance from the origin to the end of the translation. |
angle | The angle between the x-axis and the translation vector. |
units::meter_t frc::Translation3d::Distance | ( | const Translation3d & | other | ) | const |
Calculates the distance between two translations in 3D space.
The distance between translations is defined as √((x₂−x₁)²+(y₂−y₁)²+(z₂−z₁)²).
other | The translation to compute the distance to. |
units::meter_t frc::Translation3d::Norm | ( | ) | const |
Returns the norm, or distance from the origin to the translation.
|
constexpr |
Returns the translation multiplied by a scalar.
For example, Translation3d{2.0, 2.5, 4.5} * 2 = Translation3d{4.0, 5.0, 9.0}.
scalar | The scalar to multiply by. |
|
constexpr |
Returns the sum of two translations in 3D space.
For example, Translation3d{1.0, 2.5, 3.5} + Translation3d{2.0, 5.5, 7.5} = Translation3d{3.0, 8.0, 11.0}.
other | The translation to add. |
|
constexpr |
Returns the inverse of the current translation.
This is equivalent to negating all components of the translation.
|
constexpr |
Returns the difference between two translations.
For example, Translation3d{5.0, 4.0, 3.0} - Translation3d{1.0, 2.0, 3.0} = Translation3d{4.0, 2.0, 0.0}.
other | The translation to subtract. |
|
constexpr |
Returns the translation divided by a scalar.
For example, Translation3d{2.0, 2.5, 4.5} / 2 = Translation3d{1.0, 1.25, 2.25}.
scalar | The scalar to divide by. |
bool frc::Translation3d::operator== | ( | const Translation3d & | other | ) | const |
Checks equality between this Translation3d and another object.
other | The other object. |
Translation3d frc::Translation3d::RotateBy | ( | const Rotation3d & | other | ) | const |
Applies a rotation to the translation in 3D space.
For example, rotating a Translation3d of <2, 0, 0> by 90 degrees around the Z axis will return a Translation3d of <0, 2, 0>.
other | The rotation to rotate the translation by. |
|
constexpr |
Returns a Translation2d representing this Translation3d projected into the X-Y plane.
|
inlineconstexpr |
Returns the X component of the translation.
|
inlineconstexpr |
Returns the Y component of the translation.
|
inlineconstexpr |
Returns the Z component of the translation.