Main Page | Packages | Class Hierarchy | Class List | Directories | Class Members

IDVR.Tools.ArcBall Class Reference

#include <ArcBall.h>

List of all members.


Detailed Description

Class for handling object rotation by calculating rotaton angle out of mouse movement.

This class is part of the Tools namespace and the main goal is the claculation of a rotation matrix based on arbitrary mouse movement of the user.

The idea is that if the user moves the mouse pointer on the canvas (see class OpenGLCanvas) the corresponding angle to that movement will be calculated around the three main axes. The different angles are defined on the surface of a specified sphere (Arcball sphere) which will be "placed" in the middle of the canvas.
Thus, the length of a mouse movement will be projected on the sufrace of this sphere and the angles to the middle point of the sphere can be calculated.

Author:
Bernhard Pflugfelder
Version:
1.0
Date:
02-18-2005


Public Member Functions

 ArcBall (float NewWidth, float NewHeight)
 Constructor initialization with the valid mouse bounds for canvas height and width.
void setBounds (float NewWidth, float NewHeight)
 Set new mouse bounds for heigth and width.
void click (PointF NewPt)
 Saves the current specified mouse click point as the new start point.
void drag (PointF NewPt, Vector4 *NewRot)
 Saves the current specified mouse drag point as the new end point and calculates the corresponding rotation.
void resetVectors (void)
 Resets the current start and end vectors of the rotation calculation.
void CreateRotationMatrixFromVector4 (Matrix4 *n_DestinationObj, Vector4 *n_Vector4)
 Sets the value of this matrix to the matrix conversion of the quaternion argument.
void SetRotationFromMatrix (Matrix4 *NewObj, Matrix4 *n_SourceObj)
 Sets the rotational component (upper 3x3) of this matrix to the matrix values in the T precision Matrix3d argument.

Private Member Functions

void mapToSphere (PointF n_NewPt, Vector3 *n_NewVec)
 Projects the specified point on the Arcball sphere surface.
float getMatrixSVD (Matrix4 *n_DestinationObj)
 Calculates a simple SVD value of the specified 4x4 matrix.
void setRotationScaleFromMatrix (Matrix4 *n_DestinationObj, Matrix4 *n_SourceObj)
 Copies the rotational component (upper 3x3) of the input matrix to a new destination matrix.
void setMatrixMulRotationScale (Matrix4 *n_DestinationObj, float scale)
 Multiplies the the rotational component (upper 3x3) of the input matrix with the specified scale value.

Private Attributes

Vector3StVec
 Saves the start click vector of a mouse movement.
Vector3EnVec
 Saves the drag click vector of a mouse movement.
float AdjustWidth
 Saves the mouse bounds width.
float AdjustHeight
 Saves the mouse bounds height.

Static Private Attributes

static const double Epsilon = 1.0e-5
 This constant is the minimum value which will be used for all calculations in this class.
static const float RADIUS = 9.0f
 This constant is the radius of the Arcball sphere.
static const float RADIUSSQUARED = 3.0f
 This constant is the squared radius of the Arcball sphere.


Constructor & Destructor Documentation

ArcBall::ArcBall float  NewWidth,
float  NewHeight
 

Constructor initialization with the valid mouse bounds for canvas height and width.

This valid bound area specifies all valied values for possible mouse point, all point outside this area will be clipped during the calcualtion.

Parameters:
NewWidth the valid bound width.
NewHeight the valid bound height.


Member Function Documentation

void ArcBall::click PointF  NewPt  ) 
 

Saves the current specified mouse click point as the new start point.

Parameters:
NewPt the current start point of a mouse movement.

void ArcBall::CreateRotationMatrixFromVector4 Matrix4 n_DestinationObj,
Vector4 n_Vector4
 

Sets the value of this matrix to the matrix conversion of the quaternion argument.

Parameters:
[in] n_DestinationObj the input matrix.
[out] n_Vector4 the quaternion to be converted.

void ArcBall::drag PointF  NewPt,
Vector4 NewRot
 

Saves the current specified mouse drag point as the new end point and calculates the corresponding rotation.

Parameters:
[in] NewPt the current end point of a mouse movement.
[out] NewRot the calculated quaternion of the start and end vector of the mouse movement.

float ArcBall::getMatrixSVD Matrix4 n_DestinationObj  )  [private]
 

Calculates a simple SVD value of the specified 4x4 matrix.

This function calculates a very simple SVD value which will be used as a scale factor for actual rotation matrix.

Parameters:
n_DestinationObj the instance of the Matrix4 class which saves the original matrix.
Returns:
the calculated SVD value.

void ArcBall::mapToSphere PointF  n_NewPt,
Vector3 n_NewVec
[private]
 

Projects the specified point on the Arcball sphere surface.

This function calculates the surface coordinates of the corresponding point by projection.

Parameters:
[in] n_NewPt the actual mouse position.
[out] n_NewVec the projected position on the sphere surface.

void ArcBall::resetVectors void   ) 
 

Resets the current start and end vectors of the rotation calculation.

void ArcBall::setBounds float  NewWidth,
float  NewHeight
 

Set new mouse bounds for heigth and width.

Parameters:
NewWidth the valid bound width.
NewHeight the valid bound height.

void ArcBall::setMatrixMulRotationScale Matrix4 n_DestinationObj,
float  scale
[private]
 

Multiplies the the rotational component (upper 3x3) of the input matrix with the specified scale value.

Parameters:
[in] scale the scale value.
[out] n_DestinationObj the ouput matrix.

void ArcBall::SetRotationFromMatrix Matrix4 NewObj,
Matrix4 n_SourceObj
 

Sets the rotational component (upper 3x3) of this matrix to the matrix values in the T precision Matrix3d argument.

The other elements of this matrix are unchanged; a singular value decomposition is performed on this object's upper 3x3 matrix to factor out the scale, then this object's upper 3x3 matrix components are replaced by the passed rotation components, and then the scale is reapplied to the rotational components.

Parameters:
[in] n_SourceObj the input matrix.
[out] NewObj the ouput matrix.

void ArcBall::setRotationScaleFromMatrix Matrix4 n_DestinationObj,
Matrix4 n_SourceObj
[private]
 

Copies the rotational component (upper 3x3) of the input matrix to a new destination matrix.

Parameters:
[in] n_SourceObj the input matrix.
[out] n_DestinationObj the ouput matrix.


Member Data Documentation

const double IDVR.Tools.ArcBall.Epsilon = 1.0e-5 [static, private]
 

This constant is the minimum value which will be used for all calculations in this class.

That means if calculated angle values are less than Epsilon this angles will be disregarded.


The documentation for this class was generated from the following files:
Generated on Sat Apr 9 11:51:00 2005 for RayCaster wiht Importance Driven Volume Rendering (IDVR) by  doxygen 1.4.1