11/* *
22 * @file
3- * @brief Definition of Quaternion and EulerAngles.
3+ * @brief Definition of Quaternion and EulerAngles.
44 *
55 * Quaternions can be multiplied (Hamiltonian product), normalized and can
66 * perform rotations of vectors. Quaternion also has an implementation of the
2525AH_DIAGNOSTIC_WERROR () // Enable errors on warnings
2626
2727#include < AH/Arduino-Wrapper.h> // Print
28- #include < AH/Math/Degrees.hpp> // rad2deg()
29- #include < AH/Math/Vector.hpp> // Vec3f
30- #include < AH/STL/cmath> // std::sqrt
31- #include < AH/STL/limits> // std::numeric_limits
28+ #include < AH/Math/Degrees.hpp> // rad2deg()
29+ #include < AH/Math/Vector.hpp> // Vec3f
30+ #include < AH/STL/cmath> // std::sqrt
31+ #include < AH/STL/limits> // std::numeric_limits
3232
3333#ifndef ARDUINO
3434#include < iosfwd> // std::ostream
@@ -193,17 +193,17 @@ struct Quaternion {
193193 static Quaternion fromDirection (Vec3f v) {
194194 /*
195195 * Formula:
196- * q = cos(ϑ / 2) + sin(ϑ / 2)·(x·i + y·j + z·k)
197- * where (x y z) is a unit vector representing the axis about which
198- * the body is rotated; ϑ is the angle by which it is rotated.
199- *
196+ * q = cos(ϑ / 2) + sin(ϑ / 2)·(x·i + y·j + z·k)
197+ * where (x y z) is a unit vector representing the axis about which
198+ * the body is rotated; ϑ is the angle by which it is rotated.
199+ *
200200 * Source:
201201 * https://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation#Using_quaternion_as_rotations
202202 *
203- * The rotational axis (x y z) can be calcuated by taking the normalized
203+ * The rotational axis (x y z) can be calcuated by taking the normalized
204204 * cross product of (0 0 1) and the given vector. The angle of rotation
205205 * ϑ can be found using |A×B| = |A||B|·sin(ϑ).
206- */
206+ */
207207
208208 float eps = std::numeric_limits<float >::epsilon ();
209209
@@ -229,7 +229,7 @@ struct Quaternion {
229229 // Calculate the angle ϑ.
230230 float angle = std::asin (crossNorm);
231231 if (v.z < 0 )
232- angle = float (M_PI) - angle;
232+ angle = 180_deg - angle;
233233
234234 // Calculate the resulting quaternion.
235235 return {
0 commit comments