PARP Research Group Universidad de Murcia


QVQuaternion Class Reference
[Math functionality]

Implementation of quaternions. More...

#include <QVQuaternion>

Inherits QVVector.

List of all members.

Public Member Functions

 QVQuaternion ()
 Identity constructor.
 QVQuaternion (const QVVector direction, const double phi)
 Axis rotation constructor.
 QVQuaternion (const QVVector &source)
 Construct from a vector.
 QVQuaternion (const QVVector direction, float phi)
 Axis rotation constructor.
 QVQuaternion (const double i, const double j, const double k, const double r)
 Direct coordinates constructor.
 QVQuaternion (const double xAngle, const double yAngle, const double zAngle)
 Constructor from 3 euler angles.
 QVQuaternion (const QVMatrix &matrix)
 Rotation matrix constructor.
QVQuaternion operator* (const QVQuaternion &quaternion) const
 Quaternion product.
 QVQuaternion (const QVQuaternion &quaternion)
 Copy constructor.
QVQuaternion quaternionProduct (const QVQuaternion &quaternion) const
 Combination operation for quaternions.
void toEulerAngles (double &xAngle, double &yAngle, double &zAngle) const
 Gets the Euler angles corresponding to the Quaternion.
QVMatrix toRotationMatrix () const
 Gets the rotation matrix corresponding to the Quaternion.
QVQuaternion conjugate () const
 Gets the conjugate of the quaternion.
QVQuaternion inverse () const
 Gets the inverse of the quaternion.
double norm2 () const
 Gets the norm2 of the quaternion.
QV3DPointF rotate (const QV3DPointF &v) const
 Direct vector rotation.
double & real ()
 Returns the coordinate for the real component of the cuaternion.
double & i ()
 Returns the coordinate i of the cuaternion.
double & j ()
 Returns the coordinate j of the cuaternion.
double & k ()
 Returns the coordinate k of the cuaternion.
double real () const
 Sets the coordinate for the real component of the cuaternion.
double i () const
 Sets the coordinate i of the cuaternion.
double j () const
 Sets the coordinate j of the cuaternion.
double k () const
 Sets the coordinate k of the cuaternion.
QVQuaternion normalizeQuaternion () const
 Retuns a normalized quaternion.

Static Public Member Functions

static QVQuaternion trackball (float p1x, float p1y, float p2x, float p2y)
 Gets the quaternion corresponding to a trackball rotation.

Detailed Description

Implementation of quaternions.

Quaternions are an extension of the imaginary numbers. They are mostly used to represent rotations in the euclidean 3D space.

Definition at line 44 of file qvquaternion.h.


Constructor & Destructor Documentation

QVQuaternion::QVQuaternion (  ) 

Identity constructor.

Creates quaternion to identity rotation.

Definition at line 32 of file qvquaternion.cpp.

Referenced by QVQuaternion(), and trackball().

QVQuaternion::QVQuaternion ( const QVVector  direction,
const double  phi 
)

Axis rotation constructor.

Creates a quaternion object which rotates around a direction a given angle.

Parameters:
direction quaternion will rotate around this direction.
phi quaternion will rotate this angle, given in radians.

Definition at line 39 of file qvquaternion.cpp.

QVQuaternion::QVQuaternion ( const QVVector source  )  [inline]

Construct from a vector.

Creates a quaternion from a vector of size 4.

Parameters:
source The vector of size 4.

Definition at line 68 of file qvquaternion.h.

QVQuaternion::QVQuaternion ( const QVVector  direction,
float  phi 
)

Axis rotation constructor.

Creates a quaternion object which rotates around a direction a given angle.

Parameters:
direction quaternion will rotate around this direction.
phi quaternion will rotate this angle, given in radians.
QVQuaternion::QVQuaternion ( const double  i,
const double  j,
const double  k,
const double  r 
)

Direct coordinates constructor.

Creates a quaternion from its coordinate coefficients.

Parameters:
i Coefficient for the i coordinate
j Coefficient for the j coordinate
k Coefficient for the k coordinate
r Coefficient for the real coordinate

Definition at line 147 of file qvquaternion.cpp.

QVQuaternion::QVQuaternion ( const double  xAngle,
const double  yAngle,
const double  zAngle 
)

Constructor from 3 euler angles.

Creates a quaternion given the three euler angles of the rotation it represents.

Parameters:
xAngle Euler angle for the x axis.
yAngle Euler angle for the y axis.
zAngle Euler angle for the z axis.

Definition at line 158 of file qvquaternion.cpp.

QVQuaternion::QVQuaternion ( const QVMatrix matrix  ) 

Rotation matrix constructor.

Creates a quaternion from a rotation matrix.

Parameters:
matrix rotation matrix to create the quaternion from

Definition at line 52 of file qvquaternion.cpp.

QVQuaternion::QVQuaternion ( const QVQuaternion quaternion  )  [inline]

Copy constructor.

Creates a quaternion copying its coordinates from a given one.

Parameters:
quaternion quaternion to copy coordinates

Definition at line 114 of file qvquaternion.h.


Member Function Documentation

QVQuaternion QVQuaternion::operator* ( const QVQuaternion quaternion  )  const [inline]

Quaternion product.

Parameters:
quaternion operand for the product
See also:
quaternionProduct

Definition at line 107 of file qvquaternion.h.

QVQuaternion QVQuaternion::trackball ( float  p1x,
float  p1y,
float  p2x,
float  p2y 
) [static]

Gets the quaternion corresponding to a trackball rotation.

Creates a quaternion which rotates given two points at a plane, mapped to a sphere.

Parameters:
p1x first coordinate for first point.
p1y second coordinate for first point.
p2x first coordinate for second point.
p2y second coordinate for second point.
Returns:
quaternion corresponding to rotate in a sphere from point (p1x, p1y) to (p2x, p2y). corresponding to this quaternion, and at element (4,4), the unity.

Definition at line 186 of file qvquaternion.cpp.

QVQuaternion QVQuaternion::quaternionProduct ( const QVQuaternion quaternion  )  const

Combination operation for quaternions.

Creates a quaternion corresponding to combination of rotations corresponding to actual quaternion and the one received by parameter

Parameters:
quaternion operand in the combining operation.
Returns:
resulting quaternion.

Definition at line 218 of file qvquaternion.cpp.

Referenced by operator*().

void QVQuaternion::toEulerAngles ( double &  xAngle,
double &  yAngle,
double &  zAngle 
) const

Gets the Euler angles corresponding to the Quaternion.

Parameters:
xAxis Return variable that will contain the rotation in the x angle for the quaternion.
yAxis Return variable that will contain the rotation in the y angle for the quaternion.
zAxis Return variable that will contain the rotation in the z angle for the quaternion.

Definition at line 234 of file qvquaternion.cpp.

QVMatrix QVQuaternion::toRotationMatrix (  )  const

Gets the rotation matrix corresponding to the Quaternion.

Returns:
rotation matrix

Definition at line 253 of file qvquaternion.cpp.

Referenced by QVMatrix::QVMatrix(), QVCameraPose::toProjectionMatrix(), and QVEuclideanMapping3::toRotationTranslationMatrix().

QVQuaternion QVQuaternion::conjugate (  )  const

Gets the conjugate of the quaternion.

Returns:
The conjugate quaternion.

Definition at line 280 of file qvquaternion.cpp.

Referenced by inverse(), and rotate().

QVQuaternion QVQuaternion::inverse (  )  const

Gets the inverse of the quaternion.

Returns:
The inverse quaternion.

Definition at line 290 of file qvquaternion.cpp.

Referenced by QVCameraPose::compose(), QVEuclideanMapping3::inverse(), and QVCameraPose::inverse().

QV3DPointF QVQuaternion::rotate ( const QV3DPointF v  )  const
double& QVQuaternion::real (  )  [inline]

Returns the coordinate for the real component of the cuaternion.

Definition at line 172 of file qvquaternion.h.

Referenced by QVQuaternion().

double& QVQuaternion::i (  )  [inline]

Returns the coordinate i of the cuaternion.

Definition at line 175 of file qvquaternion.h.

Referenced by normalizeQuaternion(), and QVQuaternion().

double& QVQuaternion::j (  )  [inline]

Returns the coordinate j of the cuaternion.

Definition at line 178 of file qvquaternion.h.

Referenced by QVQuaternion().

double& QVQuaternion::k (  )  [inline]

Returns the coordinate k of the cuaternion.

Definition at line 181 of file qvquaternion.h.

Referenced by QVQuaternion().

double QVQuaternion::real (  )  const [inline]

Sets the coordinate for the real component of the cuaternion.

Definition at line 184 of file qvquaternion.h.

double QVQuaternion::i (  )  const [inline]

Sets the coordinate i of the cuaternion.

Definition at line 187 of file qvquaternion.h.

double QVQuaternion::j (  )  const [inline]

Sets the coordinate j of the cuaternion.

Definition at line 190 of file qvquaternion.h.

double QVQuaternion::k (  )  const [inline]

Sets the coordinate k of the cuaternion.

Definition at line 193 of file qvquaternion.h.

QVQuaternion QVQuaternion::normalizeQuaternion (  )  const

Retuns a normalized quaternion.

Definition at line 207 of file qvquaternion.cpp.


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



QVision framework. PARP research group. Copyright © 2007, 2008, 2009, 2010, 2011.