Class: Quat

og/math/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,constantmodule:og/math/Quat~Quat.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

staticmodule:og/math/Quat~Quat.axisAngleToQuat(axis, angle){og.Quat}

Computes a 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

staticmodule:og/math/Quat~Quat.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

staticmodule:og/math/Quat~Quat.getLookAtTargetUp(target, up){og.Quat}

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

staticmodule:og/math/Quat~Quat.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

staticmodule:og/math/Quat~Quat.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

staticmodule:og/math/Quat~Quat.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

staticmodule:og/math/Quat~Quat.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

staticmodule:og/math/Quat~Quat.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

getMat4(){og.Mat4}

Converts current Quat to the rotation matrix.
Returns:
Type Description
og.Mat4

getPitch(){number}

Returns a pitch angle in radians.
Returns:
Type Description
number

getRoll(){number}

Returns a roll angle in radians.
Returns:
Type Description
number

getYaw(){number}

Returns a yaw angle in radians.
Returns:
Type Description
number
Computes the inverse of the Quat.

isEqual(q){boolean}

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

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

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

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)

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

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

Sets current cuaternion 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

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>