Provides an interface for quaternions. They express 3D orientations in space with complex numbers. These are preferred over euler angles to avoid gimbal lock.
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
|
- Source:
Returns:
(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
|
Returns:
(static) identity() → {syngen.utility.quaternion}
Instantiates an identity quaternion.
- Source:
Returns:
clone() → {syngen.utility.quaternion}
Returns a new instance with the same properties.
- Source:
Returns:
conjugate() → {syngen.utility.quaternion}
Returns the conjugate as a new instance. This represents the reverse orientation.
- Source:
Returns:
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:
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:
inverse() → {syngen.utility.quaternion}
Returns the multiplicative inverse as a new instance.
- Source:
Returns:
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:
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:
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:
normalize() → {syngen.utility.quaternion}
Normalizes this and returns it as a new instance.
- Source:
Returns:
right() → {syngen.utility.vector3d}
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:
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
|
- 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: