Package edu.wpi.first.math.geometry
Class Transform2d
java.lang.Object
edu.wpi.first.math.geometry.Transform2d
public class Transform2d extends Object
Represents a transformation for a Pose2d.
-
Constructor Summary
Constructors Constructor Description Transform2d()Constructs the identity transform -- maps an initial pose to itself.Transform2d(Pose2d initial, Pose2d last)Constructs the transform that maps the initial pose to the final pose.Transform2d(Translation2d translation, Rotation2d rotation)Constructs a transform with the given translation and rotation components. -
Method Summary
Modifier and Type Method Description booleanequals(Object obj)Checks equality between this Transform2d and another object.Rotation2dgetRotation()Returns the rotational component of the transformation.Translation2dgetTranslation()Returns the translation component of the transformation.doublegetX()Returns the X component of the transformation's translation.doublegetY()Returns the Y component of the transformation's translation.inthashCode()Transform2dinverse()Invert the transformation.Transform2dplus(Transform2d other)Composes two transformations.Transform2dtimes(double scalar)Scales the transform by the scalar.StringtoString()
-
Constructor Details
-
Transform2d
Constructs the transform that maps the initial pose to the final pose.- Parameters:
initial- The initial pose for the transformation.last- The final pose for the transformation.
-
Transform2d
Constructs a transform with the given translation and rotation components.- Parameters:
translation- Translational component of the transform.rotation- Rotational component of the transform.
-
Transform2d
public Transform2d()Constructs the identity transform -- maps an initial pose to itself.
-
-
Method Details
-
times
Scales the transform by the scalar.- Parameters:
scalar- The scalar.- Returns:
- The scaled Transform2d.
-
plus
Composes two transformations.- Parameters:
other- The transform to compose with this one.- Returns:
- The composition of the two transformations.
-
getTranslation
Returns the translation component of the transformation.- Returns:
- The translational component of the transform.
-
getX
Returns the X component of the transformation's translation.- Returns:
- The x component of the transformation's translation.
-
getY
Returns the Y component of the transformation's translation.- Returns:
- The y component of the transformation's translation.
-
getRotation
Returns the rotational component of the transformation.- Returns:
- Reference to the rotational component of the transform.
-
inverse
Invert the transformation. This is useful for undoing a transformation.- Returns:
- The inverted transformation.
-
toString
-
equals
Checks equality between this Transform2d and another object. -
hashCode
-