function
LieGroups.SO3.Quat.rotate
Rotate a 3-vector by a quaternion: v' = q @ v
Public declarations
Explicit source declarations; dimensions, modifications and defaults are shown as written, without evaluation.
| Role | Name | Type | Dimensions / attributes / default | Description |
|---|---|---|---|---|
| input | q | Real | [4] | Unit quaternion {w,x,y,z} |
| input | v | Real | [3] | Input vector |
| output | v_out | Real | [3] | Rotated vector |
Modelica declarations and implementation
Show parameters, interfaces and source
Parameters, inputs, outputs, defaults and equations from the source file.
function rotate "Rotate a 3-vector by a quaternion: v' = q @ v"
input Real q[4] "Unit quaternion {w,x,y,z}";
input Real v[3] "Input vector";
output Real v_out[3] "Rotated vector";
protected
Real R[3,3];
algorithm
R := LieGroups.SO3.Quat.to_DCM(q);
v_out := R * v;
end rotate;