Rumba C++ SDK
AngleAxis.h
Go to the documentation of this file.
1 /*
2 
3  *
4  ***
5  *****
6  ********************* Mercenaries Engineering SARL
7  ***************** Copyright (C) 2025
8  *************
9  ********* http://www.mercenaries-engineering.com
10  ***********
11  **** ****
12  ** **
13 
14 */
15 #pragma once
16 
17 #include <ImathQuat.h>
18 
19 namespace maquina
20 {
21 
22 template<class T>
23 class AngleAxis
24 {
25 public:
26  AngleAxis() : angle_axis(0.0) {}
27  AngleAxis(T x, T y, T z) : angle_axis(x, y, z) {}
29  {
30  T theta = 2.0 * atan2(q.v.length(), q.r);
31  const Imath::Vec3<T> w = theta != 0.0 ? q.v / sin(theta/T(2)) : Imath::Vec3<T>{0};
32  angle_axis = theta*w;
33  }
34 
36  {
37  const T theta = angle_axis.length();
38  const Imath::Vec3<T> w = theta == 0.0 ? Imath::Vec3<T>{0.0} : angle_axis/theta;
39  return Imath::Quat<T>(cos(theta), sin(theta)*w);
40  }
41 
43 };
44 
47 
48 }
The y component of a vector value.
Vec3< T > v
Definition: ImathQuat.h:76
Definition: ImathFrame.h:42
The x component of a vector value.
This version of the SDK is unstable, i-e, it may change with no warning.
Definition: AddCurveAction.h:20
Definition: AngleAxis.h:23
AngleAxis(const Imath::Quat< T > &q)
Definition: AngleAxis.h:28
Definition: ImathQuat.h:71
T r
Definition: ImathQuat.h:75
AngleAxis(T x, T y, T z)
Definition: AngleAxis.h:27
Imath::Quat< T > to_quat() const
Definition: AngleAxis.h:35
The z component of a vector value.
AngleAxis()
Definition: AngleAxis.h:26
Imath::Vec3< T > angle_axis
Definition: AngleAxis.h:42
The w component of a vector value.