Main Content

simscape.multibody.Transformation Class

R2026b

Namespace: simscape.multibody

Construct transformation

Since R2022a

Description

Use an object of the simscape.multibody.Transformation class to construct a 3-D transformation. Like a simscape.multibody.RigidTransform object, a Transformation object includes a rotation and a translation. However, a Transformation object is a mathematical object used only in 3-D computations and analyses.

Specify the rotation as a unit quaternion and the translation as a simscape.Value object when constructing the transformation. Query the rotation and translation using methods such as quaternion, rotationMatrix, axisAngle, cartesianOffset, and sequenceAngles.

Class Attributes

Sealed
true
ConstructOnLoad
true
RestrictsSubclassing
true

For information on class attributes, see Class Attributes.

Creation

Description

t = simscape.multibody.Transformation creates a 3-D transformation with identity rotation and zero translation.

example

t = simscape.multibody.Transformation(quaternion) creates a 3-D transformation with the specified rotation and zero translation.

example

t = simscape.multibody.Transformation(translation) creates a 3-D transformation with the specified translation and identity rotation.

example

t = simscape.multibody.Transformation(quaternion,translation) creates a 3-D transformation with the specified rotation and translation.

example

Input Arguments

expand all

Rotation quaternion, specified as a 1-by-4 or 4-by-1 double array in [w x y z] format, where w is the scalar part and [x y z] is the vector part. The quaternion must be a unit quaternion.

Example: [0.7071 0 0 0.7071]

Cartesian translation, specified as a simscape.Value object that has a 3-element array and length unit.

Example: simscape.Value([1 0 -1], "m")

Methods

expand all

Examples

collapse all

This example shows how to create a default transformation and query its rotation in matrix form.

Create a transformation with default values. The default display shows the rotation in quaternion format and the translation in Cartesian coordinates.

t = simscape.multibody.Transformation
t =
  Transformation:

       Rotation: [1 0 0 0]
    Translation: [0 0 0] (m)

Extract the rotation as a 3-by-3 rotation matrix. For a default transformation with no rotation, the result is the 3-by-3 identity matrix.

R = rotationMatrix(t)
R = 3×3 double
     1     0     0
     0     1     0
     0     0     1

This example shows how to create a transformation with a rotation quaternion and extract the rotation axis and angle.

Create a transformation that rotates 90 degrees about the z-axis. Specify the rotation as a unit quaternion [w x y z].

t = simscape.multibody.Transformation([0.7071 0 0 0.7071])
t =
  Transformation:

       Rotation: [0.7071 0 0 0.7071]
    Translation: [0 0 0] (m)

Extract the rotation axis and angle.

[axis,angle] = axisAngle(t)
axis = 3×1 double
     0
     0
     1

angle =
    1.5708 (rad)

This example shows how to create a transformation with a translation offset and use it to transform a point.

Create a transformation with a translation of [0.5 -1.0 2.0] meters and no rotation.

t = simscape.multibody.Transformation(simscape.Value([0.5 -1.0 2.0],"m"))
t =
  Transformation:

       Rotation: [1 0 0 0]
    Translation: [0.5000 -1 2] (m)

Use the transformPoint method to apply the transformation to a point. Because this transformation has no rotation, the result is the point shifted by the translation offset.

p = transformPoint(t, simscape.Value([1; 2; 3],"m"))
p =
    1.5000
    1.0000
    5.0000

    (m)

This example shows how to create a transformation with both rotation and translation, and extract the rotation in different representations.

Create a transformation with rotation quaternion [0.5 0.5 0.5 0.5] and translation [1 0 -1] meters.

t = simscape.multibody.Transformation([0.5 0.5 0.5 0.5], simscape.Value([1 0 -1],"m"));
disp(t)
  Transformation:

       Rotation: [0.5000 0.5000 0.5000 0.5000]
    Translation: [1 0 -1] (m)

Extract the rotation axis and angle to understand the rotation geometrically.

[axis,angle] = axisAngle(t)
axis = 3×1 double
    0.5774
    0.5774
    0.5774

angle =
    2.0944 (rad)

Extract the 3-by-3 rotation matrix.

R = rotationMatrix(t)
R = 3×3 double
     0     0     1
     1     0     0
     0     1     0

Version History

Introduced in R2022a