Packageorg.flintparticles.threeD.geom
Classpublic class Quaternion
InheritanceQuaternion Inheritance Object

Quaternion represents a rotational transform in three-dimensional cartesian coordinate space in quaternion form.



Public Properties
 PropertyDefined By
  IDENTITY : Quaternion
[static] [read-only] An identity quaternion.
Quaternion
  magnitude : Number
[read-only] The magnitude of this quaternion.
Quaternion
  magnitudeSquared : Number
[read-only] The square of the magnitude of this quaternion.
Quaternion
  w : Number
The w coordinate of the quaternion.
Quaternion
  x : Number
The x coordinate of the quaternion.
Quaternion
  y : Number
The y coordinate of the quaternion.
Quaternion
  z : Number
The z coordinate of the quaternion.
Quaternion
  ZERO : Quaternion
[static] [read-only] A zero quaternion.
Quaternion
Public Methods
 MethodDefined By
  
Quaternion(w:Number = 1, x:Number = 0, y:Number = 0, z:Number = 0)
Constructor
Quaternion
  
Adds another quaternion to this one, returning a new quaternion.
Quaternion
  
Copies another quaternion into this one.
Quaternion
  
Makes a copy of this Quaternion object.
Quaternion
  
The conjugate of this quaternion.
Quaternion
  
Subtract another quaternion from this one.
Quaternion
  
Calculate the dot product of this quaternion with another.
Quaternion
  
equals(q:Quaternion):Boolean
Compare this quaternion to another.
Quaternion
  
Add another quaternion to this one.
Quaternion
  
The inverse of this quaternion.
Quaternion
  
Set this quaternion to its inverse.
Quaternion
  
nearEquals(q:Quaternion, e:Number):Boolean
Compare this quaternion to another.
Quaternion
  
newFromAxisRotation(axis:Vector3D, angle:Number):Quaternion
[static] Create a new unit quaternion that represents a rotation about an axis in 3D space.
Quaternion
  
Convert this quaternion to have magnitude 1.
Quaternion
  
Post multiply this quaternion by another quaternion, returning a new quaternion.
Quaternion
  
Post multiply this quaternion by another quaternion
Quaternion
  
Pre multiply this quaternion by another quaternion, returning a new quaternion.
Quaternion
  
Pre multiply this quaternion by another quaternion
Quaternion
  
reset(w:Number = 0, x:Number = 0, y:Number = 0, z:Number = 0):Quaternion
Assigns new coordinates to this quaternion
Quaternion
  
scalarMultiply(s:Number, result:Quaternion = null):Quaternion
Multiply this quaternion by a number.
Quaternion
  
Multiply this quaternion by a number.
Quaternion
  
Set this quaternion equal to its conjugate.
Quaternion
  
setFromAxisRotation(axis:Vector3D, angle:Number):Quaternion
Set this quaternion to a unit quaternion that represents a rotation about an axis in 3D space.
Quaternion
  
Subtract another quaternion from this one, returning a new quaternion.
Quaternion
  
toAxisRotation():Vector3D
Convert this quaternion to an axis/angle rotation, returning the result in a Vector3D where x, y, z represent the axis and w represents the angle, in radians.
Quaternion
  
Convert this quaternion to a matrix transformation.
Quaternion
  
toString():String
Get a string representation of this quaternion
Quaternion
  
unit(result:Quaternion = null):Quaternion
Create a unit quaternion in the same direction as this one.
Quaternion
Property Detail
IDENTITYproperty
IDENTITY:Quaternion  [read-only]

An identity quaternion.


Implementation
    public static function get IDENTITY():Quaternion
magnitudeproperty 
magnitude:Number  [read-only]

The magnitude of this quaternion.


Implementation
    public function get magnitude():Number
magnitudeSquaredproperty 
magnitudeSquared:Number  [read-only]

The square of the magnitude of this quaternion.


Implementation
    public function get magnitudeSquared():Number
wproperty 
public var w:Number

The w coordinate of the quaternion.

xproperty 
public var x:Number

The x coordinate of the quaternion.

yproperty 
public var y:Number

The y coordinate of the quaternion.

zproperty 
public var z:Number

The z coordinate of the quaternion.

ZEROproperty 
ZERO:Quaternion  [read-only]

A zero quaternion.


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

Constructor

Parameters
w:Number (default = 1) — the x coordinate of the quaternion
 
x:Number (default = 0) — the y coordinate of the quaternion
 
y:Number (default = 0) — the z coordinate of the quaternion
 
z:Number (default = 0) — the w coordinate of the quaternion
Method Detail
add()method
public function add(q:Quaternion, result:Quaternion = null):Quaternion

Adds another quaternion to this one, returning a new quaternion.

Parameters

q:Quaternion — the quaternion to add
 
result:Quaternion (default = null) — The quaternion to hold the result of the addition. If no quaternion is passed, a new quaternion is created.

Returns
Quaternion — the result of the addition
assign()method 
public function assign(q:Quaternion):Quaternion

Copies another quaternion into this one.

Parameters

q:Quaternion — The quaternion to copy

Returns
Quaternion — a reference to this Quaternion object
clone()method 
public function clone():Quaternion

Makes a copy of this Quaternion object.

Returns
Quaternion — A copy of this Quaternion
conjugate()method 
public function conjugate(result:Quaternion = null):Quaternion

The conjugate of this quaternion.

Parameters

result:Quaternion (default = null) — The quaternion to hold the result of the conjugate. If no quaternion is passed, a new quaternion is created.

Returns
Quaternion — The result of the conjugate
decrementBy()method 
public function decrementBy(q:Quaternion):Quaternion

Subtract another quaternion from this one.

Parameters

q:Quaternion — The quaternion to subtract

Returns
Quaternion — A reference to this Quaternion object.
dotProduct()method 
public function dotProduct(q:Quaternion):Number

Calculate the dot product of this quaternion with another.

Parameters

q:Quaternion — The quaternion to calculate the dot product with

Returns
Number — The dot product of the two quaternions
equals()method 
public function equals(q:Quaternion):Boolean

Compare this quaternion to another.

Parameters

q:Quaternion — The quaternion to compare with.

Returns
Boolean — true if the quaternions have the same coordinates, false otherwise.
incrementBy()method 
public function incrementBy(q:Quaternion):Quaternion

Add another quaternion to this one.

Parameters

q:Quaternion — The quaternion to add

Returns
Quaternion — A reference to this Quaternion object.
inverse()method 
public function inverse(result:Quaternion = null):Quaternion

The inverse of this quaternion.

Parameters

result:Quaternion (default = null) — The quaternion to hold the result of the inverse. If no quaternion is passed, a new quaternion is created.

Returns
Quaternion — The result of the inverse
invert()method 
public function invert():Quaternion

Set this quaternion to its inverse.

Returns
Quaternion — A reference to this quaternion.
nearEquals()method 
public function nearEquals(q:Quaternion, e:Number):Boolean

Compare this quaternion to another.

Parameters

q:Quaternion — The quaternion to compare with.
 
e:Number — The distance allowed between the coordinates of the two quaternions.

Returns
Boolean — true if the quaternions are within distance e of each other, false otherwise
newFromAxisRotation()method 
public static function newFromAxisRotation(axis:Vector3D, angle:Number):Quaternion

Create a new unit quaternion that represents a rotation about an axis in 3D space.

Parameters

axis:Vector3D — The axis of the rotation.
 
angle:Number (default = NaN) — The angle, in radians, of the rotation. If no value is set, the w coordinate of the axis Vector3D is used.

Returns
Quaternion — A Quaternion representing the rotation.
normalize()method 
public function normalize():Quaternion

Convert this quaternion to have magnitude 1.

Returns
Quaternion — A reference to this quaternion.
postMultiply()method 
public function postMultiply(q:Quaternion, result:Quaternion = null):Quaternion

Post multiply this quaternion by another quaternion, returning a new quaternion.

Parameters

q:Quaternion — The quaternion to multiply by.
 
result:Quaternion (default = null) — The quaternion to hold the result of the multiplication. If no quaternion is passed, a new quaternion is created.

Returns
Quaternion — The result of the multiplication.
postMultiplyBy()method 
public function postMultiplyBy(q:Quaternion):Quaternion

Post multiply this quaternion by another quaternion

Parameters

q:Quaternion — The quaternion to multiply by

Returns
Quaternion — A reference to this Quaternion object.
preMultiply()method 
public function preMultiply(q:Quaternion, result:Quaternion = null):Quaternion

Pre multiply this quaternion by another quaternion, returning a new quaternion.

Parameters

q:Quaternion — The quaternion to multiply by.
 
result:Quaternion (default = null) — The quaternion to hold the result of the multiplication. If no quaternion is passed, a new quaternion is created.

Returns
Quaternion — The result of the multiplication.
preMultiplyBy()method 
public function preMultiplyBy(q:Quaternion):Quaternion

Pre multiply this quaternion by another quaternion

Parameters

q:Quaternion — The quaternion to multiply by

Returns
Quaternion — A reference to this Quaternion object.
reset()method 
public function reset(w:Number = 0, x:Number = 0, y:Number = 0, z:Number = 0):Quaternion

Assigns new coordinates to this quaternion

Parameters

w:Number (default = 0) — The new x coordinate
 
x:Number (default = 0) — The new y coordinate
 
y:Number (default = 0) — The new z coordinate
 
z:Number (default = 0) — The new w coordinate

Returns
Quaternion — a reference to this Quaternion object
scalarMultiply()method 
public function scalarMultiply(s:Number, result:Quaternion = null):Quaternion

Multiply this quaternion by a number.

Parameters

s:Number — The number to multiply the quaternion by
 
result:Quaternion (default = null) — The quaternion to hold the result of the multiplication. If no quaternion is passed, a new quaternion is created.

Returns
Quaternion — The result of the multiplication
scaleBy()method 
public function scaleBy(s:Number):Quaternion

Multiply this quaternion by a number.

Parameters

s:Number — The number to multiply by

Returns
Quaternion — A reference to this Quaternion object.
selfConjugate()method 
public function selfConjugate():Quaternion

Set this quaternion equal to its conjugate.

Returns
Quaternion — A reference to this quaternion.
setFromAxisRotation()method 
public function setFromAxisRotation(axis:Vector3D, angle:Number):Quaternion

Set this quaternion to a unit quaternion that represents a rotation about an axis in 3D space.

Parameters

axis:Vector3D — The axis of the rotation.
 
angle:Number (default = NaN) — The angle, in radians, of the rotation. If no value is set, the w coordinate of the axis Vector3D is used.

Returns
Quaternion — A reference to this Quaternion.
subtract()method 
public function subtract(q:Quaternion, result:Quaternion = null):Quaternion

Subtract another quaternion from this one, returning a new quaternion.

Parameters

q:Quaternion — The quaternion to subtract
 
result:Quaternion (default = null) — The quaternion to hold the result of the subtraction. If no quaternion is passed, a new quaternion is created.

Returns
Quaternion — The result of the subtraction
toAxisRotation()method 
public function toAxisRotation():Vector3D

Convert this quaternion to an axis/angle rotation, returning the result in a Vector3D where x, y, z represent the axis and w represents the angle, in radians.

Returns
Vector3D — The axis/angle rotation.
toMatrixTransformation()method 
public function toMatrixTransformation():Matrix3D

Convert this quaternion to a matrix transformation.

Returns
Matrix3D — The matrix transformation.
toString()method 
public function toString():String

Get a string representation of this quaternion

Returns
String — a string representation of this quaternion
unit()method 
public function unit(result:Quaternion = null):Quaternion

Create a unit quaternion in the same direction as this one.

Parameters

result:Quaternion (default = null) — The quaternion to hold the result. If no quaternion is passed, a new quaternion is created.

Returns
Quaternion — The unit quaternion in the same direction as this one.