Main Page | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members

TransformerArcBall Class Reference

Implements the Transformer to compute the transformation Matrix by interpreting the mouse position as points on a hemisphere. More...

#include <TransformerArcBall.h>

Inheritance diagram for TransformerArcBall:

Transformer List of all members.

Public Member Functions

 TransformerArcBall (int width, int height)
 Create an TransformerArcBall with the given dimensions.

void reshape (int width, int height)
 Update the TransformerArcBall dimensions.

void start (float x, float y)
 Starts a rotation at the given screen coordinates.

const Matrix end (float x, float y)
 Compute the rotation matrix determined by the start of the rotation (m_rotationVector) and the current screen position.


Private Member Functions

float sphereZ (float x, float y)
 Computes the point on the hemisphere corresponding to a point on the screen.


Private Attributes

float m_centerX
 The center of the hemisphere on which the rotation is represented.

float m_centerY
 The center of the hemisphere on which the rotation is represented.

float m_radius
 The radius of the hemisphere on which the rotation is represented.

Vector m_rotationVector
 The Vector from the center of the hemisphere to the point on the hemisphere defined by the current rotation.


Detailed Description

Implements the Transformer to compute the transformation Matrix by interpreting the mouse position as points on a hemisphere.


Member Function Documentation

float TransformerArcBall::sphereZ float  x,
float  y
[private]
 

Computes the point on the hemisphere corresponding to a point on the screen.

Since the hemisphere is guaranteed to cover the entire screen, we know that points on the screen will fall somewhere on the sphere. The Z coordinate (the "height" of the point) is computed trivially using Pythagora's theorem.

void TransformerArcBall::reshape int  width,
int  height
[virtual]
 

Update the TransformerArcBall dimensions.

The m_centerX and m_centerY variables are setup to be in the middle of the screen (half of width and, respectively, height). The m_radius variable is setup to be the distance from (m_centerX, m_centerY) to the corner of the screen (thereby ensuring that the hemisphere covers the entire surface of the screen).

Implements Transformer.

void TransformerArcBall::start float  x,
float  y
[virtual]
 

Starts a rotation at the given screen coordinates.

Sets up the m_rotationVector to point to the point on the sphere corresponding to the given position (x, y, sphereZ())

Implements Transformer.

const Matrix TransformerArcBall::end float  x,
float  y
[virtual]
 

Compute the rotation matrix determined by the start of the rotation (m_rotationVector) and the current screen position.

The current screen position is represented by the Vector (x, y, sphereZ()).

The rotation is computed as follows:

  • Compute the angle between m_rotationVector and the current Vector and multiply by 2.0. This is the angle for the rotation.
  • Compute and normalize the cross product between the m_rotationVector and the current Vector. This is the axis around which the rotation is performed.
  • Initialize and normalize the Quaternion representing the rotation described above (angle, axis).
  • Return the Matrix corresponding to the Quaternion.

Implements Transformer.


Member Data Documentation

float TransformerArcBall::m_centerX [private]
 

The center of the hemisphere on which the rotation is represented.

The center and the m_radius are guaranteed to define a hemisphere which covers the entire window.

float TransformerArcBall::m_centerY [private]
 

The center of the hemisphere on which the rotation is represented.

The center and the m_radius are guaranteed to define a hemisphere which covers the entire window.

float TransformerArcBall::m_radius [private]
 

The radius of the hemisphere on which the rotation is represented.

The radius and the (m_centerX, m_centerY) are guaranteed to define a hemisphere which covers the entire window.


The documentation for this class was generated from the following files:
Generated on Mon Aug 25 23:40:58 2003 for Shadow by doxygen 1.3.2