Skip to main content

Euler

From v1.0

class Euler extends MathArray extends Array

A class to handle Euler rotation. More information on rotation using a Euler vector can be found here. Generally speaking the three components of the Euler object represents the roll, pitch and yaw angles and the rotation is applied according to a specific rotation order.

Usageโ€‹

import {Euler} from '@math.gl/core/matrix';

Rotation order is represented by the EulerRotationOrder type. Its valid values are 'xyz', 'xzy', 'yxz', 'yzx', 'zxy', and 'zyx'. The default is 'zyx'.

Membersโ€‹

x, y zโ€‹

x, y, z angle notation (note: only corresponds to axis in XYZ orientation)

roll, pitch, yawโ€‹

roll, pitch, yaw angle notation

alpha, beta, gammaโ€‹

alpha, beta, gamma angle notation

phi, theta, psiโ€‹

phi, theta, psi angle notation

orderโ€‹

The axis order used to interpret the three angles. Assigning a new order preserves the angle values.

Methodsโ€‹

constructorโ€‹

(x = 0, y = 0, z = 0, order = 'zyx')

  • Number|Number[], Number, Number, EulerRotationOrder

fromRollPitchYawโ€‹

Common ZYX rotation order

euler.fromRollPitchYaw(roll, pitch, yaw)

fromRotationMatrixโ€‹

euler.fromRotationMatrix(m, order = euler.order)

fromQuaternionโ€‹

euler.fromQuaternion(q, order = euler.order)

Sets this Euler instance from q using the requested rotation order. All six rotation orders are supported.

copyโ€‹

euler.copy(array)

Copies the first three angles from a numeric array. A supported order index in the fourth slot sets the rotation order. A three-element array preserves the current order.

setโ€‹

Sets the three angles, and optionally sets the rotation order. If order is not specified, preserves currently set order.

euler.set(x = 0, y = 0, z = 0, order)

toArrayโ€‹

Does not copy the orientation element

euler.toArray(array = [], offset = 0)

toArray4โ€‹

euler.toArray4(array = [], offset = 0)

Writes the angles and numeric order index starting at offset. The order indices from 0 through 5 are 'zyx', 'yxz', 'xzy', 'zxy', 'yzx', and 'xyz'. Pass the returned four-element array to copy() to restore the angles and order.

toVector3โ€‹

euler.toVector3(optionalResult)

fromVector3โ€‹

euler.fromVector3(v, order)

fromArrayโ€‹

euler.fromArray(array, offset = 0)

getRotationMatrixโ€‹

euler.getRotationMatrix(result = number[16])

Returns result, updated with the 4x4 rotation matrix corresponding to these Euler angles. A plain array is created when result is omitted.

To create a quaternion from Euler angles, use the destination-owned conversion:

new Quaternion().fromEuler(euler)

Remarksโ€‹

  • Attribution: inspired by THREE.js THREE.Euler class