Class: Euler

RS.Euler

The Euler class reprents euler rotations and supports conversion to/from matrices and Quaternion rotation representations.

RealityServer uses intrinsic Tait-Bryan angles. This means that rotations are performed with respect to the local coordinate system. That is, for order 'XYZ', the rotation is first around the local-X axis (which is the same as the world-X axis), then around local-Y (which may now be different from the world Y-axis), then local-Z (which may be different from the world Z-axis).

new RS.Euler (initial, order)

Creates a new Euler. Accepts any arguments that RS.Euler#set accepts.

Name Type Description
initial RS.Euler | RS.Quaternion | RS.Math.Matrix4x4 | Array | Object | Number optional

initial value.

order String optional

order to apply rotations in

Members

RS.Euler.default_order String static

The default euler order.

RS.Euler.rotation_orders Array static

Array of supported euler orders.

order String

The rotation order of the euler.

x Number

The x component of the euler in radians.

y Number

The y component of the euler in radians.

z Number

The z component of the euler in radians.

Methods

clone ()RS.Euler

Returns a copy of this euler.

Returns:
Type Description
RS.Euler

equal (rhs, tolerance)Boolean

Returns whether this euler is equal to another euler within an optional tolerance.

Name Type Description
rhs RS.Euler

the euler to compare to.

tolerance Number optional

if provided then this level of tolerance is used, otherwise uses an exact match.

Returns:
Type Description
Boolean true if equal, false if not.

equal_with_tolerance (rhs, tolerance)Boolean

Returns whether this euler is equal to another euler within a tolerance.

Name Type Description
rhs RS.Euler

the euler to compare to.

tolerance Number optional

if provided then this level of tolerance is used, otherwise tolerance is 10e-5.

Returns:
Type Description
Boolean true if equal, false if not.

reorder (new_order)Euler

Change the ordering of this euler to new_order.

Name Type Description
new_order String

the new order.

Returns:
Type Description
Euler this

set (source, order)Euler

Sets this euler. The source may be of the following types:

  • RS.Euler
  • RS.Quaternion
  • RS.Math.Matrix4x4
  • an Array with 4 or more members
  • an Object.
  • 3 individual arguments for x, y and z

In the case of an object being supplied it should have the members x, y, z. Parsing failures on x, y or z will set them to 0.

If the source is RS.Math.Matrix4x4 then it is expected to have no scaling factors. The matrix is expected to be a forward transformation, IE: an object to world space matrix.

Rotation values are in radians.

If the source is not RS.Euler then the final parameter can be a string specifying the order that should be used.

Name Type Description
source RS.Euler | RS.Quaternion | RS.Math.Matrix4x4 | Array | Object | Number

the object to set from or a set of numbers. When a number represents a rotation it is in radians.

order String optional

the order in which to apply the extracted rotations, overrides the current value if given.

Returns:
Type Description
Euler this
Example
const v = new RS.Euler();
v.set(0,Math.PI/2,0,'XYZ');
v.set([0,Math.PI/2,Math.PI/2]);
v.set({x: 0, y: Math.PI, z: 0});

to_matrix ()RS.Math.Matrix4x4

Returns a matrix representing this euler rotation. This will be a forward transformation, IE: an object to world space matrix. The matrix can be passed to RS.Math.Vector3.rotate to rotate a vector by this Euler.

Returns:
Type Description
RS.Math.Matrix4x4 the matrix.

to_quaternion ()RS.Quaternion

Returns a quaternion representing this euler rotation.

Returns:
Type Description
RS.Quaternion the quaterion.