-
Notifications
You must be signed in to change notification settings - Fork 11
/
OtherRotations.h
83 lines (61 loc) · 1.58 KB
/
OtherRotations.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#pragma once
#include <math.h>
#include "Arduino.h"
#include "BasicLinearAlgebra.h"
#include "Geometry.h"
namespace Geometry
{
class Rotation;
class Quaternion
{
BLA::Matrix<4> elems;
public:
Quaternion() = default;
Quaternion(float x, float y, float z, float w);
Quaternion(const Rotation& R);
float& x() { return elems(0); }
float& y() { return elems(1); }
float& z() { return elems(2); }
float& w() { return elems(3); }
Rotation to_rotation_matrix() const;
Quaternion operator*(const Quaternion& other) const;
friend Print& operator<<(Print& strm, const Quaternion& quat);
};
class EulerAngles
{
BLA::Matrix<3> angles;
public:
enum RotationFrame
{
Static = 0,
Rotating
};
enum RotationOrder
{
XYZ = 0,
XYX,
XZY,
XZX,
YZX,
YZY,
YXZ,
YXY,
ZXY,
ZXZ,
ZYX,
ZYZ
};
float& first() { return angles(0); }
float& second() { return angles(1); }
float& third() { return angles(2); }
const RotationFrame frame;
const RotationOrder order;
EulerAngles() = default;
EulerAngles(float ai, float aj, float ak, RotationFrame frame = RotationFrame::Static,
RotationOrder order = RotationOrder::XYZ);
EulerAngles(const Rotation& R, RotationFrame frame = RotationFrame::Static,
RotationOrder order = RotationOrder::XYZ);
Rotation to_rotation_matrix() const;
friend Print& operator<<(Print& strm, const EulerAngles& euler);
};
} // namespace Geometry