Class: Quaternion

SQR.Quaternion()

new Quaternion()

Represents a quaternion with optionally setting the values directly.

Just as a reminder, given an angle `a` and an axis `x,y,z` this is what the quaternion values are:

Source:
Example
``````var q = new SQR.Quaternion();
var s = Math.sin(a / 2);
q.x = x * s;
q.y = y * s;
q.z = z * s;
q.w = Math.cos(a / 2);``````

Methods

(static) slerp(qa, qb, t, qr)

Returns a spherical linear interpolation between two quaternions.

Parameters:
Name Type Description
`qa`

first quaternion

`qb`

second quaternion

`t`

interpolation value [0-1]

`qr`

the quaterion to store the results in and return. If omitted results are returned in a new quaternion object.

Source:

copyFrom(q)

Copy the values from another quaternion.

Parameters:
Name Type Description
`q`

the quaternion to copy values from

Source:

fromAngleAxis(a, x, y, z)

Creates a quaternion out of an angle axis representation.

Parameters:
Name Type Description
`a`

`x`

x component of the axis

`y`

y component of the axis

`z`

z component of the axis

Source:

identity()

Resets the quaternion values to identity.

Source:

inverse()

Inverses the quaternion.

Source:

lookAt(_dir, _up)

Sets the quaternion to point in the given direction.

Parameters:
Name Type Description
`_dir`

the direction to look at

`_up`

the up vector

Source:

mag()

Returns the magniture of the quaternion.

Source:

mul(q, rq)

Multiplies rq (or this if no rq) by q

Parameters:
Name Type Description
`q`
`rq`

if not defined this is multiplied by q

Source:

neg()

Negates the quaternion.

Source:

normalize()

Normalizes the quaternion.

Source:

set()

Set value of the Quaternion directly.

Source:

toMatrix()

That method doesn't do anything. Check {SQR.Matrix44.TQS()} to see how to turn a Quanternion into a matrix representation.

Source:
To Do:
• Implement (or not... not sure how much this is needed)