[wpimath] Add distance/angle constructor to Translation2d (#2791)

This commit is contained in:
Prateek Machiraju
2020-10-21 00:22:41 -04:00
committed by GitHub
parent b66fcdb3f7
commit 17698af5e3
5 changed files with 47 additions and 0 deletions

View File

@@ -50,6 +50,18 @@ public class Translation2d {
m_y = y;
}
/**
* Constructs a Translation2d with the provided distance and angle. This is
* essentially converting from polar coordinates to Cartesian coordinates.
*
* @param distance The distance from the origin to the end of the translation.
* @param angle The angle between the x-axis and the translation vector.
*/
public Translation2d(double distance, Rotation2d angle) {
m_x = distance * angle.getCos();
m_y = distance * angle.getSin();
}
/**
* Calculates the distance between two translations in 2d space.
*