Skip to content

Rotation

Rotation represented as a quaternion

Can be created from euler angles or quaternion components. Use Rotation.slerp() for smooth interpolation between rotations.

Example:

javascript
// From euler angles (radians)
var rot = Rotation(0, Math.PI / 2, 0); // 90° around Y

// From quaternion
var rot = Rotation.quaternion(0, 0.707, 0, 0.707);

// Interpolate between rotations
var mid = Rotation.slerp(rotA, rotB, 0.5);

Properties

eulerAngles

  • Type: Vector3
  • Euler angles in radians (x, y, z)

quaternion

  • Type: Vector4
  • Quaternion components (x, y, z, w)

Methods

create()

javascript
create(): Rotation

Create identity rotation (no rotation)

Returns: Rotation

inverse()

javascript
inverse(r: Rotation): Rotation

Get the inverse (conjugate) of a rotation

Parameters:

Returns: Rotation

inverse()

javascript
inverse(): Rotation

Get the inverse of this rotation

Returns: Rotation

multiply()

javascript
multiply(r1: Rotation, r2: Rotation): Rotation

Multiply two rotations (compose)

Parameters:

  • r1 (Rotation) - First rotation
  • r2 (Rotation) - Second rotation (applied after r1)

Returns: Rotation

multiply()

javascript
multiply(other: Rotation): Rotation

Multiply (compose) with another rotation

Parameters:

  • other (Rotation) - Rotation to apply after this one

Returns: Rotation

slerp()

javascript
slerp(r1: Rotation, r2: Rotation, t: number): Rotation

Spherically interpolate between two rotations

Parameters:

  • r1 (Rotation) - Start rotation
  • r2 (Rotation) - End rotation
  • t (number) - Interpolation factor (0-1)

Returns: Rotation

slerp()

javascript
slerp(other: Rotation, t: number): Rotation

Spherically interpolate to another rotation

Parameters:

  • other (Rotation) - Target rotation
  • t (number) - Interpolation factor (0-1)

Returns: Rotation