A Quaternion object which can be used to represent rotations.
Constructor
new(x:Float = 0, y:Float = 0, z:Float = 0, w:Float = 1)
Creates a new Quaternion object.
Parameters:
x | The x value of the quaternion. |
|---|---|
y | The y value of the quaternion. |
z | The z value of the quaternion. |
w | The w value of the quaternion. |
Variables
Methods
copyFrom(q:Quaternion):Void
Copies the data from a quaternion into this instance.
Parameters:
q | The quaternion to copy from. |
|---|
fromAxisAngle(axis:Vector3D, angle:Float):Void
Fills the quaternion object with values representing the given rotation around a vector.
Parameters:
axis | The axis around which to rotate |
|---|---|
angle | The angle in radians of the rotation. |
fromEulerAngles(ax:Float, ay:Float, az:Float):Void
Fills the quaternion object with values representing the given euler rotation.
Parameters:
ax | The angle in radians of the rotation around the ax axis. |
|---|---|
ay | The angle in radians of the rotation around the ay axis. |
az | The angle in radians of the rotation around the az axis. |
fromMatrix(matrix:Matrix3D):Void
Extracts a quaternion rotation matrix out of a given Matrix3D object.
Parameters:
matrix | The Matrix3D out of which the rotation will be extracted. |
|---|
lerp(qa:Quaternion, qb:Quaternion, t:Float):Void
Linearly interpolates between two quaternions.
Parameters:
qa | The first quaternion to interpolate. |
|---|---|
qb | The second quaternion to interpolate. |
t | The interpolation weight, a value between 0 and 1. |
multiply(qa:Quaternion, qb:Quaternion):Void
Fills the quaternion object with the result from a multiplication of two quaternion objects.
Parameters:
qa | The first quaternion in the multiplication. |
|---|---|
qb | The second quaternion in the multiplication. |
rotatePoint(vector:Vector3D, ?target:Vector3D):Vector3D
Rotates a point.
Parameters:
vector | The Vector3D object to be rotated. |
|---|---|
target | An optional Vector3D object that will contain the rotated coordinates. If not provided, a new object will be created. |
Returns:
A Vector3D object containing the rotated point.
slerp(qa:Quaternion, qb:Quaternion, t:Float):Void
Spherically interpolates between two quaternions, providing an interpolation between rotations with constant angle change rate.
Parameters:
qa | The first quaternion to interpolate. |
|---|---|
qb | The second quaternion to interpolate. |
t | The interpolation weight, a value between 0 and 1. |
toEulerAngles(?target:Vector3D):Vector3D
Fills a target Vector3D object with the Euler angles that form the rotation represented by this quaternion.
Parameters:
target | An optional Vector3D object to contain the Euler angles. If not provided, a new object is created. |
|---|
Returns:
The Vector3D containing the Euler angles.
toMatrix3D(?target:Matrix3D):Matrix3D
Converts the quaternion to a Matrix3D object representing an equivalent rotation.
Parameters:
target | An optional Matrix3D container to store the transformation in. If not provided, a new object is created. |
|---|
Returns:
A Matrix3D object representing an equivalent rotation.
toRawData(target:Vector<Float>, exclude4thRow:Bool = false):Void
Converts the quaternion to a Vector.<Number> matrix representation of a rotation equivalent to this quaternion.
Parameters:
target | The Vector.<Number> to contain the raw matrix data. |
|---|---|
exclude4thRow | If true, the last row will be omitted, and a 4x3 matrix will be generated instead of a 4x4. |
toString():String
Used to trace the values of a quaternion.
Returns:
A string representation of the quaternion object.