You represent a Simscape™ Multibody™ body's orientation by specifying the orientation of its center of gravity coordinate system (CG CS) axes relative to some other set of axes, either the CS axes of an adjoining body or the World CS axes. No reorientation is represented by "no rotation" or the rotational identity.

A general rotation of a body in three dimensions has three independent degrees of freedom. There are many equivalent and interconvertible ways to represent these degrees of freedom . The Body and related Body Sensor and RotationMatrix2VR blocks use the following representations. The block reference pages for these blocks discuss block-specific details.

The *axis-angle* representation
of a rotation is the most fundamental form. Specify a rotation axis ** n**, then rotate by the right-hand rule about that axis by
some angle θ. The vector

Simscape Multibody models do not make direct use of the axis-angle representation, but it is the starting point for deriving other forms. It is also used extensively in mechanical applications such as computer-aided design and robotics.

The axis-angle representation is usually written as a 4-vector:
[*n*_{x} *n*_{y} *n*_{z} θ].
Of the four numbers, three are independent, because ** n** always has unit length. The remaining freedom
in this vector allows you to specify a direction (two angles) and
the size and sense of the rotation about that directional axis (magnitude
and sign of θ).

To describe continuous rotation in time, treat ** n** and θ as functions of time.

A *quaternion* represents
a three-dimensional rotation as a four-component row vector of unit
length:

$$q=\left[{n}_{x}\mathrm{sin}\left(\theta /2\right),{n}_{y}\mathrm{sin}\left(\theta /2\right),{n}_{z}\mathrm{sin}\left(\theta /2\right),\mathrm{cos}\left(\theta /2\right)\right]=\left[{q}_{\text{v}},{q}_{\text{s}}\right]$$

with * q*q* =

The axis-angle representation also defines the *rotation matrix* *R* in
exponential form *R* = exp(θ *n·*** J**),
where the

The *J* matrices are related to the antisymmetric
permutation symbol ɛ_{ijk}.

$${\left({J}^{\text{j}}\right)}_{\text{ik}}={\epsilon}_{\text{ijk}}$$

The exponential *R* is reduced to closed form
by the *Rodrigues identity*:

$$R=\mathrm{exp}(\theta n\cdot J)\text{}=\text{}I\text{}+\text{}(n\cdot J)\mathrm{sin}\theta \text{}+\text{}{(n\cdot J)}^{2}(1-\mathrm{cos}\theta )$$

where *I* is the identity matrix, and *n·*** J** is
given by

$$n\cdot J=\left(\begin{array}{ccc}0& -{n}_{z}& {n}_{y}\\ {n}_{z}& 0& -{n}_{x}\\ -{n}_{y}& {n}_{x}& 0\end{array}\right)$$

The inverse of *R* is identical to its transpose *R*^{T}.
You can also obtain the inverse by replacing θ with θ
or by reversing the direction of ** n**.

To describe continuous rotation in time, treat ** n** and θ as functions of time.

An alternative representation for *R* is to
rotate, in succession, about three independent axes, by three independent *Euler angles*. A full rotation *R* starting
in *World* composes by multiplying the matrices
successively on the *left*:

*R*_{BW} = *R*_{3}**R*_{2}**R*_{1}

A full rotation *R* starting in a *body
CS* composes by multiplying the matrices successively on
the *right*:

*R*_{WB} = *R*_{1}**R*_{2}**R*_{3}

The Euler angle convention is to

Rotate about one body coordinate axis (which rotates the other two).

Then rotate about a second body coordinate axis (rotated from its original direction) not identical to the first.

Lastly, rotate about another body coordinate axis not identical to the second.

Thus there are 3*2*2 = 12 possible Euler angle rotation sequences.
The rotation axis sequences *Z-X-Z* and *Z-Y-X* are
common. Rotation angles are often labeled as θ_{1},
θ_{2}, θ_{3} or
Φ, θ, Ψ as the first, second, and third angles,
respectively. For example,

*R*_{BW} = *R*_{X}(θ_{1})**R*_{Y}(θ_{2})**R*_{Z}(θ_{3})

*R*_{WB} = *R*_{Z}(Φ)**R*_{X}(θ)**R*_{Z}(Ψ)

A two-dimensional rotation about a fixed axis requires one angle.
For example, rotating the *x*- and *y*-axes
about the *z*-axis by Φ is represented by

$${R}_{Z}\left(\varphi \right)=\left(\begin{array}{ccc}\mathrm{cos}\varphi & -\mathrm{sin}\varphi & 0\\ \mathrm{sin}\varphi & \mathrm{cos}\varphi & 0\\ 0& 0& 1\end{array}\right)$$

To describe continuous rotation in time, treat the Euler angles as functions of time. The Euler angle representation is singular in certain limiting situations. Such singularities are artifacts of the Euler angle form and have no geometric or physical significance.

Certain Simscape Multibody blocks make use of different rotation representations.

The Body block makes direct use of the Euler angle, rotation matrix, and quaternion representations.

The Body Sensor block makes use of the rotation matrix.

The RotationMatrix2VR block uses the rotation matrix and axis-angle forms.

The four rotation representations presented in this section are equivalent. You can represent a rotation equally well with any one of them. Some applications, however, tend to favor one representation over the others, and certain representations are singular in certain limits. It is helpful to know how to convert the various rotation representations into one another. The following summaries group the conversion formulas into one place.

The rotation axis unit vector ** n** and
the rotation angle θ define this representation, which is discussed
in detail in Axis-Angle Representation. This representation defines
the quaternion and rotation matrix representations:

$$\begin{array}{l}q=\left[{n}_{x}\mathrm{sin}\left(\theta /2\right),{n}_{y}\mathrm{sin}\left(\theta /2\right),{n}_{z}\mathrm{sin}\left(\theta /2\right),\mathrm{cos}\left(\theta /2\right)\right]=\left[{q}_{\text{v}},{q}_{\text{s}}\right]\\ R=\mathrm{exp}(\theta n\cdot J)\text{}=\text{}I\text{}+\text{}(n\cdot J)\mathrm{sin}\theta \text{}+\text{}{(}^{n}(1-\mathrm{cos}\theta )\end{array}$$

$$n\cdot J=\left(\begin{array}{ccc}0& -{n}_{z}& {n}_{y}\\ {n}_{z}& 0& -{n}_{x}\\ -{n}_{y}& {n}_{x}& 0\end{array}\right)$$

The quaternion is a vector-scalar pair, `q`

` `

= [*q*_{v} *q*_{s}],
defined by Quaternion Representation. You can recover the axis-angle
representation from the quaternion components:

$$\begin{array}{l}\theta =2\cdot {\mathrm{cos}}^{-1}\left({q}_{\text{s}}\right)\\ n={q}_{\text{v}}/\sqrt{1-{q}_{\text{s}}{}^{2}}\end{array}$$

You can also construct the equivalent rotation matrix *R* from *q*.

$$\begin{array}{l}R\text{}=\text{}(2{q}_{\text{s}}^{2}-1)I+2{q}_{\text{s}}{Q}_{\text{v}}+2{q}_{\text{v}}^{\text{T}}\otimes {q}_{\text{v}}\\ {\left({Q}_{\text{v}}\right)}_{\text{ik}}={\displaystyle {\sum}_{\text{j}}{\epsilon}_{\text{ijk}}}{\left({q}_{\text{v}}\right)}_{\text{j}}\end{array}$$

The term $${q}_{\text{v}}^{\text{T}}\otimes {q}_{\text{v}}$$ is the *outer product* of *q*_{v} with itself, the
3-by-3 matrix of *q*_{v} components
multiplied by each other.

The rotation matrix *R* is an orthogonal 3-by-3
matrix: *RR*^{T} = *R*^{T}*R* = *I*, defined in Rotation Matrix Representation. You can invert the
rotation matrix representation to obtain the equivalent representations
for the quaternion * q* = [

$$\begin{array}{l}{q}_{\text{s}}={\scriptscriptstyle \frac{1}{2}}\sqrt{Tr(R)+1}\\ {q}_{\text{v}}=Tr(J\ast R)/\left(2\sqrt{Tr(R)+1}\right)\\ \theta =2\cdot {\mathrm{cos}}^{-1}\left({\scriptscriptstyle \frac{1}{2}}\sqrt{Tr(R)+1}\right)\\ n=Tr(J\ast R)/\left(\sqrt{Tr(R)+1}\cdot \sqrt{3-Tr(R)}\right)\end{array}$$

The trace *Tr* of a matrix is the sum of
its diagonal elements.

The J matrices constitute a 3-vector of matrices defined by
the antisymmetric permutation symbol, (*J*^{j})_{ik} = ɛ_{ijk}.
See The Permutation Symbol and the Vector Cross Product for
more details.

The RotationMatrix2VR block converts the rotation matrix to the axis-angle representation.

The Euler angle representation of a rotation, defined by Euler Angle Representation, stands apart from the other three, insofar as you cannot derive it from the axis-angle representation. It depends on the choice of rotation axis sequence, which generates multiple definition conventions. The Euler angle representation, at certain limits, can also be singular. Use caution with Euler angle expressions.

If you choose a convention and three angles, then compute *R*,
you can convert *R* to the other representations
by the use of Transforming the Rotation Matrix Representation above.
But given the nine components of *R*, you must find
the Euler angles by inverting the nine equations that result from
this matrix equation. (Only three equations of the nine are independent.)
In some cases, angles can be read from *R* by inspection.

For example, choose rotations with respect to a Body coordinate
system (CS) triad, in a commonly used rotation axis sequence *Z-X-Z*,
with Φ, θ, Ψ as the respective angles. The rotation
matrix is *R*_{WB} = *R*_{1}(Φ)**R*_{2}(θ)**R*_{3}(Ψ),

$$\begin{array}{l}{R}_{\text{WB}}\left(\varphi ,\theta ,\psi \right)=\left(\begin{array}{ccc}\mathrm{cos}\varphi & -\mathrm{sin}\varphi & 0\\ \mathrm{sin}\varphi & \mathrm{cos}\varphi & 0\\ 0& 0& 1\end{array}\right)\left(\begin{array}{ccc}1& 0& 0\\ 0& \mathrm{cos}\theta & -\mathrm{sin}\theta \\ 0& \mathrm{sin}\theta & \mathrm{cos}\theta \end{array}\right)\left(\begin{array}{ccc}\mathrm{cos}\psi & -\mathrm{sin}\psi & 0\\ \mathrm{sin}\psi & \mathrm{cos}\psi & 0\\ 0& 0& 1\end{array}\right)\\ =\left(\begin{array}{ccc}\mathrm{cos}\varphi \mathrm{cos}\psi -\mathrm{sin}\varphi \mathrm{cos}\theta \mathrm{sin}\psi & -\mathrm{cos}\varphi \mathrm{sin}\psi -\mathrm{sin}\varphi \mathrm{cos}\theta \mathrm{cos}\psi & \mathrm{sin}\varphi \mathrm{sin}\theta \\ \mathrm{sin}\varphi \mathrm{cos}\psi +\mathrm{cos}\varphi \mathrm{cos}\theta \mathrm{sin}\psi & -\mathrm{sin}\varphi \mathrm{sin}\psi +\mathrm{cos}\varphi \mathrm{cos}\theta \mathrm{cos}\psi & -\mathrm{cos}\varphi \mathrm{sin}\theta \\ \mathrm{sin}\theta \mathrm{sin}\psi & \mathrm{sin}\theta \mathrm{cos}\psi & \mathrm{cos}\theta \end{array}\right)\end{array}$$

In this convention, you can read θ from the *R*_{33} component,
then find Ψ from the *R*_{32} or *R*_{31} component.
Obtain Φ from one of the other components, using cos^{2}Φ
+ sin^{2}Φ = 1,
or by multiplying from the right by *R*_{3}Ψ^{T},
then *R*_{2}θ^{T}.
The second method yields a unique solution for the sine and cosine
of Φ.

The rotation matrix *R* is defined in Representations of Body Motion and Rotation Matrix Representation.

The angular velocity vector ω is the rate at which a spinning
CS rotates. *R* and the antisymmetric matrix Ω
define ω:

$$\begin{array}{l}\Omega =+\left(\text{d}R/\text{dt}\right)\cdot {R}^{\text{T}}=-R\cdot \left(\text{d}{R}^{\text{T}}/\text{dt}\right)\\ {\Omega}_{\text{ik}}=\text{+}{\displaystyle {\sum}_{\text{j}}{\epsilon}_{\text{ijk}}{\omega}_{\text{j}}}\\ {\omega}_{\text{j}}=\left({\scriptscriptstyle \frac{\text{1}}{\text{2}}}\right){\displaystyle {\sum}_{\text{ik}}{\epsilon}_{\text{ijk}}{\Omega}_{\text{ik}}}\end{array}$$

You can also express the angular velocity in terms of Euler
angles, by choosing a particular set of angles to represent *R*.
See Euler Angle Representation and Transforming the Euler Angle Representation.

The quaternion derivative is also related to the angular velocity:

$$\begin{array}{l}\text{d}{q}_{\text{v}}\text{/dt}=\left({\scriptscriptstyle \frac{\text{1}}{\text{2}}}\right)\left({q}_{\text{s}}{\omega}_{\text{Body}}-{q}_{\text{v}}\text{x}{\omega}_{\text{Body}}\right)\\ \text{d}{q}_{\text{s}}\text{/dt}=-\left({\scriptscriptstyle \frac{\text{1}}{\text{2}}}\right)\text{(}{q}_{\text{v}}\cdot {\omega}_{\text{Body}}\text{)}\end{array}$$

Was this topic helpful?