Options
All
• Public
• Public/Protected
• All

# Namespace quat

## Functions

function

#### Parameters

• ##### out: vec4

the receiving quaternion

the first operand

the second operand

out

### calculateW

• calculateW(out: quat, a: ReadonlyQuat): quat
• Calculates the W component of a quat from the X, Y, and Z components. Assumes that quaternion is 1 unit in length. Any existing W component will be ignored.

#### Parameters

• ##### out: quat

the receiving quaternion

quat to calculate W component of

out

### Const clone

• Creates a new quat initialized with values from an existing quaternion

function

#### Parameters

quaternion to clone

#### Returns vec4

a new quaternion

### conjugate

• conjugate(out: quat, a: ReadonlyQuat): quat
• Calculates the conjugate of a quat If the quaternion is normalized, this function is faster than quat.inverse and produces the same result.

#### Parameters

• ##### out: quat

the receiving quaternion

quat to calculate conjugate of

out

### Const copy

• copy(out: vec4, a: ReadonlyVec4): vec4
• Copy the values from one quat to another

function

#### Parameters

• ##### out: vec4

the receiving quaternion

the source quaternion

out

### create

• Creates a new identity quat

#### Returns quat

a new quaternion

### Const dot

• Calculates the dot product of two quat's

function

#### Parameters

the first operand

the second operand

#### Returns number

dot product of a and b

### Const equals

• Returns whether or not the quaternions have approximately the same elements in the same position.

#### Parameters

The first vector.

The second vector.

#### Returns boolean

True if the vectors are equal, false otherwise.

### Const exactEquals

• Returns whether or not the quaternions have exactly the same elements in the same position (when compared with ===)

#### Parameters

The first quaternion.

The second quaternion.

#### Returns boolean

True if the vectors are equal, false otherwise.

### exp

• Calculate the exponential of a unit quaternion.

#### Parameters

• ##### out: quat

the receiving quaternion

quat to calculate the exponential of

out

### fromEuler

• fromEuler(out: quat, x: any, y: any, z: any): quat
• Creates a quaternion from the given euler angle x, y, z.

function

#### Parameters

• ##### out: quat

the receiving quaternion

out

### fromMat3

• fromMat3(out: quat, m: ReadonlyMat3): quat
• Creates a quaternion from the given 3x3 rotation matrix.

NOTE: The resultant quaternion is not normalized, so you should be sure to renormalize the quaternion yourself where necessary.

function

#### Parameters

• ##### out: quat

the receiving quaternion

rotation matrix

out

### Const fromValues

• fromValues(x: number, y: number, z: number, w: number): vec4
• Creates a new quat initialized with the given values

function

#### Parameters

• ##### x: number

X component

• ##### y: number

Y component

• ##### z: number

Z component

• ##### w: number

W component

#### Returns vec4

a new quaternion

### getAngle

• Gets the angular distance between two unit quaternions

#### Parameters

Origin unit quaternion

Destination unit quaternion

#### Returns number

Angle, in radians, between the two quaternions

### getAxisAngle

• getAxisAngle(out_axis: vec3, q: ReadonlyQuat): number
• Gets the rotation axis and angle for a given quaternion. If a quaternion is created with setAxisAngle, this method will return the same values as providied in the original parameter list OR functionally equivalent values. Example: The quaternion formed by axis [0, 0, 1] and angle -90 is the same as the quaternion formed by [0, 0, 1] and 270. This method favors the latter.

#### Parameters

• ##### out_axis: vec3

Vector receiving the axis of rotation

Quaternion to be decomposed

#### Returns number

Angle, in radians, of the rotation

### identity

• Set a quat to the identity quaternion

#### Parameters

• ##### out: quat

the receiving quaternion

out

### invert

• invert(out: quat, a: ReadonlyQuat): quat
• Calculates the inverse of a quat

#### Parameters

• ##### out: quat

the receiving quaternion

quat to calculate inverse of

out

### Const len

• Alias for quat.length

function

### Const length

• Calculates the length of a quat

#### Parameters

vector to calculate length of

length of a

### Const lerp

• Performs a linear interpolation between two quat's

function

#### Parameters

• ##### out: vec4

the receiving quaternion

the first operand

the second operand

• ##### t: number

interpolation amount, in the range [0-1], between the two inputs

out

### ln

• Calculate the natural logarithm of a unit quaternion.

#### Parameters

• ##### out: quat

the receiving quaternion

quat to calculate the exponential of

out

### mul

• Multiplies two quat's

#### Parameters

• ##### out: quat

the receiving quaternion

the first operand

the second operand

out

### multiply

• Multiplies two quat's

#### Parameters

• ##### out: quat

the receiving quaternion

the first operand

the second operand

out

### Const normalize

• normalize(out: vec4, a: ReadonlyVec4): vec4
• Normalize a quat

function

#### Parameters

• ##### out: vec4

the receiving quaternion

quaternion to normalize

out

### pow

• pow(out: quat, a: ReadonlyQuat, b: number): quat
• Calculate the scalar power of a unit quaternion.

#### Parameters

• ##### out: quat

the receiving quaternion

quat to calculate the exponential of

• ##### b: number

amount to scale the quaternion by

out

### random

• Generates a random unit quaternion

#### Parameters

• ##### out: quat

the receiving quaternion

out

### rotateX

• Rotates a quaternion by the given angle about the X axis

#### Parameters

• ##### out: quat

quat receiving operation result

quat to rotate

out

### rotateY

• Rotates a quaternion by the given angle about the Y axis

#### Parameters

• ##### out: quat

quat receiving operation result

quat to rotate

out

### rotateZ

• Rotates a quaternion by the given angle about the Z axis

#### Parameters

• ##### out: quat

quat receiving operation result

quat to rotate

out

### rotationTo

• rotationTo(out: any, a: any, b: any): any

### Const scale

• scale(out: vec4, a: ReadonlyVec4, b: number): vec4
• Scales a quat by a scalar number

function

#### Parameters

• ##### out: vec4

the receiving vector

the vector to scale

• ##### b: number

amount to scale the vector by

out

### Const set

• set(out: vec4, x: number, y: number, z: number, w: number): vec4
• Set the components of a quat to the given values

function

#### Parameters

• ##### out: vec4

the receiving quaternion

• ##### x: number

X component

• ##### y: number

Y component

• ##### z: number

Z component

• ##### w: number

W component

out

### setAxes

• setAxes(out: any, view: any, right: any, up: any): vec4

### setAxisAngle

• Sets a quat from the given angle and rotation axis, then returns it.

#### Parameters

• ##### out: quat

the receiving quaternion

the axis around which to rotate

out

### slerp

• Performs a spherical linear interpolation between two quat

#### Parameters

• ##### out: quat

the receiving quaternion

the first operand

the second operand

• ##### t: number

interpolation amount, in the range [0-1], between the two inputs

out

### sqlerp

• sqlerp(out: any, a: any, b: any, c: any, d: any, t: any): any

### Const sqrLen

• Alias for quat.squaredLength

function

### Const squaredLength

• Calculates the squared length of a quat

function

#### Parameters

vector to calculate squared length of

#### Returns number

squared length of a