# HQuat

## Content

HQuat | operator*

## Fields

float | `x`
float | `y`
float | `z`
float | `w`

## Functions

const HQuat & | `Normalize`
| `HQuat`
| `HQuat`
| `HQuat`
| `HQuat`
void | `Set`
HQuat | `operator*`
HQuat | `operator*`
HQuat | `operator/`
HQuat | `operator-`
HQuat | `operator+`
void | `ToMatrix`
HQuat | `Qlog`
HQuat | `Qexp`
HQuat | `Qlerp`
HQuat | `Qslerp`
HQuat | `QslerpNoInvert`
HQuat | `QslerpNoInvertExtraSpins`
HQuat | `Qsquad`
HQuat | `Qspline`
HQuat | `MatrixToQuaternion`

## Detailed Description

class HQuat

  The HQuat class defines the data type of a Quaternion.

  The HQuat class encapsulates the x,y,x,w values used to define a quaternion as well as various functions to perform algebrahic operations on quaternions

  Public Functions

  const HQuat &Normalize()

    normalizes an HQuat

  inline HQuat()

    default constructor

  inline HQuat(float X, float Y, float Z, float W)

    constructor that accepts three floats

  inline HQuat(HQuat const *p)

    constructor that accepts a pointer to an HQuat object

  inline HQuat(const HQuat &p)

    constructor that accepts an HQuat reference

  inline void Set(float X, float Y, float Z, float W)

    Set packs an HQuat object with coordinate values.

  inline HQuat operator*(const HQuat &q2) const

    Multiplies two quaternions

    Parameters

      q2 – Quaternion to multiply with

    Returns

      Result of multiplication

  inline HQuat operator*(float v) const

    Multiplies a quaternion with a float value

    Parameters

      v – Value to multiply Quaternion with

    Returns

      Result of multiplication

  inline HQuat operator/(float v) const

    Divides a quaternion by a float value

    Parameters

      v – Value to divide Quaternion by

    Returns

      Result of multiplication

  inline HQuat operator-(const HQuat &q2) const

    Subtracts one quaternion from another

    Parameters

      q2 – Quaternion to subtract with

    Returns

      Result of subtraction

  inline HQuat operator+(const HQuat &q2) const

    Add one quaternion to another

    Parameters

      q2 – Quaternion to add

    Returns

      Result of addition

  void ToMatrix(float matrix[16])

    Convert Quaternion to matrix form

    Parameters

      matrix – Returns result matrix

  Public Members

  float x

    Quaternion x Coordinate

  float y

    Quaternion y Coordinate

  float z

    Quaternion z Coordinate

  float w

    Quaternion w Coordinate

  Public Static Functions

  static HQuat Qlog(const HQuat &q)

    Logarithm of a HQuat, given as: Qlog(q) = v*a where q = [cos(a),v*sin(a)]

    Parameters

      q – Quaternion to perform log on

    Returns

      Result of logarithm

  static HQuat Qexp(const HQuat &q)

    Qexp(v*a) = [cos(a),vsin(a)]

    Parameters

      q – Quaternion to perform exp on

    Returns

      Result of Exp

  static HQuat Qlerp(const HQuat &q1, const HQuat &q2, float fraction)

    Linear interpolation between two HQuats

    Parameters

      - q1 – First Quaternion for Interpolation

      - q2 – Second Quaternion for Interpolation

      - fraction – Interpolation Distance (0 - 1)

    Returns

      Result of interplation

  static HQuat Qslerp(const HQuat &q1, const HQuat &q2, float fraction)

    Spherical interpolation between two HQuats

    Parameters

      - q1 – First Quaternion for Interpolation

      - q2 – Second Quaternion for Interpolation

      - fraction – Interpolation Distance (0 - 1)

    Returns

      Result of interplation

  static HQuat QslerpNoInvert(const HQuat &q1, const HQuat &q2, float fraction)

    Spherical interpolation between two HQuats This version of slerp, used by squad, does not check for theta > 90.

    Parameters

      - q1 – First Quaternion for Interpolation

      - q2 – Second Quaternion for Interpolation

      - fraction – Interpolation Distance (0 - 1)

    Returns

      Result of interplation

  static HQuat QslerpNoInvertExtraSpins(const HQuat &q1, const HQuat &q2, float fraction, int ExtraSpins)

    Spherical interpolation between two HQuats This version of slerp, used by squad, does not check for theta > 90.

    Parameters

      - q1 – First Quaternion for Interpolation

      - q2 – Second Quaternion for Interpolation

      - fraction – Interpolation Distance (0 - 1)

    Returns

      Result of interplation

  static HQuat Qsquad(const HQuat &q1, const HQuat &q2, const HQuat &a, const HQuat &b, float fraction)

    Spherical cubic interpolation between two HQuats

    Parameters

      - q1 – First Quaternion for Interpolation

      - q2 – Second Quaternion for Interpolation

      - a – First Control Point

      - b – Second Control Point

      - fraction – Interpolation Distance (0 - 1)

    Returns

      Result of interplation

  static HQuat Qspline(const HQuat &qnm1, const HQuat &qn, const HQuat &qnp1)

    Given 3 HQuats, qn-1,qn and qn+1, calculate a control point to be used in spline interpolation

    Parameters

      - qnm1 – qn-1 control point

      - qn – qn control point

      - qnp1 – qn + 1 control point

    Returns

      Result of interplation

  static HQuat MatrixToQuaternion(float matrix[])

    Convert matrix to quaternion

    Returns

      converted quaternion

  Friends

  inline friend HQuat operator*(float v, const HQuat &q)

    Multiplies a quaternion with a float value

    Parameters

      - v – Value to multiply Quaternion with

      - q – Quaternion to multiply with

    Returns

      Result of multiplication