View Reference
Skip to end of metadata
Go to start of metadata


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.

ViewRef Methods

  • sets up a ViewRef object, initializing all variables to default values
  • parameters – none
  • return – a new ViewRef object
  • sets extent, VRP, VUP, and VPN to make the view centered perpendicularly on the XY plane
  • parameters – self
    • data: a numpy array of the data that is used to set the coordinates
  • return – None
  • generates the transformation matrix to get the data to the screen space
  • parameters – self
  • return – the transformation matrix as a numpy array
  • changes the view reference coordinates so that they rotate the given amounts about the VUP and U axes
  • parameters – self
    • VUPangle: the amount (in radians) by which to rotate about the VUP axis
    • Uangle: the amount (in radians) by which to rotate about the U axis
      *return – none

Interface Motion


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.