# Graphics I/O Hardware

## Mice & Keyboards (Input)

1. Request
2. Sample
3. Event

#### Devices

1. Text Input
2. Pointing Input

## Event-based Programming

1. Event Loop
• Xlib
2. Callbacks
• Toolkit programming
• Java listeners

Callbacks need formal work. Java is trying hard but needs to step further back from the coal face.

# Geometry

The course notes give you the axioms and theorems. In class, I will concentrate on ideas and algorithms.

#### Euclid and the Greeks

Of course, it's completely unfair to give the Greeks all the credit.

• Straightedge and compass.
• Congruence: two different triangles share a property called congruence.
• Similarity: two different triangles share a propety called similarity.
• Felix Klein's Erlangen program. (circa 1870).

#### Descartes

Points are pairs (triples, etc)

• Connects geometry to algebra.
1. Subtract two points
2. Add (with a little hesitation) two points
4. Multiply a point by point???
• perhaps as complex numbers (in 2D at least)
• complex numbers don't generalize to 3D

Multiply a point by a scalar

5. Find a multiplicative unit, the scalar 1.
6. Does a multiplicative inverse exist?

Addition/subtraction might work all right, but the prominent role played by the origin is suspect. Why?

• Computers do algebra, not geometry.
• Distance is defined: more strongly than the compass!

Points morphed into vectors. What is the difference between two points?

• An arrow that goes from one point to the other
• The arrow does not change when the origin is translated
• Suppose we think only about vectors
1. Subtract
3. Unit, inverse
4. Scalar multiply

Closed up to here

5. Dot product of two vectors: defines length, angle.
• Makes geometry challenging as an interpretation of algebra!

#### Vector Spaces, aka Linear Algebra.

We have some things that look like Descartes' points, though we don't know exactly what they are.

We can tell when they are equal

• v1 =1 v2 if and only if x1 = x2 and y1 = y2.

• v1 +1 v2 means (x1, y1) +1 (x2, y2) =1 (x1 + x2, y1 + y2)
• They are closed under addition.
• There is a zero element 01 =1 (0, 0)
• There is an inverse: If x1 =1 x2 and y1 =1 y2, then (x1, y1 ) +1 (x2, y2 ) =1 01

Where addition is, multiplication cannot be far behind

• a *1 v =1(a * x, a * y ), called scalar multiplication.
• They are closed under scalar multiplication.
• There is a unit element 1; there is a zero element 0.
• Scalars must be a field.
• Scalar multiplication distributes over addition: a *1 ( v1 +1 v2 ) =1 a *1 v1 +1 a *1 v2.

What are these things? We want the geometrical interpretation.

• Descartes called them points, BUT they are not like points.

How?

• You can move them around, like
• derivatives
• position independent code.

We call them vectors.

Generators

• How few vectors can I use to create all of them?
• The number is the dimension.
• A set having that number, with appropriate weasel words, is a basis.

Transformations

Vectors can be transformed, by multiplying them by matrices

• Rigid transformations in 2D
1. Unit
2. Rotation
3. Reflection

More complex in 3D

• Non-rigid transformations in 2D
1. Scale
2. Skew

If you are Felix Klein you show that they are a group, and how they separate into subgroups. But even though you are not Felix Klein your response to this formulation is the same.

#### Affine Spaces

Intuition is that when I add an origin, O, vectors define points.

• Each point, P, can be - but is not - identified with the vector that joins it to the origin.
• P =2 O +2 v
• =2 and +2 are related to =1 as follows,
• First, P1 =2 O +2 v1 =2 P2 =2 O +2 v2 if and only if v1 =1 v2.
• Second, ( O +2 v1 ) +2 v2 =2 O +2 ( v1 +1 v2 )
• Define point subtraction
• v =1 P1 -2 P2 if and only if P1 =2 P2 +2 v

Generators

• A basis for the vectors, (v1, v2, ... ), plus one point, O.

Package them together (v1, v2, ..., O).