Packageaway3d.core.math
Classpublic final class Quaternion
InheritanceQuaternion Inheritance Object

A Quaternion object which can be used to represent rotations.



Public Properties
 PropertyDefined By
  magnitude : Number
[read-only] Returns the magnitude of the quaternion object.
Quaternion
  w : Number = 1
The w value of the quaternion.
Quaternion
  x : Number = 0
The x value of the quaternion.
Quaternion
  y : Number = 0
The y value of the quaternion.
Quaternion
  z : Number = 0
The z value of the quaternion.
Quaternion
Public Methods
 MethodDefined By
  
Quaternion(x:Number = 0, y:Number = 0, z:Number = 0, w:Number = 1)
Creates a new Quaternion object.
Quaternion
  
Clones the quaternion.
Quaternion
  
Copies the data from a quaternion into this instance.
Quaternion
  
fromAxisAngle(axis:Vector3D, angle:Number):void
Fills the quaternion object with values representing the given rotation around a vector.
Quaternion
  
fromEulerAngles(ax:Number, ay:Number, az:Number):void
Fills the quaternion object with values representing the given euler rotation.
Quaternion
  
fromMatrix(matrix:Matrix3D):void
Extracts a quaternion rotation matrix out of a given Matrix3D object.
Quaternion
  
lerp(qa:Quaternion, qb:Quaternion, t:Number):void
Linearly interpolates between two quaternions.
Quaternion
  
Fills the quaternion object with the result from a multiplication of two quaternion objects.
Quaternion
  
multiplyVector(vector:Vector3D, target:Quaternion = null):Quaternion
Quaternion
  
normalize(val:Number = 1):void
Normalises the quaternion object.
Quaternion
  
rotatePoint(vector:Vector3D, target:Vector3D = null):Vector3D
Rotates a point.
Quaternion
  
slerp(qa:Quaternion, qb:Quaternion, t:Number):void
Spherically interpolates between two quaternions, providing an interpolation between rotations with constant angle change rate.
Quaternion
  
toEulerAngles(target:Vector3D = null):Vector3D
Fills a target Vector3D object with the Euler angles that form the rotation represented by this quaternion.
Quaternion
  
toMatrix3D(target:Matrix3D = null):Matrix3D
Converts the quaternion to a Matrix3D object representing an equivalent rotation.
Quaternion
  
toRawData(target:Vector.<Number>, exclude4thRow:Boolean = false):void
Converts the quaternion to a Vector.<Number> matrix representation of a rotation equivalent to this quaternion.
Quaternion
  
toString():String
Used to trace the values of a quaternion.
Quaternion
Property Detail
magnitudeproperty
magnitude:Number  [read-only]

Returns the magnitude of the quaternion object.


Implementation
    public function get magnitude():Number
wproperty 
public var w:Number = 1

The w value of the quaternion.

xproperty 
public var x:Number = 0

The x value of the quaternion.

yproperty 
public var y:Number = 0

The y value of the quaternion.

zproperty 
public var z:Number = 0

The z value of the quaternion.

Constructor Detail
Quaternion()Constructor
public function Quaternion(x:Number = 0, y:Number = 0, z:Number = 0, w:Number = 1)

Creates a new Quaternion object.

Parameters
x:Number (default = 0) — The x value of the quaternion.
 
y:Number (default = 0) — The y value of the quaternion.
 
z:Number (default = 0) — The z value of the quaternion.
 
w:Number (default = 1) — The w value of the quaternion.
Method Detail
clone()method
public function clone():Quaternion

Clones the quaternion.

Returns
Quaternion — An exact duplicate of the current Quaternion.
copyFrom()method 
public function copyFrom(q:Quaternion):void

Copies the data from a quaternion into this instance.

Parameters

q:Quaternion — The quaternion to copy from.

fromAxisAngle()method 
public function fromAxisAngle(axis:Vector3D, angle:Number):void

Fills the quaternion object with values representing the given rotation around a vector.

Parameters

axis:Vector3D — The axis around which to rotate
 
angle:Number — The angle in radians of the rotation.

fromEulerAngles()method 
public function fromEulerAngles(ax:Number, ay:Number, az:Number):void

Fills the quaternion object with values representing the given euler rotation.

Parameters

ax:Number — The angle in radians of the rotation around the ax axis.
 
ay:Number — The angle in radians of the rotation around the ay axis.
 
az:Number — The angle in radians of the rotation around the az axis.

fromMatrix()method 
public function fromMatrix(matrix:Matrix3D):void

Extracts a quaternion rotation matrix out of a given Matrix3D object.

Parameters

matrix:Matrix3D — The Matrix3D out of which the rotation will be extracted.

lerp()method 
public function lerp(qa:Quaternion, qb:Quaternion, t:Number):void

Linearly interpolates between two quaternions.

Parameters

qa:Quaternion — The first quaternion to interpolate.
 
qb:Quaternion — The second quaternion to interpolate.
 
t:Number — The interpolation weight, a value between 0 and 1.

multiply()method 
public function multiply(qa:Quaternion, qb:Quaternion):void

Fills the quaternion object with the result from a multiplication of two quaternion objects.

Parameters

qa:Quaternion — The first quaternion in the multiplication.
 
qb:Quaternion — The second quaternion in the multiplication.

multiplyVector()method 
public function multiplyVector(vector:Vector3D, target:Quaternion = null):Quaternion

Parameters

vector:Vector3D
 
target:Quaternion (default = null)

Returns
Quaternion
normalize()method 
public function normalize(val:Number = 1):void

Normalises the quaternion object.

Parameters

val:Number (default = 1)

rotatePoint()method 
public function rotatePoint(vector:Vector3D, target:Vector3D = null):Vector3D

Rotates a point.

Parameters

vector:Vector3D — The Vector3D object to be rotated.
 
target:Vector3D (default = null) — An optional Vector3D object that will contain the rotated coordinates. If not provided, a new object will be created.

Returns
Vector3D — A Vector3D object containing the rotated point.
slerp()method 
public function slerp(qa:Quaternion, qb:Quaternion, t:Number):void

Spherically interpolates between two quaternions, providing an interpolation between rotations with constant angle change rate.

Parameters

qa:Quaternion — The first quaternion to interpolate.
 
qb:Quaternion — The second quaternion to interpolate.
 
t:Number — The interpolation weight, a value between 0 and 1.

toEulerAngles()method 
public function toEulerAngles(target:Vector3D = null):Vector3D

Fills a target Vector3D object with the Euler angles that form the rotation represented by this quaternion.

Parameters

target:Vector3D (default = null) — An optional Vector3D object to contain the Euler angles. If not provided, a new object is created.

Returns
Vector3D — The Vector3D containing the Euler angles.
toMatrix3D()method 
public function toMatrix3D(target:Matrix3D = null):Matrix3D

Converts the quaternion to a Matrix3D object representing an equivalent rotation.

Parameters

target:Matrix3D (default = null) — An optional Matrix3D container to store the transformation in. If not provided, a new object is created.

Returns
Matrix3D — A Matrix3D object representing an equivalent rotation.
toRawData()method 
public function toRawData(target:Vector.<Number>, exclude4thRow:Boolean = false):void

Converts the quaternion to a Vector.<Number> matrix representation of a rotation equivalent to this quaternion.

Parameters

target:Vector.<Number> — The Vector.<Number> to contain the raw matrix data.
 
exclude4thRow:Boolean (default = false) — If true, the last row will be omitted, and a 4x3 matrix will be generated instead of a 4x4.

toString()method 
public function toString():String

Used to trace the values of a quaternion.

Returns
String — A string representation of the quaternion object.