function
LieGroups.SO3.Quat.product
Hamilton quaternion product q * p
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] | Left quaternion {w,x,y,z} |
| input | p | Real | [4] | Right quaternion {w,x,y,z} |
| output | r | Real | [4] | Result quaternion {w,x,y,z} |
Modelica declarations and implementation
Show parameters, interfaces and source
Parameters, inputs, outputs, defaults and equations from the source file.
function product "Hamilton quaternion product q * p"
input Real q[4] "Left quaternion {w,x,y,z}";
input Real p[4] "Right quaternion {w,x,y,z}";
output Real r[4] "Result quaternion {w,x,y,z}";
algorithm
r[1] := q[1]*p[1] - q[2]*p[2] - q[3]*p[3] - q[4]*p[4];
r[2] := q[2]*p[1] + q[1]*p[2] - q[4]*p[3] + q[3]*p[4];
r[3] := q[3]*p[1] + q[4]*p[2] + q[1]*p[3] - q[2]*p[4];
r[4] := q[4]*p[1] - q[3]*p[2] + q[2]*p[3] + q[1]*p[4];
end product;