#include <draw.h>
#include <geometry.h>
void qball(Rectangle r, Mouse *mousep,
Quaternion *orientation,
void (*redraw)(void), Quaternion *ap)
Argument mousep is a pointer to the mouse event that triggered the interaction. It should have some button set. Qball will read more events into mousep , and return when no buttons are down.
While qball is reading mouse events, it calls out to the caller-supplied routine redraw , which is expected to update the screen to reflect the changing orientation. Argument orientation is the orientation that redraw should examine, represented as a unit Quaternion (see quaternion(9.2)). The caller may set it to any orientation. It will be updated before each call to redraw (and on return) by multiplying by the rotation specified with the mouse.
It is possible to restrict qball's attention to rotations about a particular axis. If ap is null, the rotation is unconstrained. Otherwise, the rotation will be about the same axis as *ap . This is accomplished by projecting points on the sphere to the nearest point also on the plane through the sphere's center and normal to the axis.
Ken Shoemake, ``Animating Rotation with Quaternion Curves'', SIGGRAPH '85 Conference Proceedings.