Algorithms_in_C 1.0.0
Set of algorithms implemented in C.
|
Data Structures | |
struct | quaternion_ |
a Quaternion type represented using a scalar \(w\) or \(q_0\) and a 3D vector \(\left(q_1,q_2,q_3\right)\) More... | |
struct | euler_ |
3D Euler or Tait-Bryan angles (in radian) More... | |
Typedefs | |
typedef struct quaternion_ | quaternion |
a Quaternion type represented using a scalar \(w\) or \(q_0\) and a 3D vector \(\left(q_1,q_2,q_3\right)\) | |
typedef struct euler_ | euler |
3D Euler or Tait-Bryan angles (in radian) | |
Functions | |
quaternion | quat_from_euler (const euler *in_euler) |
Function to convert given Euler angles to a quaternion. | |
euler | euler_from_quat (const quaternion *in_quat) |
Function to convert given quaternion to Euler angles. | |
quaternion | quaternion_multiply (const quaternion *in_quat1, const quaternion *in_quat2) |
Function to multiply two quaternions. | |
euler euler_from_quat | ( | const quaternion * | in_quat | ) |
Function to convert given quaternion to Euler angles.
\begin{eqnarray*} \phi & = & \tan^{-1}\left[\frac{2\left(q_0q_1+q_2q_3\right)}{1-2\left(q_1^2+q_2^2\right)}\right]\\ \theta & = &-\sin^{-1}\left[2\left(q_0q_2-q_3q_1\right)\right]\\ \psi & = & \tan^{-1}\left[\frac{2\left(q_0q_3+q_1q_2\right)}{1-2\left(q_2^2+q_3^2\right)}\right]\\ \end{eqnarray*}
[in] | in_quat | input quaternion instance |
quaternion quat_from_euler | ( | const euler * | in_euler | ) |
Function to convert given Euler angles to a quaternion.
\begin{eqnarray*} q_{0} & = &\cos\left(\frac{\phi}{2}\right)\cos\left(\frac{\theta}{2}\right)\cos\left(\frac{\psi}{2}\right) + \sin\left(\frac{\phi}{2}\right)\sin\left(\frac{\theta}{2}\right)\sin\left(\frac{\psi}{2}\right)\\ q_{1} & = &\sin\left(\frac{\phi}{2}\right)\cos\left(\frac{\theta}{2}\right)\cos\left(\frac{\psi}{2}\right) - \cos\left(\frac{\phi}{2}\right)\sin\left(\frac{\theta}{2}\right)\sin\left(\frac{\psi}{2}\right)\\ q_{2} & = &\cos\left(\frac{\phi}{2}\right)\sin\left(\frac{\theta}{2}\right)\cos\left(\frac{\psi}{2}\right) + \sin\left(\frac{\phi}{2}\right)\cos\left(\frac{\theta}{2}\right)\sin\left(\frac{\psi}{2}\right)\\ q_{3} & = &\cos\left(\frac{\phi}{2}\right)\cos\left(\frac{\theta}{2}\right)\sin\left(\frac{\psi}{2}\right) - \sin\left(\frac{\phi}{2}\right)\sin\left(\frac{\theta}{2}\right)\cos\left(\frac{\psi}{2}\right)\\ \end{eqnarray*}
[in] | in_euler | input Euler angles instance |
quaternion quaternion_multiply | ( | const quaternion * | in_quat1, |
const quaternion * | in_quat2 | ||
) |
Function to multiply two quaternions.
\begin{eqnarray*} \mathbf{c} & = & \mathbf{a}\otimes\mathbf{b}\\ & = & \begin{bmatrix}a_{0} & a_{1} & a_{2} & a_{3}\end{bmatrix}\otimes\begin{bmatrix}b_{0} & b_{1} & b_{2} & b_{3}\end{bmatrix}\\ & = & \begin{bmatrix} a_{0}b_{0}-a_{1}b_{1}-a_{2}b_{2}-a_{3}b_{3}\\ a_{0}b_{1}+a_{1}b_{0}+a_{2}b_{3}-a_{3}b_{2}\\ a_{0}b_{2}-a_{1}b_{3}+a_{2}b_{0}+a_{3}b_{1}\\ a_{0}b_{3}+a_{1}b_{2}-a_{2}b_{1}+a_{3}b_{0} \end{bmatrix}^{T} \end{eqnarray*}
[in] | in_quat1 | first input quaternion instance |
[in] | in_quat2 | second input quaternion instance |