Class: Transform_target

RS~Transform_target

The Transform_target class adds look at funcitonality to the RS.Transform class.

new Transform_target ()

The default constructor initializes with an identity matrix looking at the point 0, 0, -1.

Members

follow_target_point Boolean

Whether the target point should be followed. If true then the transform will be locked to looking at the target point. If not then operations will still occur relative to the target point however the transform diretion will remain the same.

Default Value:
  • true

target_point RS.Vector3

The target point

up_direction RS.Vector3

The nominal up direction. When performing look at operations the transform will attempt to keep it's Y axis aligned with this direction. When set the transform will re-orient itself to the new up.

Default Value:
  • {x: 0, y: 1, z: 0}

Methods

returns a copy of this Transform_target.

Returns:
Type Description
RS.Transform_target

orbit_around_target_point (dx, dy, dz)

Orbits around the target point by the given amount.

Name Type Description
dx Number

the X rotation in radians.

dy Number

the Y rotation in radians.

dz Number

the Z rotation in radians.

rotate (dx, dy, dz, rotate_target_point)

Performs an Euler rotation on the transform in ZYX order. If rotate_target_point is set to true (or if follow_target_point is false) then the target point will be rotated around the translation vector.

If rotate_target_point is false, and we are following the target point then this will only apply the dz rotation as we must keep looking at the target point.

Name Type Default Description
dx Number

X rotation in radians.

dy Number

Y rotation in radians.

dz Number

Z rotation in radians.

rotate_target_point Boolean true optional

if true then the target point is rotated by the same amount.

rotate_around_axis (axis, angle, in_object_space, rotate_target_point)

Rotates the transform about the given axis by the given angle in radians. If in_object_space is true, then the axis will be transform into object space first. If rotate_target_point is true then the target point is also rotated.

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_target_point Boolean true optional

if true then the target point is rotated by the same amount. Otherwise we keep looking at the current target point.

rotate_around_point (point, dx, dy, dz, rotate_target_point)

Performs a ZYX Euter rotation around a given world space point. If `rotate_target_point`` is true and the target point is not at the same location as the given point, then the target point is also rotated around the point.

Name Type Default Description
point RS.Vector3

the point to rotate around.

dx Number

the X rotation in radians.

dy Number

the Y rotation in radians.

dz Number

the Z rotation in radians.

rotate_target_point Boolean true optional

if true then the target point is rotated by the same amount. Otherwise we keep looking at the current target point.

set_rotation (x, y, z, rotate_target_point)

This sets the rotation of the transform. If rotate_target_point is `true`` then the target point will be rotated around the translation vector.

If rotate_target_point is false, and we are following the target point then this will only apply the z rotation as we must keep looking at the target point.

Name Type Default Description
x Number

X rotation in radians.

y Number

Y rotation in radians.

z Number

Z rotation in radians.

rotate_target_point Boolean true optional

if true then the target point is rotated by the same amount. Otherwise we keep looking at the current target point

set_rotation_around_axis (axis, angle, rotate_target_point)

Sets the rotation of the transform about the given axis by the given angle in radians. If rotate_target_point is set to true then the target point is also rotated.

Name Type Default Description
axis RS.Vector3

the axis to rotate around.

angle Number

the amount to rotate by in radians.

rotate_target_point Boolean true optional

if true then the target point is rotated by the same amount. Otherwise we keep looking at the current target point.

set_target_point (target_point, reset_y_vector)

Sets the target point. Target point CANNOT be the same as the translation vector.

Name Type Default Description
target_point RS.Vector3

the target point.

reset_y_vector Boolean true optional

if true and we are following the target point then the transform will reset to be oriented up. Otherwise the current roll will be preserved.

set_translation (x, y, z, translate_target)

Sets the translation in world space. Resulting translation CANNOT be the same as the target point.

Name Type Default Description
x Number

the X translation.

y Number

the Y translation.

z Number

the Z translation.

translate_target Boolean true optional

if true then the target point is moved to be at the same relative location as previously. Otherwise the transform will look at the old target point after translation.

translate (dx, dy, dz, in_object_space, translate_target)

Translates the transform either world space or object space. Resulting target point CANNOT be the same as translation vector.

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.

translate_target Boolean true optional

if true then the target point is translated by the same amount. Otherwise the transform will look at the old target point after translation.

translate_target_point (dx, dy, dz, in_object_space)

Translates the target point in either world space or object space. Resulting target point CANNOT be the same as translation vector.

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.