#include <ArcBall.h>
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.
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 | |
Vector3 * | StVec |
Saves the start click vector of a mouse movement. | |
Vector3 * | EnVec |
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 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.
|
|
Saves the current specified mouse click point as the new start point.
|
|
Sets the value of this matrix to the matrix conversion of the quaternion argument.
|
|
Saves the current specified mouse drag point as the new end point and calculates the corresponding rotation.
|
|
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.
|
|
Projects the specified point on the Arcball sphere surface. This function calculates the surface coordinates of the corresponding point by projection.
|
|
Resets the current start and end vectors of the rotation calculation.
|
|
Set new mouse bounds for heigth and width.
|
|
Multiplies the the rotational component (upper 3x3) of the input matrix with the specified scale value.
|
|
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.
|
|
Copies the rotational component (upper 3x3) of the input matrix to a new destination matrix.
|
|
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. |