class wpimath.geometry.Translation2d(*args, **kwargs)

Bases: pybind11_object

Represents a translation in 2D 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 and left is positive Y.

Overloaded function.

  1. __init__(self: wpimath.geometry._geometry.Translation2d) -> None

Constructs a Translation2d with X and Y components equal to zero.

  1. __init__(self: wpimath.geometry._geometry.Translation2d, x: wpimath.units.meters, y: wpimath.units.meters) -> None

Constructs a Translation2d with the X and Y components equal to the provided values.

  • x – The x component of the translation.

  • y – The y component of the translation.

  1. __init__(self: wpimath.geometry._geometry.Translation2d, distance: wpimath.units.meters, angle: wpimath.geometry._geometry.Rotation2d) -> None

Constructs a Translation2d 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.

  1. __init__(self: wpimath.geometry._geometry.Translation2d, vector: numpy.ndarray[numpy.float64[2, 1]]) -> None

Constructs a Translation2d from the provided translation vector’s X and Y components. The values are assumed to be in meters.


vector – The translation vector to represent.

WPIStruct = <capsule object "WPyStruct">
X() wpimath.units.meters

Returns the X component of the translation.


The X component of the translation.

Y() wpimath.units.meters

Returns the Y component of the translation.


The Y component of the translation.

angle() wpimath.geometry._geometry.Rotation2d

Returns the angle this translation forms with the positive X axis.


The angle of the translation

distance(other: wpimath.geometry._geometry.Translation2d) wpimath.units.meters

Calculates the distance between two translations in 2D space.

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


other – The translation to compute the distance to.


The distance between the two translations.

distanceFeet(arg0: wpimath.geometry._geometry.Translation2d) wpimath.units.feet
static fromFeet(x: wpimath.units.feet, y: wpimath.units.feet) wpimath.geometry._geometry.Translation2d
nearest(translations: List[wpimath.geometry._geometry.Translation2d]) wpimath.geometry._geometry.Translation2d

Returns the nearest Translation2d from a collection of translations


translations – The collection of translations.


The nearest Translation2d from the collection.

norm() wpimath.units.meters

Returns the norm, or distance from the origin to the translation.


The norm of the translation.

normFeet() wpimath.units.feet
rotateBy(other: wpimath.geometry._geometry.Rotation2d) wpimath.geometry._geometry.Translation2d

Applies a rotation to the translation in 2D space.

This multiplies the translation vector by a counterclockwise rotation matrix of the given angle.

[x_new]   [other.cos, -other.sin][x]
[y_new] = [other.sin,  other.cos][y]

For example, rotating a Translation2d of &lt;2, 0&gt; by 90 degrees will return a Translation2d of &lt;0, 2&gt;.


other – The rotation to rotate the translation by.


The new rotated translation.

toVector() numpy.ndarray[numpy.float64[2, 1]]

Returns a vector representation of this translation.


A Vector representation of this translation.

property x
property x_feet
property y
property y_feet