Motion events occur when the user moves the mouse over the device window, independent of the state of any of the buttons. But we want to make changes to the eyepoint only when the left button is down. Since the state of the button is known in the mouse function, we communicate this information through our boolean variable dragging.

The mouse location and the eyepoint are in two distinct coordinate systems. In turn, we need a method for computing a change in the eye coordinates from the mouse coordinates. We use in our Update Function the percentages in the x and y directions that the mouse has moved from its initial point (startX, startY).