Control Surface stm32
MIDI Control Surface library for Arduino
Quaternion.cpp
Go to the documentation of this file.
1#include "Quaternion.hpp"
2
3AH_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
16std::ostream &operator<<(std::ostream &os, Quaternion q) {
17 return os << "(" << q.w << ", " << q.x << ", " << q.y << ", " << q.z << ")";
18}
19
20std::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
28Print &operator<<(Print &os, Quaternion q) {
29 return os << "(" << q.w << ", " << q.x << ", " << q.y << ", " << q.z << ")";
30}
31
32Print &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
#define END_AH_NAMESPACE
#define BEGIN_AH_NAMESPACE
Definition of Quaternion and EulerAngles.
#define AH_DIAGNOSTIC_POP()
Definition: Warnings.hpp:37
#define AH_DIAGNOSTIC_WERROR()
Definition: Warnings.hpp:36
constexpr std::enable_if< std::is_floating_point< T >::value, T >::type rad2deg(T r)
Convert radians to degrees.
Definition: Degrees.hpp:26
Print & operator<<(Print &os, Quaternion e)
Printing.
Definition: Quaternion.cpp:28
Struct for Euler angles of floating point numbers.
Definition: Quaternion.hpp:291
float roll
X": drone X = world +Y.
Definition: Quaternion.hpp:294
float pitch
Y': drone Y = world -X.
Definition: Quaternion.hpp:293
float yaw
Z : drone Z = world +Z.
Definition: Quaternion.hpp:292
Type for quaternions of floating point numbers.
Definition: Quaternion.hpp:60
float w
Scalar (real) component.
Definition: Quaternion.hpp:61
float y
Second vector (imaginary) component .
Definition: Quaternion.hpp:63
float x
First vector (imaginary) component .
Definition: Quaternion.hpp:62
float z
Third vector (imaginary) component .
Definition: Quaternion.hpp:64