Main Content

matrix2transform

Class: sim3d.scenario.ActorBehavior
Namespace: sim3d.scenario

Convert 4-by-4 pose matrix to translation, rotation, and scale vectors

Since R2023b

Syntax

[translation, rotation, scale] = matrix2transform(self, matrix)

Description

[translation, rotation, scale] = matrix2transform(self, matrix) converts the 4-by-4 transformation matrix matrix to 3D translation, rotation, and scale vectors. Use the matrix2transform method to convert pose matrices used by RoadRunner to translation and rotation vectors used by Simulink® 3D Animation™. For more information about the output vectors, see sim3d.Actor (Simulink 3D Animation).

Input Arguments

expand all

Actor behavior object handle, specified as a sim3d.scenario.ActorBehavior object. For more information, see sim3d.scenario.ActorBehavior.

Transformation matrix, specified as a 4-by-4 real matrix.

Data Types: double

Output Arguments

expand all

3D translation component of the pose matrix, returned as a 1-by-3 real vector of translations along the X, Y, and Z axes.

Data Types: double

3D rotation component of the pose matrix, returned as right-direction rotation angles in radians about the X (pitch), Y (roll), and Z (yaw) axes.

Data Types: double

3D scale component of the pose matrix, returned as a 1-by-3 real vector of scale factors in the X, Y, and Z axes.

Data Types: double

Attributes

Accessprotected

To learn about attributes of methods, see Method Attributes.

Examples

expand all

Using the onSimulationStart method, retrieve the RoadRunner pose matrix. Use the matrix2transform method to convert the pose matrix to translation, rotation, and scale components. Update the fields of the 3D actor with these values.

function onSimulationStart(self, actorSimulation)
  [translation, rotation, scale] = matrix2transform(self, self.Pose);
  self.Actor.Translation(1, :) = translation;
  self.Actor.Rotation(1, :) = rotation;
  self.Actor.Scale(1, :) = scale;
end

Version History

Introduced in R2023b