- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# FMQuaternion Class Reference
[Mathematics Classes.]

A quaternion. More...

`#include <FMQuaternion.h>`

List of all members.

## Public Member Functions
| FMQuaternion ()
| Creates an empty FMQuaternion.
| FMQuaternion (float _x, float _y, float _z, float _w)
| Creates the quaternion with the given component values.
| FMQuaternion (const float *values)
| Creates the quaternion with the given component values.
| FMQuaternion (const double *values)
| See above.
| FMQuaternion (const FMVector3 &axis, float angle)
| Creates the quaternion from a given axis and angle of rotation.
| operator float * ()
| Retrieves this quaternion as an array of `floats`.
| operator const float * () const
| See above.
FMQuaternion & | operator= (const float *v)
| Assign this FMQuaternion to the given `float` array.
float | LengthSquared () const
| Retrieves the squared length of the vector.
float | Length () const
| Retrieves the length of the vector.
void | NormalizeIt ()
| Normalizes this vector.
FMQuaternion | Normalize () const
| Returns a quaternion with a unit length at the same space as this quaternion.
FMQuaternion | operator * (const FMQuaternion &q) const
| Returns the concatonation of this quaternion rotation and the given quaternion rotation.
FMVector3 | operator * (const FMVector3 &v) const
| Returns the concatonation of this quaternion rotation applied on the given vector.
FMQuaternion | operator~ () const
| Returns the conjugate of this quaternion.
FMQuaternion & | operator *= (const FMQuaternion &q)
| Applies quaternion multiplication of the given quaternion with this quaternion and returns the value.
FMQuaternion & | operator= (const FMQuaternion &q)
| Copy constructor.
FMQuaternion | slerp (const FMQuaternion &other, float time) const
| Returns the slerp of this quaternion to other at time time.
FMVector3 | ToEuler (FMVector3 *previousAngles=NULL) const
| Converts a quaternion to its Euler rotation angles.
void | ToAngleAxis (FMVector3 &axis, float &angle) const
| Converts a quaternion to a angle-axis rotation.
FMMatrix44 | ToMatrix () const
| Converts a quaternion to a transformation matrix.
void | SetToMatrix (FMMatrix44 &m) const
| Sets the Quaternions transform onto the specified matrix.
## Static Public Member Functions
static FMQuaternion | EulerRotationQuaternion (float x, float y, float z)
| Get the FMQuaternion representation of the Euler rotation angles.
static FMQuaternion | MatrixRotationQuaternion (const FMMatrix44 &mat)
| Get the FMQuaternion that represents the FMMatrix44 rotation.
## Public Attributes
float | x
| The i component.
float | y
| The j component.
float | z
| The k component.
float | w
| The scalar component.
## Static Public Attributes
static const FMQuaternion | Zero
| The zero quaternion.
static const FMQuaternion | Identity
| The identity quaternion.

## Detailed Description

A quaternion.

Used to represent rotations: quaternions have the sole advantage of reduced floating-point error when concatenating rotations.

## Constructor & Destructor Documentation

FMQuaternion::FMQuaternion | ( |  | ) | `[inline]`

| Creates an empty FMQuaternion. The default values are non deterministic.

FMQuaternion::FMQuaternion | ( | float | _x,
|  | float | _y,
|  | float | _z,
|  | float | _w
| ) | `[inline]`

  | Creates the quaternion with the given component values. Parameters:
  | _x | The i component.
  | _y | The j component.
  | _z | The k component.
  | _w | The scalar component.

FMQuaternion::FMQuaternion | ( | const float * | values | ) |

  | Creates the quaternion with the given component values. Parameters:
  | values | A static float array containing at least four elements.

FMQuaternion::FMQuaternion | ( | const FMVector3 & | axis,
|  | float | angle
| ) |

  | Creates the quaternion from a given axis and angle of rotation. Parameters:
  | axis | The axis of rotation.
  | angle | The angle of rotation in radians.

## Member Function Documentation

static FMQuaternion FMQuaternion::EulerRotationQuaternion | ( | float | x,
|  | float | y,
|  | float | z
| ) | `[static]`

  | Get the FMQuaternion representation of the Euler rotation angles. Parameters:
  | x | The rotation about the x-axis (roll), in radians.
  | y | The rotation about the y-axis (pitch), in radians.
  | z | The rotation about the z-axis (yaw), in radians.

float FMQuaternion::Length | ( |  | ) | const`[inline]`

| Retrieves the length of the vector. Returns: The length of this vector.

float FMQuaternion::LengthSquared | ( |  | ) | const`[inline]`

| Retrieves the squared length of the vector. Returns: The squared length of this vector.

static FMQuaternion FMQuaternion::MatrixRotationQuaternion | ( | const FMMatrix44 & | mat | ) | `[static]`

  | Get the FMQuaternion that represents the FMMatrix44 rotation. Parameters:
  | mat | The matrix whose rotation we will represent

FMQuaternion FMQuaternion::Normalize | ( |  | ) | const`[inline]`

| Returns a quaternion with a unit length at the same space as this quaternion. Returns: A FMVector3 with length 1 and same direction as this vector.

FMVector3 FMQuaternion::operator * | ( | const FMVector3 & | v | ) | const

  | Returns the concatonation of this quaternion rotation applied on the given vector. This concatonation works great on vector but will give strange results for points. Parameters:
  | v | A 3D vector to rotate.
Returns: The rotated 3D vector.

FMQuaternion FMQuaternion::operator * | ( | const FMQuaternion & | q | ) | const

  | Returns the concatonation of this quaternion rotation and the given quaternion rotation. Parameters:
  | q | A second quaternion rotation.
Returns: The result of the two quaternion rotation.

FMQuaternion& FMQuaternion::operator *= | ( | const FMQuaternion & | q | ) | `[inline]`

  | Applies quaternion multiplication of the given quaternion with this quaternion and returns the value. Parameters:
  | q | The quaternion multiplied with.
Returns: The resulting quaternion.

FMQuaternion::operator float * | ( |  | ) | `[inline]`

| Retrieves this quaternion as an array of `floats`. Returns: The `float` array.

FMQuaternion& FMQuaternion::operator= | ( | const FMQuaternion & | q | ) | `[inline]`

  | Copy constructor. Clones the given quaternion into this quaternion. Parameters:
  | q | A quaternion to clone.
Returns: This quaternion.

FMQuaternion& FMQuaternion::operator= | ( | const float * | v | ) | `[inline]`

  | Assign this FMQuaternion to the given `float` array. Assigns each coordinate of this FMQuaternion to the elements in the `float` array. The first element to the i component, the second to the j, the third to the k, and the forth to the scalar. Parameters:
  | v | The `float` array to assign with.
Returns: This quaternion.

FMQuaternion FMQuaternion::operator~ | ( |  | ) | const`[inline]`

| Returns the conjugate of this quaternion. Returns: The conjugate.

void FMQuaternion::SetToMatrix | ( | FMMatrix44 & | m | ) | const

  | Sets the Quaternions transform onto the specified matrix. This will overwrite any existing rotations, but not positions Parameters:
  | m | The matrix to set our transform onto

FMQuaternion FMQuaternion::slerp | ( | const FMQuaternion & | other,
|  | float | time
| ) | const

  | Returns the slerp of this quaternion to other at time time. Parameters:
  | other | The Quaternion to interpolate to
  | time | The percentage (0 < time < 1) to slerp
Returns: The Quaternion formed by the slerp

void FMQuaternion::ToAngleAxis | ( | FMVector3 & | axis,
|  | float & | angle
| ) | const

  | Converts a quaternion to a angle-axis rotation. Parameters:
  | axis | The returned axis for the rotation.
  | angle | The returned angle for the rotation, in radians.

FMVector3 FMQuaternion::ToEuler | ( | FMVector3 * | previousAngles = `NULL` | ) | const

  | Converts a quaternion to its Euler rotation angles. Parameters:
  | previousAngles | To support animated quaternions conversion, you need to pass in the previous quaternion's converted angles. The closest angles to the previous angles will be returned for a smooth animation. If this parameter is NULL, one valid set of angles will be returned.
Returns: A 3D vector containing the Euler rotation angles.

FMMatrix44 FMQuaternion::ToMatrix | ( |  | ) | const

| Converts a quaternion to a transformation matrix. Returns: The transformation matrix for this quaternion.

## Member Data Documentation

const FMQuaternion FMQuaternion::Identity`[static]`

| The identity quaternion. Transforming a vector or a point with this quaternion returns the same vector or point.

The documentation for this class was generated from the following file:

- FMath/FMQuaternion.h