RIT VEXU Core API
Loading...
Searching...
No Matches
rotation2d.h
1#pragma once
2#undef __ARM_NEON__
3#undef __ARM_NEON
4#include <Eigen/Dense>
5
6#include "core/utils/math/geometry/translation2d.h"
7#include <cmath>
8#include <iostream>
9#include <vector>
10
11#ifndef PI
12#define PI 3.141592654
13#endif
14
15class Translation2d;
16
27 public:
29 constexpr Rotation2d() : m_radians(0), m_cos(1), m_sin(0) {};
35 Rotation2d(const double &radians);
36
47 Rotation2d(const double &x, const double &y);
48
58 Rotation2d(const Translation2d &translation);
59
65 double radians() const;
66
72 double degrees() const;
73
79 double revolutions() const;
80
86 double f_cos() const;
87
93 double f_sin() const;
94
100 double f_tan() const;
101
109 Eigen::Matrix2d rotation_matrix() const;
110
116 double wrapped_radians_180() const;
117
123 double wrapped_degrees_180() const;
124
130 double wrapped_revolutions_180() const;
131
137 double wrapped_radians_360() const;
138
144 double wrapped_degrees_360() const;
145
151 double wrapped_revolutions_360() const;
152
164 Rotation2d operator+(const Rotation2d &other) const;
165
173 Rotation2d operator-(const Rotation2d &other) const;
174
181 Rotation2d operator-() const;
182
190 Rotation2d operator*(const double &scalar) const;
191
199 Rotation2d operator/(const double &scalar) const;
200
209 bool operator==(const Rotation2d &other) const;
210
218 friend std::ostream &operator<<(std::ostream &os, const Rotation2d &rotation);
219
220 private:
221 double m_radians;
222 double m_cos;
223 double m_sin;
224};
225
226// functions that don't belong in the class because they're useful elsewhere
232Rotation2d from_radians(const double &radians);
233
239Rotation2d from_degrees(const double &degrees);
240
246Rotation2d from_revolutions(const double &revolutions);
247
255double wrap_radians_180(const double &angle);
256
264double wrap_degrees_180(const double &angle);
265
273double wrap_revolutions_180(const double &angle);
274
282double wrap_radians_360(const double &angle);
283
291double wrap_degrees_360(const double &angle);
292
300double wrap_revolutions_360(const double &angle);
301
307double deg2rad(double deg);
308
314double rad2deg(double r);
315
324Rotation2d unwrapped_mean(const std::vector<Rotation2d> &list);
325
334Rotation2d wrapped_mean(const std::vector<Rotation2d> &list);
Definition rotation2d.h:26
Eigen::Matrix2d rotation_matrix() const
Definition rotation2d.cpp:110
bool operator==(const Rotation2d &other) const
Definition rotation2d.cpp:221
double wrapped_revolutions_180() const
Definition rotation2d.cpp:131
double wrapped_revolutions_360() const
Definition rotation2d.cpp:152
double wrapped_radians_360() const
Definition rotation2d.cpp:138
friend std::ostream & operator<<(std::ostream &os, const Rotation2d &rotation)
Definition rotation2d.cpp:232
double f_tan() const
Definition rotation2d.cpp:101
double f_cos() const
Definition rotation2d.cpp:87
double wrapped_radians_180() const
Definition rotation2d.cpp:117
constexpr Rotation2d()
Default Constructor for Rotation2d.
Definition rotation2d.h:29
double wrapped_degrees_360() const
Definition rotation2d.cpp:145
double f_sin() const
Definition rotation2d.cpp:94
double radians() const
Definition rotation2d.cpp:66
double degrees() const
Definition rotation2d.cpp:73
Rotation2d operator+(const Rotation2d &other) const
Definition rotation2d.cpp:175
Rotation2d operator/(const double &scalar) const
Definition rotation2d.cpp:211
Rotation2d operator-() const
Definition rotation2d.cpp:193
Rotation2d operator*(const double &scalar) const
Definition rotation2d.cpp:202
double wrapped_degrees_180() const
Definition rotation2d.cpp:124
double revolutions() const
Definition rotation2d.cpp:80
Definition translation2d.h:21