3#include "core/math/geometry/rotation2d.h"
4#include "core/math/geometry/translation2d.h"
5#include "core/math/units.h"
19 Translation2d translation_;
53 : translation_(
x,
y), rotation_(
angle) {}
73 const Eigen::Vector3d& transform_vector, units::Length unit,
74 units::Angle angle_unit = units::radians
76 : translation_({transform_vector(0), transform_vector(1)}, unit),
77 rotation_(units::Angle(transform_vector(2), angle_unit)) {}
80 constexpr units::Length
x()
const {
return translation_.x(); }
83 constexpr double x(units::Length unit)
const {
return translation_.x(unit); }
86 constexpr void set_x(units::Length val) { translation_.set_x(val); }
89 constexpr units::Length
y()
const {
return translation_.y(); }
92 constexpr double y(units::Length unit)
const {
return translation_.y(unit); }
95 constexpr void set_y(units::Length val) { translation_.set_y(val); }
98 constexpr Translation2d
translation()
const {
return translation_; }
110 constexpr units::Angle
angle()
const {
return rotation_.angle(); }
113 constexpr double angle(units::Angle unit)
const {
return rotation_.angle(unit); }
125 EVec<3>
as_vector(units::Length length_unit, units::Angle angle_unit = units::radians)
const {
127 translation_.x().to(length_unit), translation_.y().to(length_unit),
128 rotation_.angle().to(angle_unit)
134 return Transform2d(-translation_.rotate_by(-rotation_), -rotation_);
139 return {translation_ + other.translation_.
rotate_by(rotation_), rotation_ + other.rotation_};
150 return Transform2d(translation_ * scalar, rotation_ * scalar);
155 return transform * scalar;
163 return Transform2d(translation_ / scalar, rotation_ / scalar);
171 return (translation_ == other.translation_) && (rotation_ == other.rotation_);
179 const Transform2d& other, units::Length distance_tolerance = units::Length(1e-6),
180 units::Angle angle_tolerance = units::Angle(1e-6)
182 return translation_.is_near(other.translation_, distance_tolerance) &&
183 rotation_.is_near(other.rotation_, angle_tolerance);
constexpr LinearVector2d rotate_by(Rotation2d rotation) const
Definition translation2d.h:139
Definition rotation2d.h:16
constexpr Rotation2d()=default
Default Constructor for Rotation2d.