Public Types | Public Member Functions | Public Attributes

gmtl::Quat< DATA_TYPE > Class Template Reference
[Abstract Data Types: Matrix, Vec, Quat, Coord, Sphere, Plane]

Quat: Class to encapsulate quaternion behaviors. More...

#include <Quat.h>

Collaboration diagram for gmtl::Quat< DATA_TYPE >:
Collaboration graph
[legend]

List of all members.

Public Types

enum  Params { Size = 4 }
typedef DATA_TYPE DataType
 use this to declare single value types of the same type as this matrix.

Public Member Functions

 Quat ()
 default constructor, initializes to quaternion multiplication identity [x,y,z,w] == [0,0,0,1].
 Quat (const DATA_TYPE &x, const DATA_TYPE &y, const DATA_TYPE &z, const DATA_TYPE &w)
 data constructor, initializes to quaternion multiplication identity [x,y,z,w] == [0,0,0,1].
 Quat (const Quat< DATA_TYPE > &q)
 copy constructor
void set (const DATA_TYPE x, const DATA_TYPE y, const DATA_TYPE z, const DATA_TYPE w)
 directly set the quaternion's values
void get (DATA_TYPE &x, DATA_TYPE &y, DATA_TYPE &z, DATA_TYPE &w) const
 get the raw data elements of the quaternion.
DATA_TYPE & operator[] (const int x)
 bracket operator.
const DATA_TYPE & operator[] (const int x) const
 bracket operator (const version).
const DATA_TYPE * getData () const
 Get a DATA_TYPE pointer to the quat internal data.

Public Attributes

Vec< DATA_TYPE, 4 > mData

Detailed Description

template<typename DATA_TYPE>
class gmtl::Quat< DATA_TYPE >

Quat: Class to encapsulate quaternion behaviors.

this Quaternion is ordered in memory: x,y,z,w.

See also:
Quatf
Quatd

Note: The code for most of these routines was built using the following references

References:

Definition at line 47 of file Quat.h.


Member Typedef Documentation

template<typename DATA_TYPE>
typedef DATA_TYPE gmtl::Quat< DATA_TYPE >::DataType

use this to declare single value types of the same type as this matrix.

Definition at line 52 of file Quat.h.


Member Enumeration Documentation

template<typename DATA_TYPE>
enum gmtl::Quat::Params
Enumerator:
Size 

Definition at line 54 of file Quat.h.

{ Size = 4 };


Constructor & Destructor Documentation

template<typename DATA_TYPE>
gmtl::Quat< DATA_TYPE >::Quat (  )  [inline]

default constructor, initializes to quaternion multiplication identity [x,y,z,w] == [0,0,0,1].

NOTE: the addition identity is [0,0,0,0]

Definition at line 60 of file Quat.h.

      : mData( (DATA_TYPE)0.0, (DATA_TYPE)0.0, (DATA_TYPE)0.0, (DATA_TYPE)1.0 )
   {
   }

template<typename DATA_TYPE>
gmtl::Quat< DATA_TYPE >::Quat ( const DATA_TYPE &  x,
const DATA_TYPE &  y,
const DATA_TYPE &  z,
const DATA_TYPE &  w 
) [inline]

data constructor, initializes to quaternion multiplication identity [x,y,z,w] == [0,0,0,1].

NOTE: the addition identity is [0,0,0,0]

Definition at line 69 of file Quat.h.

      : mData( x, y, z, w )
   {
   }

template<typename DATA_TYPE>
gmtl::Quat< DATA_TYPE >::Quat ( const Quat< DATA_TYPE > &  q  )  [inline]

copy constructor

Definition at line 77 of file Quat.h.

                                    : mData( q.mData )
   {
   }


Member Function Documentation

template<typename DATA_TYPE>
void gmtl::Quat< DATA_TYPE >::get ( DATA_TYPE &  x,
DATA_TYPE &  y,
DATA_TYPE &  z,
DATA_TYPE &  w 
) const [inline]

get the raw data elements of the quaternion.

Postcondition:
sets the given variables to the quaternion's x, y, z, and w values

Definition at line 93 of file Quat.h.

   {
      x = mData[Xelt];
      y = mData[Yelt];
      z = mData[Zelt];
      w = mData[Welt];
   }

template<typename DATA_TYPE>
const DATA_TYPE* gmtl::Quat< DATA_TYPE >::getData (  )  const [inline]

Get a DATA_TYPE pointer to the quat internal data.

Postcondition:
Returns a ptr to the head of the quat data

Definition at line 141 of file Quat.h.

{ return (DATA_TYPE*)mData.getData();}

template<typename DATA_TYPE>
const DATA_TYPE& gmtl::Quat< DATA_TYPE >::operator[] ( const int  x  )  const [inline]

bracket operator (const version).

raw data accessor.

"Example (access raw data element in a Quat):"

    Quatf q;
    float rads = acos( q[Welt] ) / 2.0f;
See also:
VectorIndex

Definition at line 132 of file Quat.h.

   {
      gmtlASSERT( x >= 0 && x < 4 && "out of bounds error" );
      return mData[x];
   }

template<typename DATA_TYPE>
DATA_TYPE& gmtl::Quat< DATA_TYPE >::operator[] ( const int  x  )  [inline]

bracket operator.

raw data accessor.

"Example (access raw data element in a Quat):"

    Quatf q;
    q[Xelt] = 0.001231176f;
    q[Yelt] = 0.1222f;
    q[Zelt] = 0.721f;
    q[Welt] = 0.982323f;
See also:
VectorIndex

Definition at line 115 of file Quat.h.

   {
      gmtlASSERT( x >= 0 && x < 4 && "out of bounds error" );
      return mData[x];
   }

template<typename DATA_TYPE>
void gmtl::Quat< DATA_TYPE >::set ( const DATA_TYPE  x,
const DATA_TYPE  y,
const DATA_TYPE  z,
const DATA_TYPE  w 
) [inline]

directly set the quaternion's values

Precondition:
x,y,z,w should be normalized
Postcondition:
the quaternion is set with the given values

Definition at line 85 of file Quat.h.

   {
      mData.set( x, y, z, w );
   }


Member Data Documentation

template<typename DATA_TYPE>
Vec<DATA_TYPE, 4> gmtl::Quat< DATA_TYPE >::mData

Definition at line 145 of file Quat.h.


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