# Module: quat

Quaternion

Source:
  - quat.js, line 26

### Members

#### (static, constant) equals

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

Source:
  - quat.js, line 530

#### (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 521

#### (static, constant) length

Calculates the length of a quat

Source:
  - quat.js, line 481

#### (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 543

#### (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 608

#### (static, constant) sqlerp

Performs a spherical linear interpolation with two control points

Source:
  - quat.js, line 585

### 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 434

##### 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 198

##### 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 388

##### 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 286

##### 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 410

##### Returns:

out

Type
  quat

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

Creates a new identity quat

Source:
  - quat.js, line 36

##### 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 461

##### 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 350

##### 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 305

##### 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 400

##### 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 91

##### 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 51

##### 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 264

##### Returns:

out

Type
  quat

#### (static) len()

Alias for quat.length

Source:
  - quat.js, line 487

#### (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 between the two inputs

Source:
  - quat.js, line 473

##### Returns:

out

Type
  quat

#### (static) mul()

Alias for quat.multiply

Source:
  - quat.js, line 440

#### (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 115

##### 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 512

##### 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 134

##### 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 155

##### 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 176

##### 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 451

##### 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 423

##### 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 68

##### 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 between the two inputs

Source:
  - quat.js, line 217

##### Returns:

out

Type
  quat

#### (static) sqrLen()

Alias for quat.squaredLength

Source:
  - quat.js, line 502

#### (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 496

##### 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 377

##### Returns:

string representation of the vector

Type
  String