Functions to transform rotational frame quantities based on quaternions (also called Euler parameters)
Package Frames.Quaternions contains type definitions and functions to transform rotational frame quantities with quaternions. Functions of this package are currently only utilized in MultiBody.Parts.Body components, when quaternions shall be used as parts of the body states. Some functions are also used in a new Modelica package for B-Spline interpolation that is able to interpolate paths consisting of position vectors and orientation objects.
In the table below an example is given for every function definition. The used variables have the following declaration:
Quaternions.Orientation Q, Q1, Q2, Q_rel, Q_inv; Real[3,3] T, T_inv; Real[3] v1, v2, w1, w2, n_x, n_y, n_z, res_ori, phi; Real[6] res_equal; Real L, angle;
Function/type | Description |
---|---|
Orientation Q; | New type defining a quaternion object that describes the rotation of frame 1 into frame 2. |
der_Orientation der_Q; | New type defining the first time derivative of Frames.Quaternions.Orientation. |
res_ori = orientationConstraint(Q); | Return the constraints between the variables of a quaternion object (shall be zero). |
w1 = angularVelocity1(Q, der_Q); | Return angular velocity resolved in frame 1 from
quaternion object Q and its derivative der_Q. |
w2 = angularVelocity2(Q, der_Q); | Return angular velocity resolved in frame 2 from
quaternion object Q and its derivative der_Q. |
v1 = resolve1(Q,v2); | Transform vector v2 from frame 2 to frame 1. |
v2 = resolve2(Q,v1); | Transform vector v1 from frame 1 to frame 2. |
[v1,w1] = multipleResolve1(Q, [v2,w2]); | Transform several vectors from frame 2 to frame 1. |
[v2,w2] = multipleResolve2(Q, [v1,w1]); | Transform several vectors from frame 1 to frame 2. |
Q = nullRotation() | Return quaternion object R that does not rotate a frame. |
Q_inv = inverseRotation(Q); | Return inverse quaternion object. |
Q_rel = relativeRotation(Q1,Q2); | Return relative quaternion object from two absolute quaternion objects. |
Q2 = absoluteRotation(Q1,Q_rel); | Return absolute quaternion object from another
absolute and a relative quaternion object. |
Q = planarRotation(e, angle); | Return quaternion object of a planar rotation. |
phi = smallRotation(Q); | Return rotation angles phi valid for a small rotation. |
Q = from_T(T); | Return quaternion object Q from transformation matrix T. |
Q = from_T_inv(T_inv); | Return quaternion object Q from inverse transformation matrix T_inv. |
T = to_T(Q); | Return transformation matrix T from quaternion object Q. |
T_inv = to_T_inv(Q); | Return inverse transformation matrix T_inv from quaternion object Q. |
Extends from Modelica.Icons.Package (Icon for standard packages).
Name | Description |
---|---|
Orientation | Orientation type defining rotation from a frame 1 into a frame 2 with quaternions {p1,p2,p3,p0} |
der_Orientation | First time derivative of Quaternions.Orientation |
orientationConstraint | Return residues of orientation constraints (shall be zero) |
angularVelocity1 | Compute angular velocity resolved in frame 1 from quaternion orientation object and its derivative |
angularVelocity2 | Compute angular velocity resolved in frame 2 from quaternions orientation object and its derivative |
resolve1 | Transform vector from frame 2 to frame 1 |
resolve2 | Transform vector from frame 1 to frame 2 |
multipleResolve1 | Transform several vectors from frame 2 to frame 1 |
multipleResolve2 | Transform several vectors from frame 1 to frame 2 |
nullRotation | Return quaternion orientation object that does not rotate a frame |
inverseRotation | Return inverse quaternions orientation object |
relativeRotation | Return relative quaternions orientation object |
absoluteRotation | Return absolute quaternions orientation object from another absolute and a relative quaternions orientation object |
planarRotation | Return quaternion orientation object of a planar rotation |
smallRotation | Return rotation angles valid for a small rotation |
from_T | Return quaternion orientation object Q from transformation matrix T |
from_T_inv | Return quaternion orientation object Q from inverse transformation matrix T_inv |
to_T | Return transformation matrix T from quaternion orientation object Q |
to_T_inv | Return inverse transformation matrix T_inv from quaternion orientation object Q |
Orientation type defining rotation from a frame 1 into a frame 2 with quaternions {p1,p2,p3,p0}
This type describes the rotation to rotate a frame 1 into a frame 2 using quaternions (also called Euler parameters) according to the following definition:
Quaternions.Orientation Q; Real n[3]; Real phi(unit="rad"); Q = [ n*sin(phi/2) cos(phi/2) ]
where "n" is the axis of rotation to rotate frame 1 into frame 2 and "phi" is the rotation angle for this rotation. Vector "n" is either resolved in frame 1 or in frame 2 (the result is the same since the coordinates of "n" with respect to frame 1 are identical to its coordinates with respect to frame 2).
The term "quaternions" is preferred over the historically more reasonable "Euler parameters" in order to not get confused with Modelica "parameters".
Extends from Internal.QuaternionBase.
First time derivative of Quaternions.Orientation
Name | Description |
---|---|
unit |
Return residues of orientation constraints (shall be zero)
Extends from Modelica.Icons.Function (Icon for functions).
Name | Description |
---|---|
Q | Quaternions orientation object to rotate frame 1 into frame 2 |
Name | Description |
---|---|
residue[1] | Residue constraint (shall be zero) |
Compute angular velocity resolved in frame 1 from quaternion orientation object and its derivative
Extends from Modelica.Icons.Function (Icon for functions).
Name | Description |
---|---|
Q | Quaternions orientation object to rotate frame 1 into frame 2 |
der_Q | Derivative of Q [1/s] |
Name | Description |
---|---|
w[3] | Angular velocity resolved in frame 1 [rad/s] |
Compute angular velocity resolved in frame 2 from quaternions orientation object and its derivative
Extends from Modelica.Icons.Function (Icon for functions).
Name | Description |
---|---|
Q | Quaternions orientation object to rotate frame 1 into frame 2 |
der_Q | Derivative of Q [1/s] |
Name | Description |
---|---|
w[3] | Angular velocity of frame 2 with respect to frame 1 resolved in frame 2 [rad/s] |
Transform vector from frame 2 to frame 1
Extends from Modelica.Icons.Function (Icon for functions).
Name | Description |
---|---|
Q | Quaternions orientation object to rotate frame 1 into frame 2 |
v2[3] | Vector in frame 2 |
Name | Description |
---|---|
v1[3] | Vector in frame 1 |
Transform vector from frame 1 to frame 2
Extends from Modelica.Icons.Function (Icon for functions).
Name | Description |
---|---|
Q | Quaternions orientation object to rotate frame 1 into frame 2 |
v1[3] | Vector in frame 1 |
Name | Description |
---|---|
v2[3] | Vector in frame 2 |
Transform several vectors from frame 2 to frame 1
Extends from Modelica.Icons.Function (Icon for functions).
Name | Description |
---|---|
Q | Quaternions orientation object to rotate frame 1 into frame 2 |
v2[3, :] | Vectors in frame 2 |
Name | Description |
---|---|
v1[3, size(v2, 2)] | Vectors in frame 1 |
Transform several vectors from frame 1 to frame 2
Extends from Modelica.Icons.Function (Icon for functions).
Name | Description |
---|---|
Q | Quaternions orientation object to rotate frame 1 into frame 2 |
v1[3, :] | Vectors in frame 1 |
Name | Description |
---|---|
v2[3, size(v1, 2)] | Vectors in frame 2 |
Return quaternion orientation object that does not rotate a frame
Extends from Modelica.Icons.Function (Icon for functions).
Name | Description |
---|---|
Q | Quaternions orientation object to rotate frame 1 into frame 2 |
Return inverse quaternions orientation object
Extends from Modelica.Icons.Function (Icon for functions).
Name | Description |
---|---|
Q | Quaternions orientation object to rotate frame 1 into frame 2 |
Name | Description |
---|---|
Q_inv | Quaternions orientation object to rotate frame 2 into frame 1 |
Return relative quaternions orientation object
Extends from Modelica.Icons.Function (Icon for functions).
Name | Description |
---|---|
Q1 | Quaternions orientation object to rotate frame 0 into frame 1 |
Q2 | Quaternions orientation object to rotate frame 0 into frame 2 |
Name | Description |
---|---|
Q_rel | Quaternions orientation object to rotate frame 1 into frame 2 |
Return absolute quaternions orientation object from another absolute and a relative quaternions orientation object
Extends from Modelica.Icons.Function (Icon for functions).
Name | Description |
---|---|
Q1 | Quaternions orientation object to rotate frame 0 into frame 1 |
Q_rel | Quaternions orientation object to rotate frame 1 into frame 2 |
Name | Description |
---|---|
Q2 | Quaternions orientation object to rotate frame 0 into frame 2 |
Return quaternion orientation object of a planar rotation
Extends from Modelica.Icons.Function (Icon for functions).
Name | Description |
---|---|
e[3] | Normalized axis of rotation (must have length=1) [1] |
angle | Rotation angle to rotate frame 1 into frame 2 along axis e [rad] |
Name | Description |
---|---|
Q | Quaternions orientation object to rotate frame 1 into frame 2 along axis e |
Return rotation angles valid for a small rotation
Extends from Modelica.Icons.Function (Icon for functions).
Name | Description |
---|---|
Q | Quaternions orientation object to rotate frame 1 into frame 2 |
Name | Description |
---|---|
phi[3] | The rotation angles around x-, y-, and z-axis of frame 1 to rotate frame 1 into frame 2 for a small relative rotation [rad] |
Return quaternion orientation object Q from transformation matrix T
Extends from Modelica.Icons.Function (Icon for functions).
Name | Description |
---|---|
T[3, 3] | Transformation matrix to transform vector from frame 1 to frame 2 (v2=T*v1) |
Q_guess | Guess value for Q (there are 2 solutions; the one close to Q_guess is used |
Name | Description |
---|---|
Q | Quaternions orientation object to rotate frame 1 into frame 2 (Q and -Q have same transformation matrix) |
Return quaternion orientation object Q from inverse transformation matrix T_inv
Extends from Modelica.Icons.Function (Icon for functions).
Name | Description |
---|---|
T_inv[3, 3] | Inverse transformation matrix to transform vector from frame 2 to frame 1 (v1=T_inv*v2) |
Q_guess | Guess value for output Q (there are 2 solutions; the one closer to Q_guess is used |
Name | Description |
---|---|
Q | Quaternions orientation object to rotate frame 1 into frame 2 (Q and -Q have same transformation matrix) |
Return transformation matrix T from quaternion orientation object Q
Extends from Modelica.Icons.Function (Icon for functions).
Name | Description |
---|---|
Q | Quaternions orientation object to rotate frame 1 into frame 2 |
Name | Description |
---|---|
T[3, 3] | Transformation matrix to transform vector from frame 1 to frame 2 (v2=T*v1) |
Return inverse transformation matrix T_inv from quaternion orientation object Q
Extends from Modelica.Icons.Function (Icon for functions).
Name | Description |
---|---|
Q | Quaternions orientation object to rotate frame 1 into frame 2 |
Name | Description |
---|---|
T_inv[3, 3] | Transformation matrix to transform vector from frame 2 to frame 1 (v1=T*v2) |