cs349 - s10 - Lecture 30

CS349 - Implementing User Interfaces - Spring 2010

Public Service Annoucements

  1. Assignment 3 reminder.
  2. Assignment 4.

Lecture 30 - Interfaces to Geometry (Real GUIs)

Representations of Objects

Last class we introduced a model of a graphical object that has three parts:

  1. A basic object that fits within a unit square.
  2. A transformation matrix.
  3. The inverse of the transformation matrix.

The Transformation Matrix and its Inverse

Suppose the object is defined by N points,

We define it transformation matrix as follows

  1. Each of the the points/vectors is multiplied by the modelling matrix Mm.
  2. Rotate the object until its coordinate axes, which are vectors, coincide with the coordinate axes of the super-object.
  3. Repeat level by level until you get to the level of the object itself
  4. The inverse matrix is Mminv*Mr1inv*Mt1inv*...*Mrjinv*Mtjinv.

Interacting with Transformations

What's needed to define each transformation

  1. Translation
  2. Rotate
  3. Scale
  4. Reflection

Each of the parameters of every transformation must be obtained (usually from the user) in order to update the model.

Example: Scaling


Remember the basic scaling matrix

  1. It scales along the x-axis; its fixed points are the y-axis.
  2. To scale generally we will obtain four parameters that determine the transformation

    How do we use these parameters to obtain the right transformation matrix?

    1. Transform the line to coincide with the y-axis
    2. Use s to scale along the x-axis
    3. Transform back to the original coordinate system
  3. Transform the line to coincide with the y-axis
  4. Scale using the basic scaling matrix.
  5. Invert the transformations that brought the line into the y-axis.

The Circle

What we've been doing is based on linear algebra. (Really affine algebra.)

Drawing a line is a linear operation on its end points.

Thus, we can draw an object made of straight lines by

This does not work for curves, like ellipses


When we draw on the screen we use the painter's algorithm


Picking = Using a pointing device to select a geometric object.

Picking has two variations

  1. Select topmost versus select all.
  2. Select with point versus select with area.

Picking is strongly related to drawing

Both drawing and picking must be fast.

  1. Drawing must meet limits imposed by perception of simultaneity.
  2. Picking happens when the user's attention is focussed at the pointer.

    We must complete

    1. picking
    2. redrawing

    fast enough that the user perceives no lag.

Three important ideas to speed up picking. Remember that almost all inside tests fail so failing fast is important.

  1. Inside tests that are ANDs can terminate at the first failure. E.g. Each line segment generates a half-plane test.

    (Not necessarily true in hardware.)

  2. Make most failures fast. E.g. first test against a bounding rectangle.
  3. Skip most of the failing tests. E.g. use an auxiliary data structure like a quad-tree.

How do we apply these ideas to testing for inside a Jinn's bottle?

Return to: