Class: Quat

Quat

new Quat(x, y, z, w)

A set of 4-dimensional coordinates used to represent rotation in 3-dimensional space.
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.

Members

static,constantQuat.IDENTITYog.Quat

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){og.Quat}

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

staticQuat.getLookAtSourceDest(sourcePoint, destPoint){og.Quat}

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

staticQuat.getLookRotation(forward, up){og.Quat}

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

staticQuat.getRotationBetweenVectors(u, v){og.Quat}

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

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

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

staticQuat.getRotationBetweenVectorsUp(source, dest, up){og.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 og.Vec3 First vector.
dest og.Vec3 Second vector.
up og.Vec3 Up vector.
Returns:
Type Description
og.Quat -

staticQuat.xRotation(a){og.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
og.Quat -

staticQuat.yRotation(a){og.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
og.Quat -

staticQuat.zRotation(a){og.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
og.Quat -

add(q){og.Quat}

Computes the componentwise sum of two Quats.
Name Type Description
q og.Quat Quat to add.
Returns:
Type Description
og.Quat -

clear(){og.Quat}

Clear Quat. Sets zeroes.
Returns:
Type Description
og.Quat -

clone(){og.Quat}

Duplicates a Quat instance.
Returns:
Type Description
og.Quat -

conjugate(){og.Quat}

Gets the conjugate of the Quat.
Returns:
Type Description
og.Quat -

copy(q){og.Quat}

Copy Quat values.
Name Type Description
q og.Quat Copy Quat.
Returns:
Type Description
og.Quat -

dot(q){number}

Computes the dot (scalar) product of two Quats.
Name Type Description
q og.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(){og.Mat3}

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

getMat4(){og.Mat4}

Converts current Quat to the rotation 4x4 matrix.
Returns:
Type Description
og.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 -

inverse(){og.Quat}

Computes the inverse of the Quat.
Returns:
Type Description
og.Quat -

isEqual(q){Boolean}

Compares two Quats.
Name Type Description
q og.Quat Second quatrnion.
Returns:
Type Description
Boolean -

isZero(q){og.Quat}

Returns true if the components are zero.
Name Type Description
q og.Quat Quat to subtract.
Returns:
Type Description
og.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 -

mul(q){og.Quat}

Computes the product of two Quats.
Name Type Description
q og.Quat Quat to multiply.
Returns:
Type Description
og.Quat -

mulA(q){og.Quat}

Computes the product of two Quats.
Name Type Description
q og.Quat Quat to multiply.
Returns:
Type Description
og.Quat -

mulVec3(v){og.Vec3}

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

normalize(){og.Quat}

Current Quat normalization.
Returns:
Type Description
og.Quat -

scale(scale){og.Quat}

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

scaleTo(scale){og.Quat}

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

set(x, y, z, w){og.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
og.Quat -

setFromAxisAngle(axis, angle){og.Quat}

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

setFromEulerAngles(pitch, yaw, roll){og.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
og.Quat -

setFromMatrix4(m){og.Quat}

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

setFromSphericalCoords(lat, lon, angle){og.Quat}

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

setIdentity(){og.Quat}

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

setLookRotation(forward, up){og.Quat}

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

slerp(b, t){og.Quat}

Performs a spherical linear interpolation between two Quats.
Name Type Description
b og.Quat The end rotation Quat.
t number interpolation amount between the two Quats.
Returns:
Type Description
og.Quat -

sub(q){og.Quat}

Computes the componentwise difference of two Quats.
Name Type Description
q og.Quat Quat to subtract.
Returns:
Type Description
og.Quat -

toSphericalCoords(){Object}

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

toVec(){Array.<number, number, number, number>}

Converts Quat values to array.
Returns:
Type Description
Array.<number, number, number, number> -