Class: Quaternion

og.math.Quaternion

new og.math.Quaternion(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,constantog.math.Quaternion.IDENTITYog.math.Quaternion

Identity quaternion.

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

staticog.math.Quaternion.axisAngleToQuat(axis, angle){og.math.Quaternion}

Computes a quaternion representing a rotation around an axis.
Name Type Description
axis og.math.Vector3 The axis of rotation.
angle number The angle in radians to rotate around the axis.
Returns:
Type Description
og.math.Quaternion

staticog.math.Quaternion.getLookAtSourceDest(sourcePoint, destPoint){og.math.Quaternion}

Computes a quaternion from from source point heading to the destination point.
Name Type Description
sourcePoint og.math.Vector3 Source coordinate.
destPoint og.math.Vector3 Destination coordinate.
Returns:
Type Description
og.math.Quaternion

staticog.math.Quaternion.getLookAtTargetUp(target, up){og.math.Quaternion}

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

staticog.math.Quaternion.getRotationBetweenVectors(u, v){og.math.Quaternion}

Compute rotation between two vectors.
Name Type Description
u og.math.Vector3 First vector.
v og.math.Vector3 Second vector.
Returns:
Type Description
og.math.Quaternion

staticog.math.Quaternion.getRotationBetweenVectorsUp(source, dest, up){og.math.Quaternion}

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

staticog.math.Quaternion.xRotation(a){og.math.Quaternion}

Returns a quaternion represents rotation around X axis.
Name Type Description
a number The angle in radians to rotate around the axis.
Returns:
Type Description
og.math.Quaternion

staticog.math.Quaternion.yRotation(a){og.math.Quaternion}

Returns a quaternion represents rotation around Y axis.
Name Type Description
a number The angle in radians to rotate around the axis.
Returns:
Type Description
og.math.Quaternion

staticog.math.Quaternion.zRotation(a){og.math.Quaternion}

Returns a quaternion represents rotation around Z axis.
Name Type Description
a number The angle in radians to rotate around the axis.
Returns:
Type Description
og.math.Quaternion
Computes the componentwise sum of two quaternions.
Name Type Description
q og.math.Quaternion Quaternion to add.
Returns:
Type Description
og.math.Quaternion
Clear quaternion. Sets zeroes.
Returns:
Type Description
og.math.Quaternion
Duplicates a quaternion instance.
Returns:
Type Description
og.math.Quaternion
Gets the conjugate of the quaternion.
Returns:
Type Description
og.math.Quaternion
Copy quaternion values.
Name Type Description
q og.math.Quaternion Copy quaternion.
Returns:
Type Description
og.math.Quaternion
Computes the dot (scalar) product of two quaternions.
Name Type Description
q og.math.Quaternion Second quatrnion.
Returns:
Type Description
number
Returns axis and angle of the current quaternion.
Returns:
Type Description
Object
Returns Euler's angles of the current quaternion.
Returns:
Type Description
Object
Converts current quaternion to the rotation matrix.
Returns:
Type Description
og.math.Matrix4

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 quaternion.

isEqual(q){boolean}

Compares two quaternions.
Name Type Description
q og.math.Quaternion Second quatrnion.
Returns:
Type Description
boolean

magnitude(){number}

Computes a magnitude of the quaternion.
Returns:
Type Description
number

magnitude2(){number}

Computes a squared magnitude of the quaternion.
Returns:
Type Description
number
Computes the product of two quaternions.
Name Type Description
q og.math.Quaternion Quaternion to multiply.
Returns:
Type Description
og.math.Quaternion
Returns quatrenion and vector production.
Name Type Description
v og.math.Vector3 3d Vector.
Returns:
Type Description
og.math.Vector3
Current quaternion normalization.
Returns:
Type Description
og.math.Quaternion
Multiplies the provided quaternion componentwise by the provided scalar.
Name Type Description
scale Number The scalar to multiply with.
Returns:
Type Description
og.math.Quaternion
Sets quaternion 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.math.Quaternion

setFromAxisAngle(axis, angle){og.math.Quaternion}

Sets current quaternion representing a rotation around an axis.
Name Type Description
axis og.math.Vector3 The axis of rotation.
angle number The angle in radians to rotate around the axis.
Returns:
Type Description
og.math.Quaternion

setFromEulerAngles(pitch, yaw, roll){og.math.Quaternion}

Sets current quaternion 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.math.Quaternion

setFromMatrix4(m)

Computes a quaternion from the provided 4x4 matrix instance.
Name Type Description
m og.math.Matrix4 The rotation matrix.

setFromSphericalCoords(lat, lon, angle){og.math.Quaternion}

Sets current cuaternion by spherical coordinates.
Name Type Description
lat number Latitude.
lon number Longitude.
angle number Angle in radians.
Returns:
Type Description
og.math.Quaternion
Set current quaternion instance to identity quaternion.
Returns:
Type Description
og.math.Quaternion
Performs a spherical linear interpolation between two quaternions.
Name Type Description
b og.math.Quaternion The end rotation quaternion.
t number interpolation amount between the two quaternions.
Returns:
Type Description
og.math.Quaternion
Computes the componentwise difference of two quaternions.
Name Type Description
q og.math.Quaternion Quaternion to subtract.
Returns:
Type Description
og.math.Quaternion

toSphericalCoords(){Object}

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

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

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