# Module: quat2

Dual Quaternion
Format: [real, dual]
Quaternion format: XYZW
Make sure to have normalized dual quaternions, otherwise the functions may not work as intended.

Source:
  - quat2.js, line 5

### Members

#### (static, constant) getReal

Gets the real part of a dual quat

Source:
  - quat2.js, line 268

### Methods

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

Adds two dual quat's

##### Parameters:

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

Source:
  - quat2.js, line 580

##### Returns:

out

Type
  quat2

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

Creates a new quat initialized with values from an existing quaternion

##### Parameters:

Name | Type | Description
--- | --- | ---
`a` | quat2 | dual quaternion to clone

Source:
  - quat2.js, line 41

##### Returns:

new dual quaternion

Type
  quat2

#### (static) conjugate(out, a) → {quat2}

Calculates the conjugate of a dual quat If the dual quaternion is normalized, this function is faster than quat2.inverse and produces the same result.

##### Parameters:

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

Source:
  - quat2.js, line 719

##### Returns:

out

Type
  quat2

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

Copy the values from one dual quat to another

##### Parameters:

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

Source:
  - quat2.js, line 204

##### Returns:

out

Type
  quat2

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

Creates a new identity dual quat

Source:
  - quat2.js, line 19

##### Returns:

a new dual quaternion [real -> rotation, dual -> translation]

Type
  quat2

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

Calculates the dot product of two dual quat's (The dot product of the real parts)

##### Parameters:

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

Source:
  - quat2.js, line 663

##### Returns:

dot product of a and b

Type
  Number

#### (static) equals(a, b) → {Boolean}

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

##### Parameters:

Name | Type | Description
--- | --- | ---
`a` | quat2 | the first dual quat.
`b` | quat2 | the second dual quat.

Source:
  - quat2.js, line 829

##### Returns:

true if the dual quats are equal, false otherwise.

Type
  Boolean

#### (static) exactEquals(a, b) → {Boolean}

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

##### Parameters:

Name | Type | Description
--- | --- | ---
`a` | quat2 | the first dual quaternion.
`b` | quat2 | the second dual quaternion.

Source:
  - quat2.js, line 817

##### Returns:

true if the dual quaternions are equal, false otherwise.

Type
  Boolean

#### (static) fromMat4(out, a) → {quat2}

Creates a new dual quat from a matrix (4x4)

##### Parameters:

Name | Type | Description
--- | --- | ---
`out` | quat2 | the dual quaternion
`a` | mat4 | the matrix

Source:
  - quat2.js, line 186

##### Returns:

dual quat receiving operation result

Type
  quat2

#### (static) fromRotation(dual, q) → {quat2}

Creates a dual quat from a quaternion

##### Parameters:

Name | Type | Description
--- | --- | ---
`dual` | quat2 | quaternion receiving operation result
`q` | quat | the quaternion

Source:
  - quat2.js, line 166

##### Returns:

dual quaternion receiving operation result

Type
  quat2

#### (static) fromRotationTranslation(dual, q, t) → {quat2}

Creates a dual quat from a quaternion and a translation

##### Parameters:

Name | Type | Description
--- | --- | ---
`dual` | quat2 | quaternion receiving operation result
`q` | quat | quaternion
`t` | vec3 | tranlation vector

Source:
  - quat2.js, line 119

##### Returns:

dual quaternion receiving operation result

Type
  quat2

#### (static) fromRotationTranslationValues(x1, y1, z1, w1, x2, y2, z2) → {quat2}

Creates a new dual quat from the given values (quat and translation)

##### Parameters:

Name | Type | Description
--- | --- | ---
`x1` | Number | X component
`y1` | Number | Y component
`z1` | Number | Z component
`w1` | Number | W component
`x2` | Number | X component (translation)
`y2` | Number | Y component (translation)
`z2` | Number | Z component (translation)

Source:
  - quat2.js, line 94

##### Returns:

new dual quaternion

Type
  quat2

#### (static) fromTranslation(dual, t) → {quat2}

Creates a dual quat from a translation

##### Parameters:

Name | Type | Description
--- | --- | ---
`dual` | quat2 | quaternion receiving operation result
`t` | vec3 | translation vector

Source:
  - quat2.js, line 146

##### Returns:

dual quaternion receiving operation result

Type
  quat2

#### (static) fromValues(x1, y1, z1, w1, x2, y2, z2, w2) → {quat2}

Creates a new dual quat initialized with the given values

##### Parameters:

Name | Type | Description
--- | --- | ---
`x1` | Number | X component
`y1` | Number | Y component
`z1` | Number | Z component
`w1` | Number | W component
`x2` | Number | X component
`y2` | Number | Y component
`z2` | Number | Z component
`w2` | Number | W component

Source:
  - quat2.js, line 68

##### Returns:

new dual quaternion

Type
  quat2

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

Gets the dual part of a dual quat

##### Parameters:

Name | Type | Description
--- | --- | ---
`out` | quat | dual part
`a` | quat2 | Dual Quaternion

Source:
  - quat2.js, line 276

##### Returns:

dual part

Type
  quat

#### (static) getTranslation(out, a) → {vec3}

Gets the translation of a normalized dual quat

##### Parameters:

Name | Type | Description
--- | --- | ---
`out` | vec3 | translation
`a` | quat2 | Dual Quaternion to be decomposed

Source:
  - quat2.js, line 316

##### Returns:

translation

Type
  vec3

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

Set a dual quat to the identity dual quaternion

##### Parameters:

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

Source:
  - quat2.js, line 222

##### Returns:

out

Type
  quat2

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

Calculates the inverse of a dual quat. If they are normalized, conjugate is cheaper

##### Parameters:

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

Source:
  - quat2.js, line 698

##### Returns:

out

Type
  quat2

#### (static) len()

Alias for quat2.length

Source:
  - quat2.js, line 744

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

Calculates the length of a dual quat

##### Parameters:

Name | Type | Description
--- | --- | ---
`a` | quat2 | dual quat to calculate length of

Source:
  - quat2.js, line 738

##### Returns:

length of a

Type
  Number

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

Performs a linear interpolation between two dual quats's NOTE: The resulting dual quaternions won't always be normalized (The error is most noticeable when t = 0.5)

##### Parameters:

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

Source:
  - quat2.js, line 675

##### Returns:

out

Type
  quat2

#### (static) mul()

Alias for quat2.multiply

Source:
  - quat2.js, line 632

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

Multiplies two dual quat's

##### Parameters:

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

Source:
  - quat2.js, line 600

##### Returns:

out

Type
  quat2

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

Normalize a dual quat

##### Parameters:

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

Source:
  - quat2.js, line 769

##### Returns:

out

Type
  quat2

#### (static) rotateAroundAxis(out, a, axis, rad) → {quat2}

Rotates a dual quat around a given axis. Does the normalisation automatically

##### Parameters:

Name | Type | Description
--- | --- | ---
`out` | quat2 | the receiving dual quaternion
`a` | quat2 | the dual quaternion to rotate
`axis` | vec3 | the axis to rotate around
`rad` | Number | how far the rotation should be

Source:
  - quat2.js, line 536

##### Returns:

out

Type
  quat2

#### (static) rotateByQuatAppend(out, a, q) → {quat2}

Rotates a dual quat by a given quaternion (a * q)

##### Parameters:

Name | Type | Description
--- | --- | ---
`out` | quat2 | the receiving dual quaternion
`a` | quat2 | the dual quaternion to rotate
`q` | quat | quaternion to rotate by

Source:
  - quat2.js, line 469

##### Returns:

out

Type
  quat2

#### (static) rotateByQuatPrepend(out, q, a) → {quat2}

Rotates a dual quat by a given quaternion (q * a)

##### Parameters:

Name | Type | Description
--- | --- | ---
`out` | quat2 | the receiving dual quaternion
`q` | quat | quaternion to rotate by
`a` | quat2 | the dual quaternion to rotate

Source:
  - quat2.js, line 502

##### Returns:

out

Type
  quat2

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

Rotates a dual quat around the X axis

##### Parameters:

Name | Type | Description
--- | --- | ---
`out` | quat2 | the receiving dual quaternion
`a` | quat2 | the dual quaternion to rotate
`rad` | number | how far should the rotation be

Source:
  - quat2.js, line 370

##### Returns:

out

Type
  quat2

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

Rotates a dual quat around the Y axis

##### Parameters:

Name | Type | Description
--- | --- | ---
`out` | quat2 | the receiving dual quaternion
`a` | quat2 | the dual quaternion to rotate
`rad` | number | how far should the rotation be

Source:
  - quat2.js, line 403

##### Returns:

out

Type
  quat2

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

Rotates a dual quat around the Z axis

##### Parameters:

Name | Type | Description
--- | --- | ---
`out` | quat2 | the receiving dual quaternion
`a` | quat2 | the dual quaternion to rotate
`rad` | number | how far should the rotation be

Source:
  - quat2.js, line 436

##### Returns:

out

Type
  quat2

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

Scales a dual quat by a scalar number

##### Parameters:

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

Source:
  - quat2.js, line 643

##### Returns:

out

Type
  quat2

#### (static) set(out, x1, y1, z1, w1, x2, y2, z2, w2) → {quat2}

Set the components of a dual quat to the given values

##### Parameters:

Name | Type | Description
--- | --- | ---
`out` | quat2 | the receiving quaternion
`x1` | Number | X component
`y1` | Number | Y component
`z1` | Number | Z component
`w1` | Number | W component
`x2` | Number | X component
`y2` | Number | Y component
`z2` | Number | Z component
`w2` | Number | W component

Source:
  - quat2.js, line 249

##### Returns:

out

Type
  quat2

#### (static) setDual(out, q) → {quat2}

Set the dual component of a dual quat to the given quaternion

##### Parameters:

Name | Type | Description
--- | --- | ---
`out` | quat2 | the receiving quaternion
`q` | quat | a quaternion representing the dual part

Source:
  - quat2.js, line 302

##### Returns:

out

Type
  quat2

#### (static) setReal(out, q) → {quat2}

Set the real component of a dual quat to the given quaternion

##### Parameters:

Name | Type | Description
--- | --- | ---
`out` | quat2 | the receiving quaternion
`q` | quat | a quaternion representing the real part

Source:
  - quat2.js, line 292

##### Returns:

out

Type
  quat2

#### (static) sqrLen()

Alias for quat2.squaredLength

Source:
  - quat2.js, line 759

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

Calculates the squared length of a dual quat

##### Parameters:

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

Source:
  - quat2.js, line 753

##### Returns:

squared length of a

Type
  Number

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

Returns a string representation of a dual quatenion

##### Parameters:

Name | Type | Description
--- | --- | ---
`a` | quat2 | dual quaternion to represent as a string

Source:
  - quat2.js, line 805

##### Returns:

string representation of the dual quat

Type
  String

#### (static) translate(out, a, v) → {quat2}

Translates a dual quat by the given vector

##### Parameters:

Name | Type | Description
--- | --- | ---
`out` | quat2 | the receiving dual quaternion
`a` | quat2 | the dual quaternion to translate
`v` | vec3 | vector to translate by

Source:
  - quat2.js, line 339

##### Returns:

out

Type
  quat2