Modelica.Mechanics.MultiBody.Frames.Quaternions

Functions to transform rotational frame quantities based on quaternions (also called Euler parameters)

Information

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.

Content

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/typeDescription
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.FunctionsPackage (Icon for packages containing functions).

Package Content

Name Description
Modelica.Mechanics.MultiBody.Frames.Quaternions.Orientation Orientation Orientation type defining rotation from a frame 1 into a frame 2 with quaternions {p1,p2,p3,p0}
Modelica.Mechanics.MultiBody.Frames.Quaternions.der_Orientation der_Orientation First time derivative of Quaternions.Orientation
Modelica.Mechanics.MultiBody.Frames.Quaternions.orientationConstraint orientationConstraint Return residues of orientation constraints (shall be zero)
Modelica.Mechanics.MultiBody.Frames.Quaternions.angularVelocity1 angularVelocity1 Compute angular velocity resolved in frame 1 from quaternions orientation object and its derivative
Modelica.Mechanics.MultiBody.Frames.Quaternions.angularVelocity2 angularVelocity2 Compute angular velocity resolved in frame 2 from quaternions orientation object and its derivative
Modelica.Mechanics.MultiBody.Frames.Quaternions.resolve1 resolve1 Transform vector from frame 2 to frame 1
Modelica.Mechanics.MultiBody.Frames.Quaternions.resolve2 resolve2 Transform vector from frame 1 to frame 2
Modelica.Mechanics.MultiBody.Frames.Quaternions.multipleResolve1 multipleResolve1 Transform several vectors from frame 2 to frame 1
Modelica.Mechanics.MultiBody.Frames.Quaternions.multipleResolve2 multipleResolve2 Transform several vectors from frame 1 to frame 2
Modelica.Mechanics.MultiBody.Frames.Quaternions.nullRotation nullRotation Return quaternion orientation object that does not rotate a frame
Modelica.Mechanics.MultiBody.Frames.Quaternions.inverseRotation inverseRotation Return inverse quaternions orientation object
Modelica.Mechanics.MultiBody.Frames.Quaternions.relativeRotation relativeRotation Return relative quaternions orientation object
Modelica.Mechanics.MultiBody.Frames.Quaternions.absoluteRotation absoluteRotation Return absolute quaternions orientation object from another absolute and a relative quaternions orientation object
Modelica.Mechanics.MultiBody.Frames.Quaternions.planarRotation planarRotation Return quaternion orientation object of a planar rotation
Modelica.Mechanics.MultiBody.Frames.Quaternions.smallRotation smallRotation Return rotation angles valid for a small rotation
Modelica.Mechanics.MultiBody.Frames.Quaternions.from_T from_T Return quaternion orientation object Q from transformation matrix T
Modelica.Mechanics.MultiBody.Frames.Quaternions.from_T_inv from_T_inv Return quaternion orientation object Q from inverse transformation matrix T_inv
Modelica.Mechanics.MultiBody.Frames.Quaternions.to_T to_T Return transformation matrix T from quaternion orientation object Q
Modelica.Mechanics.MultiBody.Frames.Quaternions.to_T_inv to_T_inv Return inverse transformation matrix T_inv from quaternion orientation object Q

Modelica.Mechanics.MultiBody.Frames.Quaternions.Orientation

Orientation type defining rotation from a frame 1 into a frame 2 with quaternions {p1,p2,p3,p0}

Information

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.

Modelica.Mechanics.MultiBody.Frames.Quaternions.der_Orientation

First time derivative of Quaternions.Orientation

Parameters

NameValue
Custom Parameters
unit"1/s"

Modelica.Mechanics.MultiBody.Frames.Quaternions.orientationConstraint Modelica.Mechanics.MultiBody.Frames.Quaternions.orientationConstraint

Return residues of orientation constraints (shall be zero)

Information

Syntax

residue = Quaternions.orientationConstraint(Q);

Description

This function returns the Real residue vector with 1 element only that describes the constraints between the 4 elements of the quaternions orientation Q.

See also

Frames.orientationConstraint, TransformationMatrices.orientationConstraint.

Extends from Modelica.Icons.Function (Icon for functions).

Inputs

NameDescription
QQuaternions orientation object to rotate frame 1 into frame 2

Outputs

NameDescription
residue[1]Residue constraint (shall be zero)

Modelica.Mechanics.MultiBody.Frames.Quaternions.angularVelocity1 Modelica.Mechanics.MultiBody.Frames.Quaternions.angularVelocity1

Compute angular velocity resolved in frame 1 from quaternions orientation object and its derivative

Information

Syntax

w = Quaternions.angularVelocity1(Q, der_Q);

Description

This function returns the angular velocity w of frame 2 with respect to frame 1, resolved in frame 1, from the quaternions orientation Q that describes the orientation to rotate frame 1 into frame 2 and from its first time derivative der_Q.

See also

Frames.angularVelocity1, TransformationMatrices.angularVelocity1.

Extends from Modelica.Icons.Function (Icon for functions).

Inputs

NameDescription
QQuaternions orientation object to rotate frame 1 into frame 2
der_QDerivative of Q [1/s]

Outputs

NameDescription
w[3]Angular velocity of frame 2 with respect to frame 1 resolved in frame 1 [rad/s]

Modelica.Mechanics.MultiBody.Frames.Quaternions.angularVelocity2 Modelica.Mechanics.MultiBody.Frames.Quaternions.angularVelocity2

Compute angular velocity resolved in frame 2 from quaternions orientation object and its derivative

Information

Syntax

w = Quaternions.angularVelocity2(Q, der_Q);

Description

This function returns the angular velocity w of frame 2 with respect to frame 1, resolved in frame 2, from the quaternions orientation Q that describes the orientation to rotate frame 1 into frame 2 and from its first time derivative der_Q.

See also

Frames.angularVelocity2, TransformationMatrices.angularVelocity2.

Extends from Modelica.Icons.Function (Icon for functions).

Inputs

NameDescription
QQuaternions orientation object to rotate frame 1 into frame 2
der_QDerivative of Q [1/s]

Outputs

NameDescription
w[3]Angular velocity of frame 2 with respect to frame 1 resolved in frame 2 [rad/s]

Modelica.Mechanics.MultiBody.Frames.Quaternions.resolve1 Modelica.Mechanics.MultiBody.Frames.Quaternions.resolve1

Transform vector from frame 2 to frame 1

Information

Syntax

v1 = Quaternions.resolve1(Q, v2);

Description

This function returns vector v resolved in frame 1 (=v1) from vector v resolved in frame 2 (=v2) using the quaternions orientation Q that describes the orientation to rotate frame 1 into frame 2.

See also

resolve2, Frames.resolve1, TransformationMatrices.resolve1.

Extends from Modelica.Icons.Function (Icon for functions).

Inputs

NameDescription
QQuaternions orientation object to rotate frame 1 into frame 2
v2[3]Vector in frame 2

Outputs

NameDescription
v1[3]Vector in frame 1

Modelica.Mechanics.MultiBody.Frames.Quaternions.resolve2 Modelica.Mechanics.MultiBody.Frames.Quaternions.resolve2

Transform vector from frame 1 to frame 2

Information

Syntax

v2 = Quaternions.resolve2(Q, v1);

Description

This function returns vector v resolved in frame 2 (=v2) from vector v resolved in frame 1 (=v1) using the quaternions orientation Q that describes the orientation to rotate frame 1 into frame 2.

See also

resolve1, Frames.resolve2, TransformationMatrices.resolve2.

Extends from Modelica.Icons.Function (Icon for functions).

Inputs

NameDescription
QQuaternions orientation object to rotate frame 1 into frame 2
v1[3]Vector in frame 1

Outputs

NameDescription
v2[3]Vector in frame 2

Modelica.Mechanics.MultiBody.Frames.Quaternions.multipleResolve1 Modelica.Mechanics.MultiBody.Frames.Quaternions.multipleResolve1

Transform several vectors from frame 2 to frame 1

Information

Syntax

v1 = Quaternions.multipleResolve1(Q, v2);

Description

This function returns vectors v resolved in frame 1 (=v1) from vectors v resolved in frame 2 (=v2) using the quaternions orientation Q that describes the orientation to rotate frame 1 into frame 2.

See also

TransformationMatrices.multipleResolve1.

Extends from Modelica.Icons.Function (Icon for functions).

Inputs

NameDescription
QQuaternions orientation object to rotate frame 1 into frame 2
v2[3, :]Vectors in frame 2

Outputs

NameDescription
v1[3, size(v2, 2)]Vectors in frame 1

Modelica.Mechanics.MultiBody.Frames.Quaternions.multipleResolve2 Modelica.Mechanics.MultiBody.Frames.Quaternions.multipleResolve2

Transform several vectors from frame 1 to frame 2

Information

Syntax

v2 = Quaternions.multipleResolve2(Q, v1);

Description

This function returns vectors v resolved in frame 2 (=v2) from vectors v resolved in frame 1 (=v1) using the quaternions orientation Q that describes the orientation to rotate frame 1 into frame 2.

See also

TransformationMatrices.multipleResolve2.

Extends from Modelica.Icons.Function (Icon for functions).

Inputs

NameDescription
QQuaternions orientation object to rotate frame 1 into frame 2
v1[3, :]Vectors in frame 1

Outputs

NameDescription
v2[3, size(v1, 2)]Vectors in frame 2

Modelica.Mechanics.MultiBody.Frames.Quaternions.nullRotation Modelica.Mechanics.MultiBody.Frames.Quaternions.nullRotation

Return quaternion orientation object that does not rotate a frame

Information

Syntax

Q = Quaternions.nullRotation();

Description

This function returns a quaternions orientation Q describing the orientation object to rotate frame 1 into frame 2, if frame 1 and frame 2 are identical. (= transformation matrix is identity matrix and angular velocity is zero).

See also

Frames.nullRotation, TransformationMatrices.nullRotation.

Extends from Modelica.Icons.Function (Icon for functions).

Outputs

NameDescription
QQuaternions orientation object to rotate frame 1 into frame 2

Modelica.Mechanics.MultiBody.Frames.Quaternions.inverseRotation Modelica.Mechanics.MultiBody.Frames.Quaternions.inverseRotation

Return inverse quaternions orientation object

Information

Syntax

Q_inv = Quaternions.inverseRotation(Q);

Description

This function returns quaternions orientation Q_inv that describes the orientation to rotate from frame 2 to frame 1 from the quaternions orientation Q that describes the orientation to rotate from frame 1 into frame 2.

See also

Frames.inverseRotation, TransformationMatrices.inverseRotation.

Extends from Modelica.Icons.Function (Icon for functions).

Inputs

NameDescription
QQuaternions orientation object to rotate frame 1 into frame 2

Outputs

NameDescription
Q_invQuaternions orientation object to rotate frame 2 into frame 1

Modelica.Mechanics.MultiBody.Frames.Quaternions.relativeRotation Modelica.Mechanics.MultiBody.Frames.Quaternions.relativeRotation

Return relative quaternions orientation object

Information

Syntax

Q_rel = Quaternions.relativeRotation(Q1, Q2);

Description

This function returns quaternions orientation Q_rel that describes the orientation to rotate frame 1 to frame 2 from the quaternions orientation Q1 that describes the orientation to rotate from frame 0 to frame 1 and from the quaternions orientation Q2 that describes the orientation to rotate from frame 0 to frame 2.

See also

Frames.relativeRotation, TransformationMatrices.relativeRotation.

Extends from Modelica.Icons.Function (Icon for functions).

Inputs

NameDescription
Q1Quaternions orientation object to rotate frame 0 into frame 1
Q2Quaternions orientation object to rotate frame 0 into frame 2

Outputs

NameDescription
Q_relQuaternions orientation object to rotate frame 1 into frame 2

Modelica.Mechanics.MultiBody.Frames.Quaternions.absoluteRotation Modelica.Mechanics.MultiBody.Frames.Quaternions.absoluteRotation

Return absolute quaternions orientation object from another absolute and a relative quaternions orientation object

Information

Syntax

Q2 = Quaternions.absoluteRotation(Q1, Q_rel);

Description

This function returns quaternions orientation Q2 that describes the orientation frame 0 to frame 2 from the quaternions orientation Q1 that describes the orientation to rotate from frame 0 to frame 1 and from the relative quaternions orientation Q_rel that describes the orientation to rotate from frame 1 to frame 2.

See also

Frames.absoluteRotation, TransformationMatrices.absoluteRotation.

Extends from Modelica.Icons.Function (Icon for functions).

Inputs

NameDescription
Q1Quaternions orientation object to rotate frame 0 into frame 1
Q_relQuaternions orientation object to rotate frame 1 into frame 2

Outputs

NameDescription
Q2Quaternions orientation object to rotate frame 0 into frame 2

Modelica.Mechanics.MultiBody.Frames.Quaternions.planarRotation Modelica.Mechanics.MultiBody.Frames.Quaternions.planarRotation

Return quaternion orientation object of a planar rotation

Information

Syntax

Q = Quaternions.planarRotation(e, angle);

Description

This function returns quaternions orientation Q that describes the orientation to rotate in the plane along unit axis e from frame 1 into frame 2 with angle angle. Note, "e" must be a unit vector. However, this is not checked in this function and the function will return a wrong result, if length(e) is not one.

See also

Frames.planarRotation, TransformationMatrices.planarRotation.

Extends from Modelica.Icons.Function (Icon for functions).

Inputs

NameDescription
e[3]Normalized axis of rotation (must have length=1) [1]
angleRotation angle to rotate frame 1 into frame 2 along axis e [rad]

Outputs

NameDescription
QQuaternions orientation object to rotate frame 1 into frame 2 along axis e

Modelica.Mechanics.MultiBody.Frames.Quaternions.smallRotation Modelica.Mechanics.MultiBody.Frames.Quaternions.smallRotation

Return rotation angles valid for a small rotation

Information

Syntax

phi = Quaternions.smallRotation(Q);

Description

This function returns rotation angles valid for a small rotation of x-y-z sequence (i.e. {1,2,3}).

See also

Frames.smallRotation, TransformationMatrices.smallRotation.

Extends from Modelica.Icons.Function (Icon for functions).

Inputs

NameDescription
QQuaternions orientation object to rotate frame 1 into frame 2

Outputs

NameDescription
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]

Modelica.Mechanics.MultiBody.Frames.Quaternions.from_T Modelica.Mechanics.MultiBody.Frames.Quaternions.from_T

Return quaternion orientation object Q from transformation matrix T

Information

Syntax

Q = Quaternions.from_T(T, Q_guess);

Description

This function returns a quaternions orientation Q. computed from a transformation matrix T and depending on the initial guess Q_guess. Generally, the transformation matrix T can be gained using a function from the TransformationMatrices package.

See also

to_T. from_T_inv, Frames.from_T, TransformationMatrices.from_T.

Extends from Modelica.Icons.Function (Icon for functions).

Inputs

NameDescription
T[3, 3]Transformation matrix to transform vector from frame 1 to frame 2 (v2=T*v1)
Q_guessGuess value for Q (there are 2 solutions; the one close to Q_guess is used

Outputs

NameDescription
QQuaternions orientation object to rotate frame 1 into frame 2 (Q and -Q have same transformation matrix)

Modelica.Mechanics.MultiBody.Frames.Quaternions.from_T_inv Modelica.Mechanics.MultiBody.Frames.Quaternions.from_T_inv

Return quaternion orientation object Q from inverse transformation matrix T_inv

Information

Syntax

Q = Quaternions.from_T_inv(T_inv, Q_guess);

Description

This function returns a quaternions orientation Q. computed from an inverse transformation matrix T_inv and depending on the initial guess Q_guess. Generally, the transformation matrix T_inv can be gained using a function from the TransformationMatrices package, e.g. using T_inv = inverseRotation(T).

See also

from_T, Frames.from_T_inv, TransformationMatrices.from_T_inv.

Extends from Modelica.Icons.Function (Icon for functions).

Inputs

NameDescription
T_inv[3, 3]Inverse transformation matrix to transform vector from frame 2 to frame 1 (v1=T_inv*v2)
Q_guessGuess value for output Q (there are 2 solutions; the one closer to Q_guess is used

Outputs

NameDescription
QQuaternions orientation object to rotate frame 1 into frame 2 (Q and -Q have same transformation matrix)

Modelica.Mechanics.MultiBody.Frames.Quaternions.to_T Modelica.Mechanics.MultiBody.Frames.Quaternions.to_T

Return transformation matrix T from quaternion orientation object Q

Information

Syntax

T = Quaternions.to_T(Q);

Description

This function returns a real matrix T computed from a quaternions orientation Q. The matrix T is considered to be an object transformation matrix.

See also

from_T, to_T_inv, Frames.to_T, TransformationMatrices.to_T.

Extends from Modelica.Icons.Function (Icon for functions).

Inputs

NameDescription
QQuaternions orientation object to rotate frame 1 into frame 2

Outputs

NameDescription
T[3, 3]Transformation matrix to transform vector from frame 1 to frame 2 (v2=T*v1)

Modelica.Mechanics.MultiBody.Frames.Quaternions.to_T_inv Modelica.Mechanics.MultiBody.Frames.Quaternions.to_T_inv

Return inverse transformation matrix T_inv from quaternion orientation object Q

Information

Syntax

T_inv = Quaternions.to_T_inv(Q);

Description

This function returns a real matrix T_inv computed from a quaternions orientation Q. The matrix T is considered to be an inverse transformation matrix.

See also

to_T, from_T_inv, Frames.to_T_inv, TransformationMatrices.to_T_inv.

Extends from Modelica.Icons.Function (Icon for functions).

Inputs

NameDescription
QQuaternions orientation object to rotate frame 1 into frame 2

Outputs

NameDescription
T_inv[3, 3]Transformation matrix to transform vector from frame 2 to frame 1 (v1=T*v2)
Automatically generated Thu Oct 1 16:07:53 2020.