# cQuaternion Struct Reference
[Math]

cQuaternion can be used to represents rotations in quaternion form. Simple floating point arithmetic operations are provided too. More...

`#include <CQuaternion.h>`

List of all members.

## Public Member Functions
| cQuaternion ()
| Constructor of cQuaternion.
| cQuaternion (double nw, double nx, double ny, double nz)
| Constructor of cQuaternion.
| cQuaternion (double const *in)
| Constructor of cQuaternion.
| operator double * ()
| Cast quaternion to a double*.
| operator double const * () const
| Cast quaternion to a double const*.
void | zero ()
| Clear quaternion with zeros.
void | negate ()
| Negate current quaternion. Result is stored in current quaternion.
double | magsq () const
| Returns quaternion magnitude squared.
double | lengthsq () const
| Returns quaternion magnitude squared.
double | mag () const
| Returns quaternion magnitude.
double | length () const
| Returns quaternion magnitude.
void | normalize ()
| Normalize quaternion.
void | toRotMat (cMatrix3d &a_mat) const
| Convert quaternion to rotation matrix.
void | fromRotMat (cMatrix3d const &a_mat)
void | fromAxisAngle (cVector3d a_axis, double a_angle)
void | toAxisAngle (cVector3d &a_axis, double &a_angle) const
void | conj ()
| Conjugate of quaternion.
void | invert ()
| Invert quaternion ( inverse is conjugate/magsq ).
cQuaternion & | operator*= (cQuaternion const &a_otherQ)
| Multiply operator (grassman product).
void | mul (cQuaternion const &a_otherQ)
cQuaternion & | operator*= (double a_scale)
| Scale operator.
void | mul (double s)
| Scale this quaternion by a scalar.
bool | operator== (cQuaternion const &a_otherQ) const
| Equality operator.
double | dot (cQuaternion const &a_otherQ) const
cQuaternion & | operator+= (cQuaternion const &a_otherQ)
| Addition.
void | add (cQuaternion const &a_otherQ)
void | slerp (double a_level, cQuaternion const &a_q1, cQuaternion a_q2)
## Public Attributes
double | w
| Component w of quaternion.
double | x
| Component x of quaternion.
double | y
| Component y of quaternion.
double | z
| Component z of quaternion.

## Detailed Description

cQuaternion can be used to represents rotations in quaternion form. Simple floating point arithmetic operations are provided too.

## Member Function Documentation

void cQuaternion::add | ( | cQuaternion const & | a_otherQ | ) | `[inline]`

Addition
Add another quaternion to this one and store here.

Parameters:

  | a_otherQ | The other quaternion.

double cQuaternion::dot | ( | cQuaternion const & | a_otherQ | ) | const`[inline]`

Dot product.
Take the dot product with another quaternion and store the result here.

Parameters:

  | a_otherQ | The other quaternion.

Returns:
  The result of the dot product.

void cQuaternion::fromAxisAngle | ( | cVector3d | a_axis,
|  | double | a_angle |
| ) |  |  | `[inline]`

Convert from axis and angle (in radians).

Parameters:

  | a_axis | The axis.
  | a_angle | The angle in radians.

void cQuaternion::fromRotMat | ( | cMatrix3d const & | a_mat | ) | `[inline]`

Convert rotation matrix to quaternion.

Parameters:

  | a_mat | The rotation matrix to convert.

void cQuaternion::mul | ( | cQuaternion const & | a_otherQ | ) | `[inline]`

Quaternion multiplication
Multiply this quaternion with another and store result here.

Parameters:

  | a_otherQ | The other quaternion.

void cQuaternion::slerp | ( | double | a_level,
|  | cQuaternion const & | a_q1,
|  | cQuaternion | a_q2 |
| ) |  |  | `[inline]`

Spherical linear interpolation.
Spherically linearly interpolate between quaternions and store the result here.

Parameters:

  | a_level | Parameter between 0 (fully at a_q1) and 1.0 (fully at a_q2).
  | a_q1 | Starting quaternion.
  | a_q2 | Ending quaternion.

void cQuaternion::toAxisAngle | ( | cVector3d & | a_axis,
|  | double & | a_angle |
| ) |  |  | const`[inline]`

Convert to axis (not normalized) and angle.

Parameters:

  | a_axis | Where to store the axis.
  | a_angle | Where to store the angle.

void cQuaternion::toRotMat | ( | cMatrix3d & | a_mat | ) | const`[inline]`

Convert quaternion to rotation matrix.

Parameters:

  | a_mat | The matrix to store the result into.

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

- D:/CHAI3D/build-2-0-0/2.0.0/win32/src/math/CQuaternion.h

CHAI3D 2.0.0 documentation
Please address any questions to support@chai3d.org
(C) 2003-2009 - CHAI 3D
All Rights Reserved.