My favorites | English | Sign in

Try Google Chrome's developer tools New!

o3djs.quaternions Module Reference

List of all members.


Detailed Description

A Module for quaternion math.

Source

o3djs/quaternions.js

Public Member Functions

(!o3djs.quaternions.Quaternion|number)  add(a, b) o3djs.quaternions
!o3djs.quaternions.Quaternion  addQuaternionQuaternion(a, b) o3djs.quaternions
!o3djs.quaternions.Quaternion  addQuaternionScalar(a, b) o3djs.quaternions
!o3djs.quaternions.Quaternion  addScalarQuaternion(a, b) o3djs.quaternions
!o3djs.quaternions.Quaternion  axisRotation(axis, angle) o3djs.quaternions
!o3djs.quaternions.Quaternion  conjugate(q) o3djs.quaternions
!o3djs.quaternions.Quaternion  copy(q) o3djs.quaternions
(!o3djs.quaternions.Quaternion|number)  div(a, b) o3djs.quaternions
!o3djs.quaternions.Quaternion  divQuaternionQuaternion(a, b) o3djs.quaternions
!o3djs.quaternions.Quaternion  divQuaternionScalar(q, k) o3djs.quaternions
!o3djs.quaternions.Quaternion  divScalarQuaternion(a, b) o3djs.quaternions
!o3djs.quaternions.Quaternion  inverse(q) o3djs.quaternions
number  length(a) o3djs.quaternions
number  lengthSquared(a) o3djs.quaternions
string  mathType(a) o3djs.quaternions
(!o3djs.quaternions.Quaternion|number)  mul(a, b) o3djs.quaternions
!o3djs.quaternions.Quaternion  mulQuaternionQuaternion(a, b) o3djs.quaternions
!o3djs.quaternions.Quaternion  mulQuaternionScalar(q, k) o3djs.quaternions
!o3djs.quaternions.Quaternion  mulScalarQuaternion(k, q) o3djs.quaternions
!o3djs.quaternions.Quaternion  negative(q) o3djs.quaternions
!o3djs.quaternions.Quaternion  normalize(a) o3djs.quaternions
!o3djs.math.Matrix4  quaternionToRotation(q) o3djs.quaternions
!o3djs.quaternions.Quaternion  rotationToQuaternion(m) o3djs.quaternions
!o3djs.quaternions.Quaternion  rotationX(angle) o3djs.quaternions
!o3djs.quaternions.Quaternion  rotationY(angle) o3djs.quaternions
!o3djs.quaternions.Quaternion  rotationZ(angle) o3djs.quaternions
(!o3djs.quaternions.Quaternion|number)  sub(a, b) o3djs.quaternions
!o3djs.quaternions.Quaternion  subQuaternionQuaternion(a, b) o3djs.quaternions
!o3djs.quaternions.Quaternion  subQuaternionScalar(a, b) o3djs.quaternions
!o3djs.quaternions.Quaternion  subScalarQuaternion(a, b) o3djs.quaternions

Public Properties

<Global>  !Array.<number> Quaternion o3djs.quaternions

Member Function Documentation

(!o3djs.quaternions.Quaternion|number) o3djs.quaternions.add ( (!o3djs.quaternions.Quaternion|number) a
(!o3djs.quaternions.Quaternion|number) b )

Adds two objects which are either scalars or quaternions.

Parameters:
a Operand.
b Operand.
Returns:
(!o3djs.quaternions.Quaternion|number).The sum of a and b.
!o3djs.quaternions.Quaternion o3djs.quaternions.addQuaternionQuaternion ( !o3djs.quaternions.Quaternion a
!o3djs.quaternions.Quaternion b )

Adds two Quaternions.

Parameters:
a Operand Quaternion.
b Operand Quaternion.
Returns:
!o3djs.quaternions.Quaternion.The sum of a and b.
!o3djs.quaternions.Quaternion o3djs.quaternions.addQuaternionScalar ( !o3djs.quaternions.Quaternion a
number b )

Adds a quaternion to a scalar.

Parameters:
a Operand Quaternion.
b Operand Scalar.
Returns:
!o3djs.quaternions.Quaternion.The sum of a and b.
!o3djs.quaternions.Quaternion o3djs.quaternions.addScalarQuaternion ( number a
!o3djs.quaternions.Quaternion b )

Adds a scalar to a quaternion.

Parameters:
a Operand scalar.
b Operand quaternion.
Returns:
!o3djs.quaternions.Quaternion.The sum of a and b.
!o3djs.quaternions.Quaternion o3djs.quaternions.axisRotation ( !o3djs.math.Vector3 axis
number angle )

Creates a quaternion which rotates around the given axis by the given angle.

Parameters:
axis The axis about which to rotate.
angle The angle by which to rotate (in radians).
Returns:
!o3djs.quaternions.Quaternion.A quaternion which rotates angle radians around the axis.
!o3djs.quaternions.Quaternion o3djs.quaternions.conjugate ( !o3djs.quaternions.Quaternion q )

Computes the conjugate of the given quaternion.

Parameters:
q The quaternion.
Returns:
!o3djs.quaternions.Quaternion.The conjugate of q.

Copies a quaternion.

Parameters:
q The quaternion.
Returns:
!o3djs.quaternions.Quaternion.A new quaternion identical to q.
(!o3djs.quaternions.Quaternion|number) o3djs.quaternions.div ( (!o3djs.quaternions.Quaternion|number) a
(!o3djs.quaternions.Quaternion|number) b )

Divides two objects which are either scalars or quaternions.

Parameters:
a Operand.
b Operand.
Returns:
(!o3djs.quaternions.Quaternion|number).The quotient of a and b.
!o3djs.quaternions.Quaternion o3djs.quaternions.divQuaternionQuaternion ( !o3djs.quaternions.Quaternion a
!o3djs.quaternions.Quaternion b )

Divides two quaternions; assumes the convention that a/b = a*(1/b).

Parameters:
a Operand quaternion.
b Operand quaternion.
Returns:
!o3djs.quaternions.Quaternion.The quaternion quotient a / b.
!o3djs.quaternions.Quaternion o3djs.quaternions.divQuaternionScalar ( !o3djs.quaternions.Quaternion q
number k )

Divides a Quaternion by a scalar.

Parameters:
q The quaternion.
k The scalar.
Returns:
!o3djs.quaternions.Quaternion.q The quaternion q divided by k.
!o3djs.quaternions.Quaternion o3djs.quaternions.divScalarQuaternion ( number a
!o3djs.quaternions.Quaternion b )

Divides a scalar by a quaternion.

Parameters:
a Operand scalar.
b Operand quaternion.
Returns:
!o3djs.quaternions.Quaternion.The quaternion product.

Computes the multiplicative inverse of a quaternion.

Parameters:
q The quaternion.
Returns:
!o3djs.quaternions.Quaternion.The multiplicative inverse of q.
number o3djs.quaternions.length ( !o3djs.quaternions.Quaternion a )

Computes the length of a Quaternion, i.e. the square root of the sum of the squares of the coefficients.

Parameters:
a The Quaternion.
Returns:
number.The length of a.
number o3djs.quaternions.lengthSquared ( !o3djs.quaternions.Quaternion a )

Computes the square of the length of a quaternion, i.e. the sum of the squares of the coefficients.

Parameters:
a The quaternion.
Returns:
number.The square of the length of a.
string o3djs.quaternions.mathType ( (number|!o3djs.quaternions.Quaternion) a )

Quickly determines if the object a is a scalar or a quaternion; assumes that the argument is either a number (scalar), or an array of numbers.

Parameters:
a A number or array the type of which is in question.
Returns:
string.Either the string 'Scalar' or 'Quaternion'.
(!o3djs.quaternions.Quaternion|number) o3djs.quaternions.mul ( (!o3djs.quaternions.Quaternion|number) a
(!o3djs.quaternions.Quaternion|number) b )

Multiplies two objects which are either scalars or quaternions.

Parameters:
a Operand.
b Operand.
Returns:
(!o3djs.quaternions.Quaternion|number).The product of a and b.
!o3djs.quaternions.Quaternion o3djs.quaternions.mulQuaternionQuaternion ( !o3djs.quaternions.Quaternion a
!o3djs.quaternions.Quaternion b )

Multiplies two quaternions.

Parameters:
a Operand quaternion.
b Operand quaternion.
Returns:
!o3djs.quaternions.Quaternion.The quaternion product a * b.
!o3djs.quaternions.Quaternion o3djs.quaternions.mulQuaternionScalar ( !o3djs.quaternions.Quaternion q
number k )

Multiplies a quaternion by a scalar.

Parameters:
q The Quaternion.
k The scalar.
Returns:
!o3djs.quaternions.Quaternion.The product of k and v.
!o3djs.quaternions.Quaternion o3djs.quaternions.mulScalarQuaternion ( number k
!o3djs.quaternions.Quaternion q )

Multiplies a scalar by a quaternion.

Parameters:
k The scalar.
q The quaternion.
Returns:
!o3djs.quaternions.Quaternion.The product of k and q.
!o3djs.quaternions.Quaternion o3djs.quaternions.negative ( !o3djs.quaternions.Quaternion q )

Negates a quaternion.

Parameters:
q The quaternion.
Returns:
!o3djs.quaternions.Quaternion.-q.
!o3djs.quaternions.Quaternion o3djs.quaternions.normalize ( !o3djs.quaternions.Quaternion a )

Divides a Quaternion by its length and returns the quotient.

Parameters:
a The Quaternion.
Returns:
!o3djs.quaternions.Quaternion.A unit length quaternion pointing in the same direction as a.
!o3djs.math.Matrix4 o3djs.quaternions.quaternionToRotation ( !o3djs.quaternions.Quaternion q )

Computes a 4-by-4 rotation matrix (with trivial translation component) given a quaternion. We assume the convention that to rotate a vector v by a quaternion r means to express that vector as a quaternion q by letting q = [v[0], v[1], v[2], 0] and then obtain the rotated vector by evaluating the expression (r * q) / r.

Parameters:
q The quaternion.
Returns:
!o3djs.math.Matrix4.A 4-by-4 rotation matrix.
!o3djs.quaternions.Quaternion o3djs.quaternions.rotationToQuaternion ( (!o3djs.math.Matrix4|!o3djs.math.Matrix3) m )

Computes a quaternion whose rotation is equivalent to the given matrix.

Parameters:
m A 3-by-3 or 4-by-4 rotation matrix.
Returns:
!o3djs.quaternions.Quaternion.A quaternion q such that quaternions.quaternionToRotation(q) is m.
!o3djs.quaternions.Quaternion o3djs.quaternions.rotationX ( number angle )

Creates a quaternion which rotates around the x-axis by the given angle.

Parameters:
angle The angle by which to rotate (in radians).
Returns:
!o3djs.quaternions.Quaternion.The quaternion.
!o3djs.quaternions.Quaternion o3djs.quaternions.rotationY ( number angle )

Creates a quaternion which rotates around the y-axis by the given angle.

Parameters:
angle The angle by which to rotate (in radians).
Returns:
!o3djs.quaternions.Quaternion.The quaternion.
!o3djs.quaternions.Quaternion o3djs.quaternions.rotationZ ( number angle )

Creates a quaternion which rotates around the z-axis by the given angle.

Parameters:
angle The angle by which to rotate (in radians).
Returns:
!o3djs.quaternions.Quaternion.The quaternion.
(!o3djs.quaternions.Quaternion|number) o3djs.quaternions.sub ( (!o3djs.quaternions.Quaternion|number) a
(!o3djs.quaternions.Quaternion|number) b )

Subtracts two objects which are either scalars or quaternions.

Parameters:
a Operand.
b Operand.
Returns:
(!o3djs.quaternions.Quaternion|number).The difference of a and b.
!o3djs.quaternions.Quaternion o3djs.quaternions.subQuaternionQuaternion ( !o3djs.quaternions.Quaternion a
!o3djs.quaternions.Quaternion b )

Subtracts two quaternions.

Parameters:
a Operand quaternion.
b Operand quaternion.
Returns:
!o3djs.quaternions.Quaternion.The difference a - b.
!o3djs.quaternions.Quaternion o3djs.quaternions.subQuaternionScalar ( !o3djs.quaternions.Quaternion a
number b )

Subtracts a scalar from a quaternion.

Parameters:
a Operand quaternion.
b Operand scalar.
Returns:
!o3djs.quaternions.Quaternion.The difference a - b.
!o3djs.quaternions.Quaternion o3djs.quaternions.subScalarQuaternion ( number a
!o3djs.quaternions.Quaternion b )

Subtracts a quaternion from a scalar.

Parameters:
a Operand scalar.
b Operand quaternion.
Returns:
!o3djs.quaternions.Quaternion.The difference a - b.

Member Property Documentation

!Array.<number> o3djs.quaternions.Quaternion

A Quaternion.