mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
[wpimath] Add distance/angle constructor to Translation2d (#2791)
This commit is contained in:
committed by
GitHub
parent
b66fcdb3f7
commit
17698af5e3
@@ -16,6 +16,9 @@ using namespace frc;
|
||||
Translation2d::Translation2d(units::meter_t x, units::meter_t y)
|
||||
: m_x(x), m_y(y) {}
|
||||
|
||||
Translation2d::Translation2d(units::meter_t distance, const Rotation2d& angle)
|
||||
: m_x(distance * angle.Cos()), m_y(distance * angle.Sin()) {}
|
||||
|
||||
units::meter_t Translation2d::Distance(const Translation2d& other) const {
|
||||
return units::math::hypot(other.m_x - m_x, other.m_y - m_y);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user