CogniPilot

MODELICA LIBRARY · ENGINEERING REFERENCE

package

LieGroups.SO3.Quat

SO(3) quaternion parameterization — q = {w, x, y, z}

Rotation convention

A unit quaternion is {w,x,y,z}, with Hamilton multiplication. A body-to-world quaternion rotates body vectors into world coordinates with rotate. Keep quaternion sign ambiguity separate from the represented rotation.

Example

For Real q[4] and Real v[3], this algorithm fragment rotates the x axis by 90 degrees about positive z:

q := LieGroups.SO3.Quat.exp_map({0,0,1.5707963267948966});
v := LieGroups.SO3.Quat.rotate(q, {1,0,0});

The result is approximately {0,1,0}. exp_map accepts a rotation vector in radians; log_map returns the local rotation vector. Group operations expect valid rotations; use normalize where a caller must explicitly restore quaternion norm.

Members

NameKindDescription
normalizefunctionNormalize quaternion to unit length
productfunctionHamilton quaternion product q * p
inversefunctionQuaternion inverse (conjugate for unit quaternions)
exp_mapfunctionExponential map: so(3) rotation vector -> unit quaternion
log_mapfunctionLogarithmic map: unit quaternion -> so(3) rotation vector
to_DCMfunctionConvert unit quaternion to 3x3 rotation matrix (DCM)
from_DCMfunctionConvert 3x3 rotation matrix to unit quaternion (Shepperd's method)
rotatefunctionRotate a 3-vector by a quaternion: v' = q @ v
kinematicsfunctionQuaternion kinematics: q_dot = 0.5 * q * [0, omega]
adjointfunctionAdjoint Ad_X: for SO(3), Ad_q = R (the rotation matrix)
small_adjointfunctionSmall adjoint ad_xi: the 3x3 skew-symmetric matrix [v]x
wedgefunctionWedge map: so(3) vector -> 3x3 skew-symmetric matrix (xi^wedge)
veefunctionVee map: 3x3 skew-symmetric matrix -> so(3) vector (S^vee)
left_jacobianfunctionLeft Jacobian J_l(v) of SO(3)
left_jacobian_invfunctionInverse left Jacobian J_l^{-1}(v) of SO(3)
right_jacobianfunctionRight Jacobian J_r(v) of SO(3)
right_jacobian_invfunctionInverse right Jacobian J_r^{-1}(v) of SO(3)
left_jacobian_exactfunctionLeft Jacobian J_l(v) of SO(3), closed form down to the exp_map branch radius
left_jacobian_inv_exactfunctionInverse left Jacobian J_l^-1(v) of SO(3), closed form down to 1e-4 rad
right_jacobian_exactfunctionRight Jacobian J_r(v) of SO(3), closed form down to the exp_map branch radius
right_jacobian_inv_exactfunctionInverse right Jacobian J_r^-1(v) of SO(3), closed form down to 1e-4 rad
exp_map_jacobianfunctionRight-trivialized derivative of exp_map with respect to its rotation vector
log_map_jacobianfunctionRight-trivialized derivative of log_map with respect to its quaternion
product_left_factor_jacobianfunctionRight-trivialized derivative of product with respect to its left factor
product_right_factor_jacobianfunctionRight-trivialized derivative of product with respect to its right factor
inverse_jacobianfunctionRight-trivialized derivative of inverse with respect to its quaternion
rotate_rotation_jacobianfunctionRight-trivialized derivative of rotate with respect to its quaternion
rotate_vector_jacobianfunctionDerivative of rotate with respect to the vector being rotated

Modelica declarations and implementation

Show parameters, interfaces and source

Parameters, inputs, outputs, defaults and equations from the source file.

package Quat "SO(3) quaternion parameterization — q = {w, x, y, z}"
  annotation(Documentation(info = "<html>
    <h4>Rotation convention</h4>
<p>A unit quaternion is {w,x,y,z}, with Hamilton multiplication. A body-to-world
quaternion rotates body vectors into world coordinates with
<a href=\"modelica://LieGroups.SO3.Quat.rotate\">rotate</a>. Keep quaternion
sign ambiguity separate from the represented rotation.</p>
<h4>Example</h4>
<p>For <code>Real q[4]</code> and <code>Real v[3]</code>, this algorithm fragment
rotates the x axis by 90 degrees about positive z:</p>
<pre>q := LieGroups.SO3.Quat.exp_map({0,0,1.5707963267948966});
v := LieGroups.SO3.Quat.rotate(q, {1,0,0});</pre>
<p>The result is approximately {0,1,0}.
<a href=\"modelica://LieGroups.SO3.Quat.exp_map\">exp_map</a> accepts a rotation
vector in radians; <a href=\"modelica://LieGroups.SO3.Quat.log_map\">log_map</a>
returns the local rotation vector. Group operations expect valid rotations;
use <a href=\"modelica://LieGroups.SO3.Quat.normalize\">normalize</a> where a
caller must explicitly restore quaternion norm.</p>
    </html>"));
end Quat;