- Main Page
- Classes
- Files
- Directories

- Class List
- Class Hierarchy
- Class Members

# cQuaternion Class Reference

cQuaternion represents rotations in quaternion form More...

`#include <CQuaternion.h>`

List of all members.

## Public Member Functions
| cQuaternion ()
| operator double * ()
| Cast to a double*.
void | zero ()
| Clear vector with zeros.
void | negate ()
| Negate current quaternion. Result is stored in current quaternion.
double | magsq () const
| Returns magnitude squared.
double | lengthsq () const
| Returns magnitude squared.
double | mag () const
| Returns magnitude.
double | length () const
| Returns magnitude.
void | normalize ()
| Normalize.
void | toRotMat (cMatrix3d &a_mat) const
| Convert to rotation matrix.
void | fromRotMat (cMatrix3d const &a_mat)
| Convert rotation matrix to quaternion.
void | fromAxisAngle (cVector3d a_axis, double a_angle)
| Convert from axis and angle (in radians).
void | toAxisAngle (cVector3d &a_axis, double &a_angle) const
| Convert to axis (not normalized) and angle.
void | conj ()
| Conjugate.
void | invert ()
| Invert ( inverse is conjugate/magsq ).
cQuaternion & | operator *= (cQuaternion const &a_otherQ)
| Multiply operator (grassman product).
void | mul (cQuaternion const &a_otherQ)
| Quaternion multiplication.
cQuaternion & | operator *= (double a_scale)
| Scale operator.
void | mul (double s)
| Scale.
bool | operator== (cQuaternion const &a_otherQ) const
| Equality operator.
double | dot (cQuaternion const &a_otherQ) const
| Dot product.
cQuaternion & | operator+= (cQuaternion const &a_otherQ)
| Addition.
void | add (cQuaternion const &a_otherQ)
| Addition.
void | slerp (double a_level, cQuaternion const &a_q1, cQuaternion a_q2)
| Spherical linear interpolation.
## 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 represents rotations in quaternion form

## Constructor & Destructor Documentation

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

Constructors of cVector3d.

You can initialize a cVector3d from any of the following:

double,double,double,double double*

Also the default copy constructor will work

## Member Function Documentation

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

Convert to rotation matrix.

Parameters:

  | a_mat | The matrix to store the result into

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

Convert rotation matrix to quaternion.

Parameters:

  | a_mat | The rotation matrix to convert

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::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::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::mul | ( | double | s | ) | `[inline]`

Scale.

Scale this quaternion by a scalar

Parameters:

  | a_scale | The scalar

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::add | ( | cQuaternion const & | a_otherQ | ) | `[inline]`

Addition.

Add another quaternion to this one and store 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

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

- chai3d/src/math/CQuaternion.h