Interface: quaternion

syngen.utility.quaternion

Provides an interface for quaternions. They express 3D orientations in space with complex numbers. These are preferred over euler angles to avoid gimbal lock.

Source:
See:

Members

w :Number

The real w-component of the quaternion. Implementations are discouraged from modifying this directly.

Type:
  • Number
Source:

x :Number

The imaginary x-component of the quaternion. Implementations are discouraged from modifying this directly.

Type:
  • Number
Source:

y :Number

The imaginary y-component of the quaternion. Implementations are discouraged from modifying this directly.

Type:
  • Number
Source:

z :Number

The imaginary z-component of the quaternion. Implementations are discouraged from modifying this directly.

Type:
  • Number
Source:

Methods

(static) create(optionsopt) → {syngen.utility.quaternion}

Instantiates a new quaternion.

Parameters:
Name Type Attributes Default Description
options syngen.utility.quaternion | Object <optional>
{}
Properties
Name Type Attributes Default Description
w Number <optional>
1
x Number <optional>
0
y Number <optional>
0
z Number <optional>
0
Source:
Returns:
Type
syngen.utility.quaternion

(static) fromEuler(euler, sequenceopt) → {syngen.utility.quaternion}

Converts an Euler angle to a quaternion.

Parameters:
Name Type Attributes Default Description
euler syngen.utility.euler
sequence String <optional>
syngen.const.eulerToQuaternion
Source:
See:
Returns:
Type
syngen.utility.quaternion

(static) identity() → {syngen.utility.quaternion}

Instantiates an identity quaternion.

Source:
Returns:
Type
syngen.utility.quaternion

clone() → {syngen.utility.quaternion}

Returns a new instance with the same properties.

Source:
Returns:
Type
syngen.utility.quaternion

conjugate() → {syngen.utility.quaternion}

Returns the conjugate as a new instance. This represents the reverse orientation.

Source:
Returns:
Type
syngen.utility.quaternion

distance() → {Number}

Calculates the magnitude (Euclidean distance).

Source:
Returns:
Type
Number

distance2() → {Number}

Calculates the norm (squared Euclidean distance).

Source:
Returns:
Type
Number

divide(quaternionopt) → {syngen.utility.quaternion}

Multiplies this by the inverse of quaternion to return their difference as a new instance.

Parameters:
Name Type Attributes Description
quaternion syngen.utility.quaternion | Object <optional>
Source:
Returns:
Type
syngen.utility.quaternion

equals(quaternionopt) → {Boolean}

Returns whether this is equal to quaternion.

Parameters:
Name Type Attributes Description
quaternion syngen.utility.quaternion | Object <optional>
Source:
Returns:
Type
Boolean

forward() → {syngen.utility.vector3d}

Returns the unit vector that's ahead of the orientation. The vector can be inverted to receive a vector behind.

Source:
Returns:
Type
syngen.utility.vector3d

inverse() → {syngen.utility.quaternion}

Returns the multiplicative inverse as a new instance.

Source:
Returns:
Type
syngen.utility.quaternion

isZero() → {Boolean}

Returns whether this is equal to the identity quaternion.

Source:
Returns:
Type
Boolean

lerpFrom(quaternion) → {syngen.utility.quaternion}

Linearly interpolates quaternion to this and returns it as a new instance.

Parameters:
Name Type Description
quaternion syngen.utility.quaternion | Object
Source:
To Do:
  • Create syngen.utility.quaternion.slerpFrom for spherical interpolation
Returns:
Type
syngen.utility.quaternion

lerpTo(quaternion) → {syngen.utility.quaternion}

Linearly interpolates this to quaternion and returns it as a new instance.

Parameters:
Name Type Description
quaternion syngen.utility.quaternion | Object
Source:
To Do:
  • Create syngen.utility.quaternion.slerpTo for spherical interpolation
Returns:
Type
syngen.utility.quaternion

multiply(quaternionopt) → {syngen.utility.quaternion}

Multiplies this by quaternion to return their sum as a new instance.

Parameters:
Name Type Attributes Description
quaternion syngen.utility.quaternion | Object <optional>
Source:
Returns:
Type
syngen.utility.quaternion

normalize() → {syngen.utility.quaternion}

Normalizes this and returns it as a new instance.

Source:
Returns:
Type
syngen.utility.quaternion

Returns the unit vector that's to the right of the orientation. The vector can be inverted to receive a vector to its left.

Source:
Returns:
Type
syngen.utility.vector3d

set(optionsopt)

Sets all properties with options. These values are best derived from syngen.utility.quaternion.fromEuler or other quaternions.

Parameters:
Name Type Attributes Description
options syngen.utility.quaternion | Object <optional>
Properties
Name Type Attributes Default Description
w Number <optional>
1
x Number <optional>
0
y Number <optional>
0
z Number <optional>
0
Source:

up() → {syngen.utility.vector3d}

Returns the unit vector that's above of the orientation. The vector can be inverted to receive a vector below.

Source:
Returns:
Type
syngen.utility.vector3d