# QuatC

# Class hierarchy

QuatC

# Overview

QuatC class defines a quaternion class which is used by the Demopaja system. The quaternion class implements standard set of methods and overdriven operators for easy use.

This class is implemented by the system.

Header: | QuatC.h
Library: | core.lib

# Class members

`QuatC( float32 f32X float32 f32Y float32 f32Z float32 f32W );`

#### Parameters

f32X
  The X component of the quaternion. Default value 0.
f32Y
  The Y component of the quaternion. Default value 0.
f32Z
  The Z component of the quaternion. Default value 0.
f32W
  The W component of the quaternion. Default value 1.

#### Remarks

Creates a new quaternion with the values as the arguments.

`QuatC( const QuatC& rQuat );`

#### Parameters

rQuat
  Reference to the quaternion to copy.

#### Remarks

Copy constructor. Creates a new quaternion with the same values as the argument.

`void from_rot_matrix( const Matrix3C& rMat );`

#### Parameters

rMat
  Reference to the matrix to copy the rotation.

#### Remarks

Converts a matrix to quaternion and stores the result to the quaternion.

`Matrix3C to_rot_matrix() const;`

#### Return value

Rotation matrix.

#### Remarks

Converts the quaternion to matrix and returns the result.

`void from_axis_angle( const Vector3C& rVec float32 f32Angle );`

`void from_axis_angle( float32 f32X float32 f32Y float32 f32Z float32 f32Angle );`

#### Parameters

rVec
  Reference to the point specifying the axis of rotation.
f32X
  The X component of the rotation axis.
f32Y
  The X component of the rotation axis.
f32Z
  The Z component of the rotation axis.
f32Angle
  The angle of rotation.

#### Remarks

Creates quaternion from axis-angle presentation and stores the result in the quaternion.

`void to_axis_angle( Vector3C& rVec float32& f32Angle ) const;`

`void to_axis_angle( float32& f32X float32& f32Y float32& f32Z float32& f32Angle ) const;`

#### Parameters

rVec
  Reference to the point specifying the axis of rotation.
f32X
  Reference to the X component of the rotation axis.
f32Y
  Reference to the X component of the rotation axis.
f32Z
  Reference to the Z component of the rotation axis.
f32Angle
  Reference to the angle of rotation.

#### Remarks

Converts the quaternion to axis-angle presentation and stores the result to the arguments.

`QuatC operator-() const;`

#### Remarks

Negates the quaternion and returns the result.

`float32& operator[]( int32 i );`

`const float32& operator[]( int32 i ) const;`

#### Parameters

i
  Index to the component to get. Range 0..3.

#### Return value

Reference to the component pointed by the index.

#### Remarks

The index values from 0 to 3 corresponds to components X, Y, Z, and W respectively. There are two versions of this method, the first enables to assign values and the second is for retrieving the values.

`QuatC operator+( const QuatC& rQuat ) const;`

#### Remarks

Adds the quaternion specified by argument from the quaternion and returns the result.

`QuatC operator-( const QuatC& rQuat ) const;`

#### Remarks

Substracts the quaternion specified by argument from the quaternion and returns the result.

`QuatC operator*( const QuatC& rQuat ) const;`

#### Remarks

Multiplies the quaternion specified by argument from the quaternion and returns the result.

`QuatC operator/( const QuatC& rQuat ) const;`

#### Remarks

Divides the quaternion specified by argument from the quaternion and returns the result.

`QuatC operator*( float32 f32Scalar ) const;`

#### Remarks

Multiplies the quaternion by a scalar value specified by the argument and returns the result.

`friend QuatC operator*( float32 f32Scalar const QuatC& rQuat ) const;`

#### Remarks

Multiplies the quaternion by a scalar value specified by the argument and returns the result.

`bool operator==( const QuatC& rQuat ) const;`

#### Return value

True if both quaternions are equal, else false.

`bool operator!=( const QuatC& rQuat );`

#### Return value

True if both quaternions are not equal, else false.

`float32 dot( const QuatC& rQuat ) const;`

#### Remarks

Computes the quaternion dot product and returns the result.

`float32 norm() const;`

#### Return value

Return the squared-length of the quaternion.

`QuatC inverse() const;`

#### Remarks

Converts the quaternion to unit-length and inverses it and returns the result. Use this method to inverse non-unit-length quaternions.

`QuatC unit_inverse() const;`

#### Remarks

Inverses the quaternion and returns the result. Use this method to inverse unit-length quaternions.

`QuatC exp() const;`

#### Remarks

Computes the exponential of the quaternion and returns the result.

`QuatC log() const;`

#### Remarks

Computes the logarithm of the quaternion and returns the result.

`QuatC normalize() const;`

#### Remarks

Normalizes the quaternion to unit length and returns the result.

`static QuatC slerp( float32 f32T const QuatC& rQ const QuatC& rP );`

#### Parameters

f32T
  The time of interpolation. Range 0..1.
rQ
  Reference to the quaternion to interpolate from.
rP
  Reference to the quaternion to interpolate to.

#### Return value

Interpolated quaternion.

#### Remarks

Uses spherical linear interpolation to find the quaternion value between the first and the second interpolation quaternions.

Copyright © 2000 Moppi Productions