Class: Transform

RS.Transform

The Transform class provides a more user friendly way of manipulating matrices. Typically this class would be initialized by setting the world_to_obj property with a matrix that has been retrieved from RealityServer. The translation, rotation and scale properties will then contain the object to world space geometric properties of that matrix. The transform can then be manipulated as desired and the world_to_obj property then used to set the matrix of a RealityServer Instance.

NB: All properties return copies of the internal values. Editing the components of these properties directly will not modify the transform. You need to set values back onto the properties to effect changes.

const t = new Transform();
t.translation.x = 1.0; //< Incorrect
const v = t.translation;
v.x = 1.0;
t.translation = v; //< Correct

new RS.Transform ()

The default constructor initializes with an identity matrix.

Members

RS.Transform.NEG_X_AXIS Vector4 static

The negative X Axis vector

RS.Transform.NEG_Y_AXIS Vector4 static

The negative Y Axis vector

RS.Transform.NEG_Z_AXIS Vector4 static

The negative Z Axis vector

RS.Transform.X_AXIS Vector4 static

The X Axis vector

RS.Transform.Y_AXIS Vector4 static

The Y Axis vector

RS.Transform.Z_AXIS Vector4 static

The Z Axis vector

rotation RS.Quaternion

The rotation component of this Transform

scale RS.Vector3

The scale component of this transform

translation RS.Vector3

The translation component of this Transform

world_to_obj RS.Matrix4x4

The World to Object space Matrix represented by this Transform

x_axis RS.Vector3 readonly

The X axis of this transform

y_axis RS.Vector3 readonly

The Y axis of this transform

z_axis RS.Vector3 readonly

The Z axis of this transform

Methods

clone ()RS.Transform

returns a copy of this Transform.

Returns:
Type Description
RS.Transform

multiply_scale (value)

Scales the transform.

Name Type Description
value Vector3

The amount to scale by

rotate (x, y, z)

Performs an Euler rotation on the transform in ZYX order.

Name Type Description
x Number

X rotation in radians.

y Number

Y rotation in radians.

z Number

Z rotation in radians.

rotate_around_axis (axis, angle, in_object_space)

Rotates the transform about the given axis by the given angle in radians. If in_object_space is set to true, then the axis will be transformed into object space first.

Name Type Default Description
axis RS.Vector3

the axis to rotate around.

angle Number

the amount to rotate by in radians.

in_object_space Boolean true optional

if true then the axis is in object space, otherwise world.

rotate_around_point (point, dx, dy, dz)

Rotates the transform around a given world space point

Name Type Description
point RS.Vector3

the point to rotate around.

dx Number

the amount to rotate around the transforms X axis by in radians.

dy Number

the amount to rotate around the transforms Y axis by in radians.

dz Number

the amount to rotate around the transforms Z axis by in radians.

set_rotation (x, y, z)

Sets an Euler rotation on the transform in ZYX order.

Name Type Description
x Number

X rotation in radians.

y Number

Y rotation in radians.

z Number

Z rotation in radians.

set_rotation_around_axis (axis, angle)

Sets the rotation of the transform about the given world space axis by the given angle in radians.

Name Type Description
axis RS.Vector3

the axis to rotate around.

angle Number

the amount to rotate by in radians.

translate (dx, dy, dz, in_object_space)

Translates the transform by the given amount in either world space or object space.

Name Type Default Description
dx Number

the amount to translate in X.

dy Number

the amount to translate in Y.

dz Number

the amount to translate in Z.

in_object_space Boolean true optional

if true then translates in object space, otherwise world.