LinearAlgebra
Loading...
Searching...
No Matches
SwingTwist.h
1// This Source Code Form is subject to the terms of the Mozilla Public
2// License, v. 2.0.If a copy of the MPL was not distributed with this
3// file, You can obtain one at https ://mozilla.org/MPL/2.0/.
4
5#ifndef SWINGTWIST_H
6#define SWINGTWIST_H
7
8#include "Angle.h"
9#include "Direction.h"
10#include "Quaternion.h"
11#include "Spherical.h"
12
13namespace Passer {
14namespace LinearAlgebra {
15
19template <typename T> class SwingTwistOf {
20public:
21 DirectionOf<T> swing;
22 AngleOf<T> twist;
23
26 SwingTwistOf<T>(AngleOf<T> horizontal, AngleOf<T> vertical, AngleOf<T> twist);
27
28 static SwingTwistOf<T> Degrees(float horizontal, float vertical = 0,
29 float twist = 0);
30
31 Quaternion ToQuaternion() const;
32 static SwingTwistOf<T> FromQuaternion(Quaternion q);
33
34 SphericalOf<T> ToAngleAxis() const;
35 static SwingTwistOf<T> FromAngleAxis(SphericalOf<T> aa);
36
37 const static SwingTwistOf<T> identity;
38
39 bool operator==(const SwingTwistOf<T> d) const;
40
55 SwingTwistOf<T> operator*=(const SwingTwistOf<T> &rotation);
56
58
65 static SwingTwistOf<T> AngleAxis(float angle, const DirectionOf<T> &axis);
66
67 static AngleOf<T> Angle(const SwingTwistOf<T> &r1, const SwingTwistOf<T> &r2);
68
69 void Normalize();
70};
71
74
75} // namespace LinearAlgebra
76} // namespace Passer
77using namespace Passer::LinearAlgebra;
78
79#endif
An angle in various representations.
Definition Angle.h:21
An orientation using swing and twist angles in various representations.
Definition SwingTwist.h:19
SphericalOf< T > operator*(const SphericalOf< T > &vector) const
Rotate a vector using this rotation.
Definition SwingTwist.cpp:105
static SwingTwistOf< T > AngleAxis(float angle, const DirectionOf< T > &axis)
Convert an angle/axis representation to a swingt.
Definition SwingTwist.cpp:138
A quaternion.
Definition Quaternion.h:41