Panning, zooming, and rotating are all achieved by making changes to the view reference coordinates. We created a ViewRef class to hold variables for the VRP, axes VPN, VUP, and U, the view extent, the screen space, and a screen offset.
Motion with the first mouse button held down causes the data to move with the mouse. The axes are not changed, but the VRP moves in the opposite direction in the data space. Each time the function is called to handle movement, the -dx and -dy since the last call are calculated, and the VRP is translated by them.
Motion with the third mouse button held down results in a resizing of the data extent, which has the effect of zooming in or out. This is implemented as though the user grabs a lever, and moving it away (up the screen) zooms in, and pulling back (down the screen) zooms out. The axes and VRP do not change, just the extent does. It scales by a factor related to the distance the mouse has moved since the initial click.
Motion with the second mouse button held down causes the data to rotate – up-down rotates about the U axis, and left-right rotates about VUP. The mouse distances since the last update are transformed into angles by multiplying by pi/400. These angles are used as parameters for rotateVRC.