Class: Quat

Quat

A set of 4-dimensional coordinates used to represent rotation in 3-dimensional space.

new Quat(x, y, z, w)

Name Type Default Description
x Number 0.0 optional The X component.
y Number 0.0 optional The Y component.
z Number 0.0 optional The Z component.
w Number 0.0 optional The W component.

Classes

Quat

Members

static,constantQuat.IDENTITYQuat

Identity Quat.

wNumber

The W component.
Default Value:
  • 0.0

xNumber

The X component.
Default Value:
  • 0.0

yNumber

The Y component.
Default Value:
  • 0.0

zNumber

The Z component.
Default Value:
  • 0.0

Methods

staticQuat.axisAngleToQuat(axis, angle){Quat}

Computes a Quat representing a rotation around an axis.
Name Type Default Description
axis Vec3 The axis of rotation.
angle number 0.0 optional The angle in radians to rotate around the axis.
Returns:
Type Description
Quat -

staticQuat.getLookAtSourceDest(sourcePoint, destPoint){Quat}

Computes a Quat from from source point heading to the destination point.
Name Type Description
sourcePoint Vec3 Source coordinate.
destPoint Vec3 Destination coordinate.
Returns:
Type Description
Quat -

staticQuat.getLookRotation(forward, up){Quat}

Computes a rotation from the given heading and up vector.
Name Type Description
forward Vec3 Heading target coordinates.
up Vec3 Up vector.
Returns:
Type Description
Quat -

staticQuat.getRotationBetweenVectors(u, v){Quat}

Compute rotation between two vectors.
Name Type Description
u Vec3 First vector.
v Vec3 Second vector.
Returns:
Type Description
Quat -

staticQuat.getRotationBetweenVectorsRes(u, v, res){Quat}

Compute rotation between two vectors.
Name Type Description
u Vec3 First vector.
v Vec3 Second vector.
res Quat
Returns:
Type Description
Quat -

staticQuat.getRotationBetweenVectorsUp(source, dest, up){Quat}

Compute rotation between two vectors with around vector up for exactly opposite vectors. If vectors exaclty in the same direction than returns identity Quat.
Name Type Description
source Vec3 First vector.
dest Vec3 Second vector.
up Vec3 Up vector.
Returns:
Type Description
Quat -

staticQuat.xRotation(a){Quat}

Returns a Quat represents rotation around X axis.
Name Type Description
a number The angle in radians to rotate around the axis.
Returns:
Type Description
Quat -

staticQuat.yRotation(a){Quat}

Returns a Quat represents rotation around Y axis.
Name Type Description
a number The angle in radians to rotate around the axis.
Returns:
Type Description
Quat -

staticQuat.zRotation(a){Quat}

Returns a Quat represents rotation around Z axis.
Name Type Description
a number The angle in radians to rotate around the axis.
Returns:
Type Description
Quat -
Computes the componentwise sum of two Quats.
Name Type Description
q Quat Quat to add.
Returns:
Type Description
Quat -
Clear Quat. Sets zeroes.
Returns:
Type Description
Quat -
Duplicates a Quat instance.
Returns:
Type Description
Quat -

conjugate(){Quat}

Gets the conjugate of the Quat.
Returns:
Type Description
Quat -
Copy Quat values.
Name Type Description
q Quat Copy Quat.
Returns:
Type Description
Quat -

dot(q){number}

Computes the dot (scalar) product of two Quats.
Name Type Description
q Quat Second quatrnion.
Returns:
Type Description
number -

getAxisAngle(){Object}

Returns axis and angle of the current Quat.
Returns:
Type Description
Object -

getEulerAngles(){Object}

Returns Euler's angles of the current Quat.
Returns:
Type Description
Object -

getMat3(){Mat3}

Converts current Quat to the rotation 3x3 matrix.
TODO
  • NOT TESTED
Returns:
Type Description
Mat3 -
Converts current Quat to the rotation 4x4 matrix.
Returns:
Type Description
Mat4 -

getPitch(reprojectAxis){number}

Returns a pitch angle in radians.
Name Type Description
reprojectAxis Boolean optional -
Returns:
Type Description
number -

getRoll(reprojectAxis){Number}

Returns a roll angle in radians.
Name Type Description
reprojectAxis Boolean optional -
Returns:
Type Description
Number -

getYaw(reprojectAxis){number}

Returns a yaw angle in radians.
Name Type Description
reprojectAxis Boolean optional -
Returns:
Type Description
number -
Computes the inverse of the Quat.
Returns:
Type Description
Quat -

isEqual(q){Boolean}

Compares two Quats.
Name Type Description
q Quat Second quatrnion.
Returns:
Type Description
Boolean -
Returns true if the components are zero.
Name Type Description
q Quat Quat to subtract.
Returns:
Type Description
Quat -

magnitude(){number}

Computes a magnitude of the Quat.
Returns:
Type Description
number -

magnitude2(){number}

Computes a squared magnitude of the Quat.
Returns:
Type Description
number -
Computes the product of two Quats.
Name Type Description
q Quat Quat to multiply.
Returns:
Type Description
Quat -
Computes the product of two Quats.
Name Type Description
q Quat Quat to multiply.
Returns:
Type Description
Quat -

mulVec3(v){Vec3}

Returns quatrenion and vector production.
Name Type Description
v Vec3 3d Vector.
Returns:
Type Description
Vec3 -

normalize(){Quat}

Current Quat normalization.
Returns:
Type Description
Quat -

scale(scale){Quat}

Multiplies the provided Quat componentwise.
Name Type Description
scale Number The scalar to multiply with.
Returns:
Type Description
Quat -

scaleTo(scale){Quat}

Multiplies the provided Quat componentwise by the provided scalar.
Name Type Description
scale Number The scalar to multiply with.
Returns:
Type Description
Quat -

set(x, y, z, w){Quat}

Sets Quat values.
Name Type Default Description
x Number 0.0 optional The X component.
y Number 0.0 optional The Y component.
z Number 0.0 optional The Z component.
w Number 0.0 optional The W component.
Returns:
Type Description
Quat -

setFromAxisAngle(axis, angle){Quat}

Sets current Quat representing a rotation around an axis.
Name Type Description
axis Vec3 The axis of rotation.
angle number The angle in radians to rotate around the axis.
Returns:
Type Description
Quat -

setFromEulerAngles(pitch, yaw, roll){Quat}

Sets current Quat by Euler's angles.
Name Type Description
pitch number Pitch angle in degrees.
yaw number Yaw angle in degrees.
roll number Roll angle in degrees.
Returns:
Type Description
Quat -

setFromMatrix4(m){Quat}

Computes a Quat from the provided 4x4 matrix instance.
Name Type Description
m Mat4 The rotation matrix.
Returns:
Type Description
Quat -

setFromSphericalCoords(lat, lon, angle){Quat}

Sets current quaternion by spherical coordinates.
Name Type Description
lat number Latitude.
lon number Longitude.
angle number Angle in radians.
Returns:
Type Description
Quat -

setIdentity(){Quat}

Set current Quat instance to identity Quat.
Returns:
Type Description
Quat -

setLookRotation(forward, up){Quat}

Sets rotation with the given heading and up vectors.
Name Type Description
forward Vec3 Heading target coordinates.
up Vec3 Up vector.
Returns:
Type Description
Quat -

slerp(b, t){Quat}

Performs a spherical linear interpolation between two Quats.
Name Type Description
b Quat The end rotation Quat.
t number interpolation amount between the two Quats.
Returns:
Type Description
Quat -
Computes the componentwise difference of two Quats.
Name Type Description
q Quat Quat to subtract.
Returns:
Type Description
Quat -

toSphericalCoords(){Object}

Gets spherical coordinates.
Returns:
Type Description
Object Returns object with latitude, longitude and alpha.

toVec(){Array.<number>}

Converts Quat values to array.
Returns:
Type Description
Array.<number> - (exactly 4 entries)