Control Surface  1.2.0
MIDI Control Surface library for Arduino
Quaternion.cpp
Go to the documentation of this file.
1 #include "Quaternion.hpp"
2 
3 AH_DIAGNOSTIC_WERROR() // Enable errors on warnings
4 
5 #include <AH/PrintStream/PrintStream.hpp>
6 #ifndef ARDUINO
7 #include <ostream> // std::ostream, <<
8 #endif
9 
11 
12 // LCOV_EXCL_START
13 
14 #ifndef ARDUINO
15 
16 std::ostream &operator<<(std::ostream &os, Quaternion q) {
17  return os << "(" << q.w << ", " << q.x << ", " << q.y << ", " << q.z << ")";
18 }
19 
20 std::ostream &operator<<(std::ostream &os, EulerAngles e) {
21  os << "(" << rad2deg(e.yaw) << "°, " << rad2deg(e.pitch) << "°, "
22  << rad2deg(e.roll) << "°)";
23  return os;
24 }
25 
26 #endif // ARDUINO
27 
28 Print &operator<<(Print &os, Quaternion q) {
29  return os << "(" << q.w << ", " << q.x << ", " << q.y << ", " << q.z << ")";
30 }
31 
32 Print &operator<<(Print &os, EulerAngles e) {
33  os << "(" << rad2deg(e.yaw) << "°, " << rad2deg(e.pitch) << "°, "
34  << rad2deg(e.roll) << "°)";
35  return os;
36 }
37 
38 // LCOV_EXCL_STOP
39 
41 
AH::rad2deg
constexpr double rad2deg(T r)
Convert radians to degrees.
Definition: Degrees.hpp:20
AH::EulerAngles::yaw
float yaw
Z : drone Z = world +Z.
Definition: Quaternion.hpp:293
AH::Quaternion
Type for quaternions of floating point numbers.
Definition: Quaternion.hpp:61
AH::Quaternion::z
float z
Third vector (imaginary) component .
Definition: Quaternion.hpp:65
AH_DIAGNOSTIC_POP
#define AH_DIAGNOSTIC_POP()
Definition: Warnings.hpp:36
AH::Quaternion::y
float y
Second vector (imaginary) component .
Definition: Quaternion.hpp:64
AH::EulerAngles
Struct for Euler angles of floating point numbers.
Definition: Quaternion.hpp:292
AH::Quaternion::w
float w
Scalar (real) component.
Definition: Quaternion.hpp:62
AH::EulerAngles::roll
float roll
X": drone X = world +Y.
Definition: Quaternion.hpp:295
AH::EulerAngles::pitch
float pitch
Y': drone Y = world -X.
Definition: Quaternion.hpp:294
AH_DIAGNOSTIC_WERROR
#define AH_DIAGNOSTIC_WERROR()
Definition: Warnings.hpp:35
BEGIN_AH_NAMESPACE
#define BEGIN_AH_NAMESPACE
Definition: AH/Settings/NamespaceSettings.hpp:9
END_AH_NAMESPACE
#define END_AH_NAMESPACE
Definition: AH/Settings/NamespaceSettings.hpp:10
Quaternion.hpp
Definition of Quaternion and EulerAngles.
AH::Quaternion::operator<<
Print & operator<<(Print &os, Quaternion e)
Printing.
Definition: Quaternion.cpp:28
AH::Quaternion::x
float x
First vector (imaginary) component .
Definition: Quaternion.hpp:63