Main Content

transform2matrix

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

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

Since R2023b

Syntax

matrix = transform2matrix(self, translation, rotation, scale)

Description

matrix = transform2matrix(self, translation, rotation, scale) converts 3D translation, rotation, and scale vectors used by Simulink® 3D Animation™ to a pose matrix used by RoadRunner. For more information about the input vectors, see sim3d.Actor (Simulink 3D Animation).

Input Arguments

expand all

Actor behavior object handle, specified as a sim3d.scenario.ActorBehavior object.

3D translation, specified as a 1-by-3 real vector of X, Y, and Z translation components.

Data Types: double

3D rotation, specified as a 1-by-3 real vector of right-direction rotations in radians about the X (pitch), Y (roll), and Z (yaw) axes.

Data Types: double

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

Data Types: double

Output Arguments

expand all

3D transformation matrix, specified as a 4x4 matrix of doubles.

Attributes

Accessprotected

To learn about attributes of methods, see Method Attributes.

Examples

expand all

At the start of simulation, set the RoadRunner Pose attribute using the transform2matrix method and the 3D actor pose.

function onSimulationStart(self, event)
  translation = [100 200 0];
  rotation = deg2rad([0 0 25]);
  scale = [1 1 1];
  self.Pose = transform2matrix(self, translation, rotation, scale);

  self.Actor.Translation(1, :) = translation;
  self.Actor.Rotation(1, :) = rotation;
  self.Actor.Scale(1, :) = scale;
end

Version History

Introduced in R2023b