# Translation2d

#### Why It's Useful

This class is foundational to representing points and movements in 2D space. Since programming often involves modeling motion and field-relative positions, `Translation2d` is crucial.

#### Common Use Cases

* **Robot movement and odometry**: Track robot translation from encoders or trajectory planners
* **Vision processing**: Represent detected AprilTag or goal positions in field coordinates
* **Path following**: Waypoints or target positions for autonomous navigation
* Almost everything else

<figure><img src="https://2151751410-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fj1bCS1NH8kvxuexCZ4iF%2Fuploads%2FUJDaZlHc42Hgzw38KuE8%2Fimage.png?alt=media&#x26;token=7c61e008-f5e0-4354-a74c-b9454585b71a" alt=""><figcaption><p>Example 2dVector/Translation2d</p></figcaption></figure>

### Useful Methods

{% hint style="warning" %}
These are for the 254 Geometry classes, these will either have a different name or not exist in the WPILib class
{% endhint %}

For the following methods trans represents an instance of the Translation2d class and rot represts an instance of the Rotation2d class

* Trans.norm() - Returns the hypotenuse of the line
* trans.rotateBy(rot) - Rotates the translation about the origin by the angle rot
* Trans.translateBy(otherTrans) - Adds the translations tip to tip and returns the new translation
* Trans.direction() - Returns a rotation 2d that contains the direction the translation is pointing
