A pointer to the destination matrix.
The amount the `top surface' has moved in each direction.
The radius of the imaginary ball.
Note that using the 2D manipulator to describe small circles can rotate the 3D object about its vertical axis.
Description:
This function generates a matrix which provides an intuitive way of controlling the rotation of 3D objects with a mouse or other 2D pointing device. The mouse may be thought of as controlling a horizontal flat surface resting on top of a fixed sphere. As the surface is moved in any direction (but not rotated), so the sphere will rotate.BrMatrix34RollingBall()
void BrMatrix34RollingBall(br_matrix34* mat, int dx, int dy, int radius)
br_matrix34 * mat
int dx,dy
int radius
dx
,dy
) to the sphere of radius radius
. in 3D, and uses this to determine the axis of rotation normal to this tangent at the centre of the sphere, and the angle subtended by the tangent vector. From this, a transform matrix is created, describing the rotation.
int mouse_x,mouse_y;
br_matrix34 mat;
...
BrMatrix34RollingBall(&mat,-mouse_x,mouse_y,500);
See Also:
The book Graphics Gems III, edited by David Kirk, ISBN 0-12-409670-0, Ch.2, Pt.3, `The Rolling Ball', Andrew J. Hanson, p51.
Generated with CERN WebMaker