Introduction
Often we would like to visualize a 3d model from different view angles. Trackball is rotation technique that allow the user to intuitively change the view angle by using the mouse. The mouse behaves like a virtual trackball. Let's try to understand how trackball view rotation work exactly. This could be useful, as a programmer, if you want to implement this rotation technique in your application. Or if your are an artist it could be interesting to know what's happen under the stage.
Principle
The mouse moves on the screen which is a 2D plane. However a trackball could rotate in any direction in a 3D space. The problem here is to match the planar mouse movement to a 3D rotation. The idea to solve this problem is to project the 2D coordinate of the mouse cursor on a virtual sphere behind the screen, thus we obtained 3D point (blue on the picture). The difference between this 3D point and the center of the virtual sphere (red on the picture) is a 3D vector. The movement of this 3D vector while dragging the mouse is a rotation around the sphere center. Here we are! We use that rotation to rotate the view.
No comments:
Post a Comment