Arduino Helpers master
Utility library for Arduino
Quaternion.cpp
Go to the documentation of this file.
1#include "Quaternion.hpp"
2
4#ifndef ARDUINO
5#include <ostream> // std::ostream, <<
6#endif
7
9
10// LCOV_EXCL_START
11
12#ifndef ARDUINO
13
14std::ostream &operator<<(std::ostream &os, Quaternion q) {
15 return os << "(" << q.w << ", " << q.x << ", " << q.y << ", " << q.z << ")";
16}
17
18std::ostream &operator<<(std::ostream &os, EulerAngles e) {
19 os << "(" << rad2deg(e.yaw) << "°, " << rad2deg(e.pitch) << "°, "
20 << rad2deg(e.roll) << "°)";
21 return os;
22}
23
24#endif // ARDUINO
25
26Print &operator<<(Print &os, Quaternion q) {
27 return os << "(" << q.w << ", " << q.x << ", " << q.y << ", " << q.z << ")";
28}
29
30Print &operator<<(Print &os, EulerAngles e) {
31 os << "(" << rad2deg(e.yaw) << "°, " << rad2deg(e.pitch) << "°, "
32 << rad2deg(e.roll) << "°)";
33 return os;
34}
35
36// LCOV_EXCL_STOP
37
#define END_AH_NAMESPACE
#define BEGIN_AH_NAMESPACE
Definition of Quaternion and EulerAngles.
constexpr std::enable_if< std::is_floating_point< T >::value, T >::type rad2deg(T r)
Convert radians to degrees.
Definition: Degrees.hpp:24
Print & operator<<(Print &os, Quaternion e)
Printing.
Definition: Quaternion.cpp:26
Struct for Euler angles of floating point numbers.
Definition: Quaternion.hpp:288
float roll
X": drone X = world +Y.
Definition: Quaternion.hpp:291
float pitch
Y': drone Y = world -X.
Definition: Quaternion.hpp:290
float yaw
Z : drone Z = world +Z.
Definition: Quaternion.hpp:289
Type for quaternions of floating point numbers.
Definition: Quaternion.hpp:57
float w
Scalar (real) component.
Definition: Quaternion.hpp:58
float y
Second vector (imaginary) component .
Definition: Quaternion.hpp:60
float x
First vector (imaginary) component .
Definition: Quaternion.hpp:59
float z
Third vector (imaginary) component .
Definition: Quaternion.hpp:61