Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

SH::ShQuaternion< B, T > Class Template Reference

A Quaternion. More...

#include <ShQuaternion.hpp>

Collaboration diagram for SH::ShQuaternion< B, T >:

Collaboration graph
[legend]
List of all members.

Public Types

typedef ShHostType< T >::type HostType

Public Member Functions

 ShQuaternion ()
 Constructor for ShQuaternion.
template<ShBindingType B2>
 ShQuaternion (const ShQuaternion< B2, T > &other)
 Constructor for ShQuaternion with a quaternion as parameter.
template<ShBindingType B2>
 ShQuaternion (const ShAttrib< 4, B2, T, SH_VECTOR > &values)
 Constructor for ShQuaternion with a 4-vector as parameter.
template<ShBindingType B2, ShBindingType B3>
 ShQuaternion (const ShAttrib< 1, B2, T > &angle, const ShAttrib< 3, B3, T, SH_VECTOR > &axis)
 Constructor for ShQuaternion with an angle and axis of rotation.
template<ShBindingType B2>
 ShQuaternion (const ShMatrix< 4, 4, B2, T > &mat)
 Constructor for ShQuaternion with a rotation matrix.
template<ShBindingType B2>
ShQuaternionoperator= (const ShQuaternion< B2, T > &other)
 Definition of assignment to another quaternion.
template<ShBindingType B2>
ShQuaternionoperator+= (const ShQuaternion< B2, T > &right)
 Definition of the add-assign operation with another quaternion.
template<ShBindingType B2>
ShQuaternionoperator-= (const ShQuaternion< B2, T > &right)
 Definition of the minus-assign operation with another quaternion.
template<ShBindingType B2>
ShQuaternionoperator *= (const ShQuaternion< B2, T > &right)
 Definition of the times-assign operation with another quaternion.
template<ShBindingType B2>
ShQuaternionoperator *= (const ShAttrib< 1, B2, T > &right)
 Definition of the times-assign operation with a scalar.
template<ShBindingType B2>
ShQuaternionoperator *= (const ShAttrib< 3, B2, T, SH_VECTOR > &right)
 Definition of the times-assign operation with a 3-vector.
template<ShBindingType B2>
ShQuaternionoperator *= (const ShAttrib< 3, B2, T, SH_NORMAL > &right)
 Definition of the times-assign operation with a 3-normal.
template<ShBindingType B2>
ShQuaternion< SH_TEMP, T > operator+ (const ShQuaternion< B2, T > &q2)
 Definition of the add operation with another quaternion.
template<ShBindingType B2>
ShQuaternion< SH_TEMP, T > operator- (const ShQuaternion< B2, T > &q2)
 Definition of the subtract operation with another quaternion.
template<ShBindingType B2>
ShQuaternion< SH_TEMP, T > operator * (const ShQuaternion< B2, T > &q2)
 Definition of the multiply operation with another quaternion.
template<ShBindingType B2>
ShQuaternion< SH_TEMP, T > operator * (const ShAttrib< 1, B2, T > &c)
 Definition of the multiply operation with a scalar.
template<ShBindingType B2>
ShQuaternion< SH_TEMP, T > operator * (const ShAttrib< 3, B2, T, SH_VECTOR > &q2)
 Definition of the times operation with a 3-vector.
template<ShBindingType B2>
ShQuaternion< SH_TEMP, T > operator * (const ShAttrib< 3, B2, T, SH_NORMAL > &q2)
 Definition of the times operation with a 3-normal.
void normalize ()
 Definition of the normalize function.
void getValues (HostType values[]) const
 Definition of the getValues function.
void setUnit (bool flag)
 Definition of the setUnit function.
void name (const std::string &name)
 Definition of the name function.
std::string name () const
 Definition of the name function.
template<ShBindingType B2>
ShAttrib< 1, SH_TEMP, T > dot (const ShQuaternion< B2, T > &q) const
 Definition of the dot function.
ShQuaternion< SH_TEMP, T > conjugate () const
 Definition of the conjugate function.
ShQuaternion< SH_TEMP, T > inverse () const
 Definition of the inverse function.
ShMatrix< 4, 4, SH_TEMP, T > getMatrix () const
 Definition of the getMatrix function.
ShAttrib< 4, SH_TEMP, T, SH_VECTOR > getVector () const
 Definition of the getVector function.

Friends

template<ShBindingType B2, typename T2>
std::ostream & operator<< (std::ostream &out, const ShQuaternion< B2, T2 > &q)

Detailed Description

template<ShBindingType B, typename T = float>
class SH::ShQuaternion< B, T >

A Quaternion.

Definition at line 35 of file ShQuaternion.hpp.


Constructor & Destructor Documentation

template<ShBindingType B, typename T>
SH::ShQuaternion< B, T >::ShQuaternion  ) 
 

Constructor for ShQuaternion.

Creates a identity ShQuaternion

Definition at line 28 of file ShQuaternionImpl.hpp.

template<ShBindingType B, typename T>
template<ShBindingType B2>
SH::ShQuaternion< B, T >::ShQuaternion const ShQuaternion< B2, T > &  other  ) 
 

Constructor for ShQuaternion with a quaternion as parameter.

Creates a ShQuaternion where each element is equal to the one in the parameters

Parameters:
other the quaternion from which we will get the values from

Definition at line 39 of file ShQuaternionImpl.hpp.

template<ShBindingType B, typename T>
template<ShBindingType B2>
SH::ShQuaternion< B, T >::ShQuaternion const ShAttrib< 4, B2, T, SH_VECTOR > &  values  ) 
 

Constructor for ShQuaternion with a 4-vector as parameter.

Creates a ShQuaternion where each element is equal to the one in the parameters

Parameters:
values 4-vector from which we will get the values from

Definition at line 46 of file ShQuaternionImpl.hpp.

template<ShBindingType B, typename T>
template<ShBindingType B2, ShBindingType B3>
SH::ShQuaternion< B, T >::ShQuaternion const ShAttrib< 1, B2, T > &  angle,
const ShAttrib< 3, B3, T, SH_VECTOR > &  axis
 

Constructor for ShQuaternion with an angle and axis of rotation.

Creates a unit ShQuaternion defined by a rotation

Parameters:
angle angle in radians of the rotation
axis axis of rotation

Definition at line 53 of file ShQuaternionImpl.hpp.

References SH::cos(), SH::normalize(), and SH::sin().

template<ShBindingType B, typename T>
template<ShBindingType B2>
SH::ShQuaternion< B, T >::ShQuaternion const ShMatrix< 4, 4, B2, T > &  mat  ) 
 

Constructor for ShQuaternion with a rotation matrix.

Creates a unit ShQuaternion defined by a rotation

Parameters:
mat matrix defining the rotation
Precondition:
det(mat) = 1

Definition at line 64 of file ShQuaternionImpl.hpp.

References SH::sqrt(), and SH::trace().


Member Function Documentation

template<ShBindingType B, typename T>
ShQuaternion< SH_TEMP, T > SH::ShQuaternion< B, T >::conjugate  )  const
 

Definition of the conjugate function.

Returns the conjugate of this quaternion

Definition at line 214 of file ShQuaternionImpl.hpp.

Referenced by SH::ShQuaternion< B, T >::inverse().

template<ShBindingType B, typename T>
template<ShBindingType B2>
ShAttrib< 1, SH_TEMP, T > SH::ShQuaternion< B, T >::dot const ShQuaternion< B2, T > &  q  )  const
 

Definition of the dot function.

Returns the dot product between this quaternion and q

Parameters:
q quaternion we're taking the dot product with

Definition at line 208 of file ShQuaternionImpl.hpp.

References SH::dot(), and SH::ShQuaternion< B, T >::getVector().

Referenced by SH::slerp().

template<ShBindingType B, typename T>
ShMatrix< 4, 4, SH_TEMP, T > SH::ShQuaternion< B, T >::getMatrix  )  const
 

Definition of the getMatrix function.

Returns the rotation matrix defined by this quaternion

Precondition:
this quaternion is unit

Definition at line 236 of file ShQuaternionImpl.hpp.

template<ShBindingType B, typename T>
void SH::ShQuaternion< B, T >::getValues HostType  values[]  )  const
 

Definition of the getValues function.

Outputs the current content of the quaternion as a T array

Parameters:
values output T array

Definition at line 331 of file ShQuaternionImpl.hpp.

References SH::ShGeneric< N, T >::getValues().

template<ShBindingType B, typename T>
ShAttrib< 4, SH_TEMP, T, SH_VECTOR > SH::ShQuaternion< B, T >::getVector  )  const
 

Definition of the getVector function.

Returns the values of this quaternion as a vector

Definition at line 259 of file ShQuaternionImpl.hpp.

Referenced by SH::ShQuaternion< B, T >::dot(), SH::ShQuaternion< B, T >::operator *=(), SH::ShQuaternion< B, T >::operator+=(), SH::ShQuaternion< B, T >::operator-=(), and SH::ShQuaternion< B, T >::operator=().

template<ShBindingType B, typename T>
ShQuaternion< SH_TEMP, T > SH::ShQuaternion< B, T >::inverse  )  const
 

Definition of the inverse function.

Returns the inverse of this quaternion (same as conjugate if unit)

Definition at line 225 of file ShQuaternionImpl.hpp.

References SH::ShQuaternion< B, T >::conjugate(), and SH::dot().

template<ShBindingType B, typename T>
std::string SH::ShQuaternion< B, T >::name  )  const
 

Definition of the name function.

Returns this variable's name.

Definition at line 362 of file ShQuaternionImpl.hpp.

References SH::ShMetaForwarder::name().

template<ShBindingType B, typename T>
void SH::ShQuaternion< B, T >::name const std::string &  name  ) 
 

Definition of the name function.

Set this variable's name. If set to the empty string, defaults to the type and id of the variable.

Parameters:
name the name string

Definition at line 368 of file ShQuaternionImpl.hpp.

References SH::ShMetaForwarder::name().

template<ShBindingType B, typename T>
void SH::ShQuaternion< B, T >::normalize  ) 
 

Definition of the normalize function.

Normalizes the current quaternion which makes it unit

Definition at line 319 of file ShQuaternionImpl.hpp.

References SH::normalize().

template<ShBindingType B, typename T = float>
template<ShBindingType B2>
ShQuaternion<SH_TEMP, T> SH::ShQuaternion< B, T >::operator * const ShAttrib< 3, B2, T, SH_NORMAL > &  q2  ) 
 

Definition of the times operation with a 3-normal.

Returns a new ShQuaternion equals to the current quaternion * ShQuaternion(0.0, right)

Parameters:
q2 3-normal converted to a quaternion multiplied to this one

template<ShBindingType B, typename T>
template<ShBindingType B2>
ShQuaternion< SH_TEMP, T > SH::ShQuaternion< B, T >::operator * const ShAttrib< 3, B2, T, SH_VECTOR > &  q2  ) 
 

Definition of the times operation with a 3-vector.

Returns a new ShQuaternion equals to the current quaternion * ShQuaternion(0.0, right)

Parameters:
q2 3-vector converted to a quaternion multiplied to this one

Definition at line 303 of file ShQuaternionImpl.hpp.

template<ShBindingType B, typename T>
template<ShBindingType B2>
ShQuaternion< SH_TEMP, T > SH::ShQuaternion< B, T >::operator * const ShAttrib< 1, B2, T > &  c  ) 
 

Definition of the multiply operation with a scalar.

Returns a new ShQuaternion equals to the current quaternion * c

Parameters:
c the scalar multiplied to this one

Definition at line 294 of file ShQuaternionImpl.hpp.

template<ShBindingType B, typename T>
template<ShBindingType B2>
ShQuaternion< SH_TEMP, T > SH::ShQuaternion< B, T >::operator * const ShQuaternion< B2, T > &  q2  ) 
 

Definition of the multiply operation with another quaternion.

Returns a new ShQuaternion equals to the current quaternion * q2

Parameters:
q2 the other quaternion multiplied to this one

Definition at line 285 of file ShQuaternionImpl.hpp.

template<ShBindingType B, typename T = float>
template<ShBindingType B2>
ShQuaternion& SH::ShQuaternion< B, T >::operator *= const ShAttrib< 3, B2, T, SH_NORMAL > &  right  ) 
 

Definition of the times-assign operation with a 3-normal.

Returns the address of a quaternion where the result is the current quaternion * ShQuaternion(0.0, right)

Parameters:
right 3-normal converted to a quaternion multiplied to this one

template<ShBindingType B, typename T>
template<ShBindingType B2>
ShQuaternion< B, T > & SH::ShQuaternion< B, T >::operator *= const ShAttrib< 3, B2, T, SH_VECTOR > &  right  ) 
 

Definition of the times-assign operation with a 3-vector.

Returns the address of a quaternion where the result is the current quaternion * ShQuaternion(0.0, right)

Parameters:
right 3-vector converted to a quaternion multiplied to this one

Definition at line 182 of file ShQuaternionImpl.hpp.

template<ShBindingType B, typename T>
template<ShBindingType B2>
ShQuaternion< B, T > & SH::ShQuaternion< B, T >::operator *= const ShAttrib< 1, B2, T > &  right  ) 
 

Definition of the times-assign operation with a scalar.

Returns the address of a quaternion where the result is the current quaternion (each component) multiplied by right

Parameters:
right the scalar multiplied to this quaternion

Definition at line 173 of file ShQuaternionImpl.hpp.

template<ShBindingType B, typename T>
template<ShBindingType B2>
ShQuaternion< B, T > & SH::ShQuaternion< B, T >::operator *= const ShQuaternion< B2, T > &  right  ) 
 

Definition of the times-assign operation with another quaternion.

Returns the address of a quaternion where the result is the current quaternion * right

Parameters:
right the other quaternion multiplied to this one

Definition at line 155 of file ShQuaternionImpl.hpp.

References SH::cross(), SH::dot(), and SH::ShQuaternion< B, T >::getVector().

template<ShBindingType B, typename T>
template<ShBindingType B2>
ShQuaternion< SH_TEMP, T > SH::ShQuaternion< B, T >::operator+ const ShQuaternion< B2, T > &  q2  ) 
 

Definition of the add operation with another quaternion.

Returns a new ShQuaternion equals to the current quaternion + q2

Parameters:
q2 the other quaternion added to this one

Definition at line 267 of file ShQuaternionImpl.hpp.

template<ShBindingType B, typename T>
template<ShBindingType B2>
ShQuaternion< B, T > & SH::ShQuaternion< B, T >::operator+= const ShQuaternion< B2, T > &  right  ) 
 

Definition of the add-assign operation with another quaternion.

Returns the address of a quaternion where the result is the current quaternion + right

Parameters:
right the other quaternion added to this one

Definition at line 137 of file ShQuaternionImpl.hpp.

References SH::ShQuaternion< B, T >::getVector().

template<ShBindingType B, typename T>
template<ShBindingType B2>
ShQuaternion< SH_TEMP, T > SH::ShQuaternion< B, T >::operator- const ShQuaternion< B2, T > &  q2  ) 
 

Definition of the subtract operation with another quaternion.

Returns a new ShQuaternion equals to the current quaternion - q2

Parameters:
q2 the other quaternion subtracted from this one

Definition at line 276 of file ShQuaternionImpl.hpp.

template<ShBindingType B, typename T>
template<ShBindingType B2>
ShQuaternion< B, T > & SH::ShQuaternion< B, T >::operator-= const ShQuaternion< B2, T > &  right  ) 
 

Definition of the minus-assign operation with another quaternion.

Returns the address of a quaternion where the result is the current quaternion - right

Parameters:
right the other quaternion subtracted from this one

Definition at line 146 of file ShQuaternionImpl.hpp.

References SH::ShQuaternion< B, T >::getVector().

template<ShBindingType B, typename T>
template<ShBindingType B2>
ShQuaternion< B, T > & SH::ShQuaternion< B, T >::operator= const ShQuaternion< B2, T > &  other  ) 
 

Definition of assignment to another quaternion.

Returns the address of a quaternion from which the values were copied from other

Parameters:
other ShQuaternion from which we will get the values from

Definition at line 128 of file ShQuaternionImpl.hpp.

References SH::ShQuaternion< B, T >::getVector().

template<ShBindingType B, typename T>
void SH::ShQuaternion< B, T >::setUnit bool  flag  ) 
 

Definition of the setUnit function.

Manually indicate whether the quaternion is unit or non-unit

Parameters:
flag true or false

Definition at line 325 of file ShQuaternionImpl.hpp.


The documentation for this class was generated from the following files:
Generated on Wed Jun 15 18:16:03 2005 for Sh by  doxygen 1.4.3-20050530