A 3D Dynamic Geometry Software

Calques 3D C++



unitquaternion Class Reference

Inheritance diagram for unitquaternion:

Inheritance graph
Collaboration diagram for unitquaternion:

Collaboration graph

List of all members.


Detailed Description

A unit lenght quaternion class.

The unitquaternion class manages quaternions of unit length, such quaternions can be used to represent arbitrary rotations. To mantain the unit lenght property along quaternion calculus addition and subtraction as well as multiplication and division by scalars are not allowed (they're made private or they're overloaded by "trap" functions).

Actually only a few member functions of the base class are overloaded since the quaternion calculus apply with no modification to unit quaternions.


Public Member Functions

real x () const
 accessor for the x component of the vector part
real y () const
 accessor for the y component of the vector part
real z () const
 accessor for the z component of the vector part
real w () const
 accessor for the scalar part
real scalarPart () const
 other accessor for the scalar component
vector vectorPart () const
 accessor for the vector part
 unitquaternion ()
 default constructor
 unitquaternion (const real &angle, const vector &axis)
 constructs a unitquaternion representing a rotation of angle radiants about axis
 unitquaternion (const quaternion &q)
 constructs a unitquaternion from a generic one (conversion by normalizing)
 ~unitquaternion ()
 the distructor
unitquaternion inversed () const
 inversed copy of the unitquaternion
void inverse ()
 inverse of the unitquaternion
tmatrix getRotMatrix ()
void getVectorsOnSphere (vector &vfrom, vector &vto)
unitquaternion & operator *= (const unitquaternion &other)
 multiply by another unitquaternion & assign is not allowed

Private Member Functions

unitquaternion & operator+= (const unitquaternion &other)
 sum & assign is not allowed
unitquaternion & operator-= (const unitquaternion &other)
 subtract & assign is not allowed
unitquaternion & operator *= (const real &fact)
 multiply by a scalar factor & assign is not allowed
unitquaternion & operator/= (const real &fact)
 divide by a scalar factor & assign is not allowed
 unitquaternion (const vector &v, const real &s)
 constructs a unitquaternion assigning directly the scalar and vector parts

Friends

unitquaternion operator+ (const unitquaternion &q1, const unitquaternion &q2)
 the sum is not allowed
unitquaternion operator- (const unitquaternion &q1, const unitquaternion &q2)
 the difference is not allowed
unitquaternion operator * (const unitquaternion &q, const real &s)
 multiply a unitquaternion by a scalar is not allowed
unitquaternion operator * (const real &s, const unitquaternion &q)
 multiply a scalar by a unitquaternion is not allowed
unitquaternion operator/ (const unitquaternion &q, const real &s)
 divide a unitquaternion by a scalar factor is not allowed

Constructor & Destructor Documentation

unitquaternion ( const vector &  v,
const real &  s 
) [inline, private]

constructs a unitquaternion assigning directly the scalar and vector parts

This constructor has been introduced exclusively to make the inversed function more efficient by avoiding too many unitquaternion copies and conversions to quaternions.

unitquaternion (  )  [inline]

default constructor

unitquaternion ( const real &  angle,
const vector &  axis 
) [inline]

constructs a unitquaternion representing a rotation of angle radiants about axis

This constructor has a different meaning from the same in the base class. Here the vector means an axis of rotation while the real means the angle to rotate about the axis.

NOTE: the angle and axis vector are not directly assigned to the real part and the vector part, respectively, of the quaternion. The unit quaternion (s,v) represents a rotation of angle radians about the axis a if:

s = cos(angle / 2)
v = a * sin( angle / 2)

Parameters:
angle the rotation angle
axis the axis of rotation
Date:
18/06/99

unitquaternion ( const quaternion &  q  )  [inline]

constructs a unitquaternion from a generic one (conversion by normalizing)

~unitquaternion (  )  [inline]

the distructor


Member Function Documentation

unitquaternion& operator+= ( const unitquaternion &  other  )  [private]

sum & assign is not allowed

unitquaternion& operator-= ( const unitquaternion &  other  )  [private]

subtract & assign is not allowed

unitquaternion& operator *= ( const real &  fact  )  [private]

multiply by a scalar factor & assign is not allowed

Reimplemented from quaternion.

unitquaternion& operator/= ( const real &  fact  )  [private]

divide by a scalar factor & assign is not allowed

Reimplemented from quaternion.

real x (  )  const [inline]

accessor for the x component of the vector part

This function overrides the same in base class to prevent the use as an l-value (that is to modify the x component of the vector part).

real y (  )  const [inline]

accessor for the y component of the vector part

This function overrides the same in base class to prevent the use as an l-value (that is to modify the y component of the vector part).

real z (  )  const [inline]

accessor for the z component of the vector part

This function overrides the same in base class to prevent the use as an l-value (that is to modify the z component of the vector part).

real w (  )  const [inline]

accessor for the scalar part

This function overrides the same in base class to prevent the use as an l-value (that is to modify the scalar part).

real scalarPart (  )  const [inline]

other accessor for the scalar component

This function overrides the same in base class to prevent the use as an l-value (that is to modify the scalar part).

vector vectorPart (  )  const [inline]

accessor for the vector part

This function overrides the same in base class to prevent the use as an l-value (that is to modify the vector part).

unitquaternion inversed (  )  const [inline]

inversed copy of the unitquaternion

For unitquaternions the inverse equals the conjugate (which is simpler to calculate) This function doesn't modifies the quaternion upon which has been called, it returns a new quaternion instead.

Returns:
the normalized copy of the quaternion
Date:
18/06/99

Reimplemented from quaternion.

void inverse (  )  [inline]

inverse of the unitquaternion

For unitquaternions the inverse equals the conjugate (which is simpler to calculate). The function doesn't call the base conjugate function to avoid an expensive quaternion to unitquaternion conversion. This function modifies the quaternion upon which has been called.

Reimplemented from quaternion.

tmatrix getRotMatrix (  )  [virtual]

The generated rotation matrix is OpenGL compatible, it is intended to be post-multiplied to the current trasformation matrix to achieve the rotation.

Returns:
the rotation matrix

Reimplemented from quaternion.

void getVectorsOnSphere ( vector &  vfrom,
vector &  vto 
)

the rotation represented by the unitquaternion would transform the first vector into the second. The vectors are of unit length (so they are placed on a unit sphere)

Parameters:
vfrom the first vector
vto the second vector

unitquaternion & operator *= ( const unitquaternion &  other  ) 

multiply by another unitquaternion & assign is not allowed


Friends And Related Function Documentation

unitquaternion operator+ ( const unitquaternion &  q1,
const unitquaternion &  q2 
) [friend]

the sum is not allowed

This function has been defined to trap the use of an operation which is not allowed

unitquaternion operator- ( const unitquaternion &  q1,
const unitquaternion &  q2 
) [friend]

the difference is not allowed

This function has been defined to trap the use of an operation which is not allowed

unitquaternion operator * ( const unitquaternion &  q,
const real &  s 
) [friend]

multiply a unitquaternion by a scalar is not allowed

This function has been defined to trap the use of an operation which is not allowed

unitquaternion operator * ( const real &  s,
const unitquaternion &  q 
) [friend]

multiply a scalar by a unitquaternion is not allowed

This function has been defined to trap the use of an operation which is not allowed

unitquaternion operator/ ( const unitquaternion &  q,
const real &  s 
) [friend]

divide a unitquaternion by a scalar factor is not allowed

This function has been defined to trap the use of an operation which is not allowed