# Module: quat

Quaternion

Source:
  - quat.js, line 6

### Members

#### (static, constant) equals

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

Source:
  - quat.js, line 535

#### (static, constant) exactEquals

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

Source:
  - quat.js, line 526

#### (static, constant) length

Calculates the length of a quat

Source:
  - quat.js, line 486

#### (static, constant) rotationTo

Sets a quaternion to represent the shortest rotation from one vector to another. Both vectors are assumed to be unit length.

Source:
  - quat.js, line 548

#### (static, constant) setAxes

Sets the specified quaternion with values corresponding to the given axes. Each axis is a vec3 and is expected to be unit length and perpendicular to all other specified axes.

Source:
  - quat.js, line 613

#### (static, constant) sqlerp

Performs a spherical linear interpolation with two control points

Source:
  - quat.js, line 590

### Methods

#### (static) add(out, a, b) → {quat}

Adds two quat's

##### Parameters:

Name | Type | Description
--- | --- | ---
`out` | quat | the receiving quaternion
`a` | quat | the first operand
`b` | quat | the second operand

Source:
  - quat.js, line 439

##### Returns:

out

Type
  quat

#### (static) calculateW(out, a) → {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:

Name | Type | Description
--- | --- | ---
`out` | quat | the receiving quaternion
`a` | quat | quat to calculate W component of

Source:
  - quat.js, line 180

##### Returns:

out

Type
  quat

#### (static) clone(a) → {quat}

Creates a new quat initialized with values from an existing quaternion

##### Parameters:

Name | Type | Description
--- | --- | ---
`a` | quat | quaternion to clone

Source:
  - quat.js, line 393

##### Returns:

a new quaternion

Type
  quat

#### (static) conjugate(out, a) → {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:

Name | Type | Description
--- | --- | ---
`out` | quat | the receiving quaternion
`a` | quat | quat to calculate conjugate of

Source:
  - quat.js, line 291

##### Returns:

out

Type
  quat

#### (static) copy(out, a) → {quat}

Copy the values from one quat to another

##### Parameters:

Name | Type | Description
--- | --- | ---
`out` | quat | the receiving quaternion
`a` | quat | the source quaternion

Source:
  - quat.js, line 415

##### Returns:

out

Type
  quat

#### (static) create() → {quat}

Creates a new identity quat

Source:
  - quat.js, line 16

##### Returns:

a new quaternion

Type
  quat

#### (static) dot(a, b) → {Number}

Calculates the dot product of two quat's

##### Parameters:

Name | Type | Description
--- | --- | ---
`a` | quat | the first operand
`b` | quat | the second operand

Source:
  - quat.js, line 466

##### Returns:

dot product of a and b

Type
  Number

#### (static) fromEuler(out, Angle, Angle, Angle) → {quat}

Creates a quaternion from the given euler angle x, y, z.

##### Parameters:

Name | Type | Description
--- | --- | ---
`out` | quat | the receiving quaternion
`Angle` | x | to rotate around X axis in degrees.
`Angle` | y | to rotate around Y axis in degrees.
`Angle` | z | to rotate around Z axis in degrees.

Source:
  - quat.js, line 355

##### Returns:

out

Type
  quat

#### (static) fromMat3(out, m) → {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.

##### Parameters:

Name | Type | Description
--- | --- | ---
`out` | quat | the receiving quaternion
`m` | mat3 | rotation matrix

Source:
  - quat.js, line 310

##### Returns:

out

Type
  quat

#### (static) fromValues(x, y, z, w) → {quat}

Creates a new quat initialized with the given values

##### Parameters:

Name | Type | Description
--- | --- | ---
`x` | Number | X component
`y` | Number | Y component
`z` | Number | Z component
`w` | Number | W component

Source:
  - quat.js, line 405

##### Returns:

a new quaternion

Type
  quat

#### (static) getAxisAngle(out_axis, q) → {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:

Name | Type | Description
--- | --- | ---
`out_axis` | vec3 | Vector receiving the axis of rotation
`q` | quat | Quaternion to be decomposed

Source:
  - quat.js, line 73

##### Returns:

Angle, in radians, of the rotation

Type
  Number

#### (static) identity(out) → {quat}

Set a quat to the identity quaternion

##### Parameters:

Name | Type | Description
--- | --- | ---
`out` | quat | the receiving quaternion

Source:
  - quat.js, line 33

##### Returns:

out

Type
  quat

#### (static) invert(out, a) → {quat}

Calculates the inverse of a quat

##### Parameters:

Name | Type | Description
--- | --- | ---
`out` | quat | the receiving quaternion
`a` | quat | quat to calculate inverse of

Source:
  - quat.js, line 269

##### Returns:

out

Type
  quat

#### (static) len()

Alias for quat.length

Source:
  - quat.js, line 492

#### (static) lerp(out, a, b, t) → {quat}

Performs a linear interpolation between two quat's

##### Parameters:

Name | Type | Description
--- | --- | ---
`out` | quat | the receiving quaternion
`a` | quat | the first operand
`b` | quat | the second operand
`t` | Number | interpolation amount, in the range [0-1], between the two inputs

Source:
  - quat.js, line 478

##### Returns:

out

Type
  quat

#### (static) mul()

Alias for quat.multiply

Source:
  - quat.js, line 445

#### (static) multiply(out, a, b) → {quat}

Multiplies two quat's

##### Parameters:

Name | Type | Description
--- | --- | ---
`out` | quat | the receiving quaternion
`a` | quat | the first operand
`b` | quat | the second operand

Source:
  - quat.js, line 97

##### Returns:

out

Type
  quat

#### (static) normalize(out, a) → {quat}

Normalize a quat

##### Parameters:

Name | Type | Description
--- | --- | ---
`out` | quat | the receiving quaternion
`a` | quat | quaternion to normalize

Source:
  - quat.js, line 517

##### Returns:

out

Type
  quat

#### (static) random(out) → {quat}

Generates a random quaternion

##### Parameters:

Name | Type | Description
--- | --- | ---
`out` | quat | the receiving quaternion

Source:
  - quat.js, line 245

##### Returns:

out

Type
  quat

#### (static) rotateX(out, a, rad) → {quat}

Rotates a quaternion by the given angle about the X axis

##### Parameters:

Name | Type | Description
--- | --- | ---
`out` | quat | quat receiving operation result
`a` | quat | quat to rotate
`rad` | number | angle (in radians) to rotate

Source:
  - quat.js, line 116

##### Returns:

out

Type
  quat

#### (static) rotateY(out, a, rad) → {quat}

Rotates a quaternion by the given angle about the Y axis

##### Parameters:

Name | Type | Description
--- | --- | ---
`out` | quat | quat receiving operation result
`a` | quat | quat to rotate
`rad` | number | angle (in radians) to rotate

Source:
  - quat.js, line 137

##### Returns:

out

Type
  quat

#### (static) rotateZ(out, a, rad) → {quat}

Rotates a quaternion by the given angle about the Z axis

##### Parameters:

Name | Type | Description
--- | --- | ---
`out` | quat | quat receiving operation result
`a` | quat | quat to rotate
`rad` | number | angle (in radians) to rotate

Source:
  - quat.js, line 158

##### Returns:

out

Type
  quat

#### (static) scale(out, a, b) → {quat}

Scales a quat by a scalar number

##### Parameters:

Name | Type | Description
--- | --- | ---
`out` | quat | the receiving vector
`a` | quat | the vector to scale
`b` | Number | amount to scale the vector by

Source:
  - quat.js, line 456

##### Returns:

out

Type
  quat

#### (static) set(out, x, y, z, w) → {quat}

Set the components of a quat to the given values

##### Parameters:

Name | Type | Description
--- | --- | ---
`out` | quat | the receiving quaternion
`x` | Number | X component
`y` | Number | Y component
`z` | Number | Z component
`w` | Number | W component

Source:
  - quat.js, line 428

##### Returns:

out

Type
  quat

#### (static) setAxisAngle(out, axis, rad) → {quat}

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

##### Parameters:

Name | Type | Description
--- | --- | ---
`out` | quat | the receiving quaternion
`axis` | vec3 | the axis around which to rotate
`rad` | Number | the angle in radians

Source:
  - quat.js, line 50

##### Returns:

out

Type
  quat

#### (static) slerp(out, a, b, t) → {quat}

Performs a spherical linear interpolation between two quat

##### Parameters:

Name | Type | Description
--- | --- | ---
`out` | quat | the receiving quaternion
`a` | quat | the first operand
`b` | quat | the second operand
`t` | Number | interpolation amount, in the range [0-1], between the two inputs

Source:
  - quat.js, line 199

##### Returns:

out

Type
  quat

#### (static) sqrLen()

Alias for quat.squaredLength

Source:
  - quat.js, line 507

#### (static) squaredLength(a) → {Number}

Calculates the squared length of a quat

##### Parameters:

Name | Type | Description
--- | --- | ---
`a` | quat | vector to calculate squared length of

Source:
  - quat.js, line 501

##### Returns:

squared length of a

Type
  Number

#### (static) str(a) → {String}

Returns a string representation of a quatenion

##### Parameters:

Name | Type | Description
--- | --- | ---
`a` | quat | vector to represent as a string

Source:
  - quat.js, line 382

##### Returns:

string representation of the vector

Type
  String