02 - Coordinate Syst..

advertisement
Last Time:
What is graphics? What is this class?
Graphics in a nutshell



Light and how nature renders
Ability to think about “3D” in the image plane
Pixel-oriented vs. Primitive-oriented graphics
Today
Some mechanics (how will we run the class)
Primitive-based Graphics
Coordinate System Basics
Coordinate Systems and Linear Algebra
Thunderstorm as an example (lightning, can’t tell the distance, could be painted on window)
Page 1 of 9
Images-based (Pixels) vs. Object-based (Primitives)
Pixels : discrete set of samples, change the values
Representation – a list of values (colors)
What order do you give the list in?
Top left – reading order (normal)
Bottom left – math 1st quadrant
Coherence issues
Compression (come back to later)
Primitives: simple objects
Break things down into a list of simple objects - Primitives
Points, lines, polygons (polylines)
Curves, surface elements (curved surface elements), …
Rich set of primitives vs. Small set that people put together
Two questions:
Where?
What color? (how to fill in) -- SHADING
Pixels vs. Primitives
Pixels: same complexity no matter what the conent (size of image)
White image? Lots of white pixels
Complex image? Same number of pixels
Primitives: more complexity = more primitives
White image? 1 big rectangle
Complex image? Lots of pieces
Caveats:
Can create complexity through complex shading
Multiple ways to make a picture (could have lots of primitives when not needed)
Some things about primitives
Basically, a list:
Might want fancier representation that leads to a list
Page 2 of 9
Surfaces vs. Solids
3D scenes vs. 2D drawings
What happens if things are in the same place?
3D – happens rarely with surfaces (unless exactly the same)
2D – happens a lot (overdraw)
What is drawn last wins? (usual in 2D)
Doing the right thing in 3D is tricky (and often not done well)
How do we talk about locations (for primitives)?
Start in 2D – although most things generalize
Name specific places
Coordinates – some numbers that represent positions
Coordinate System – tells us how to interpret coordinates
Page 3 of 9
Aside APIs…
What you need to draw a primitive (above)
Stated vs. stateless
Immediate vs. retained
Richness of primitive set/styling set vs. simplicity
Old: better and better primitives, longer lists of styling options
New: let programmer break things into smaller primitives,
Modern graphics hardware: one primitive (triangle), filling by running a program
At least a few years ago: pay extra for lines
Page 4 of 9
Why will we make a big deal about coordinate systems?
Need to know where to put objects
No one right coordinate system – use ones that are convenient
Need to manipulate coordinate systems (to move between different ones)
Manipulating coordinate systems (transformations) easier than manipulating objects
Or, is a way to think about manipulating objects
List of numbers (ordered)
Tuple / Array – just an ordered list of numbers
Vectors – a movement, a displacement, …
Represented in a tuple / array -- but a specific interpretation
Point / position – specific place
Represented in a tuple / array
Interpretation as a vector in a coordinate system
Walk in room example
What can you do with a vector (think a movement):
Multiply by scalar
Add
Linear combination
What does a vector like (3,2) mean?
3 * first + 2 * second
Need to know basis vectors
What does a point mean?
Start at origin, then vector
Page 5 of 9
Vector space – all vectors that can be made as a linear combination of a starting set
Vectors span a space
2 vectors span all of a 2D space if not parallel, and not zero
Basis – set of vectors we use to define a space (or a coordinate system)
Just about any pair of vectors (not parallel, not zero) === parallel is multiple
Why is orthogonal good? Why is nearly parallel bad? (singular, near singular)
Convenient Coodinate Systems
Global – GPS
Local vs. Global
Turn left/right vs. Map points north
Driving a radio control car (turn left/right) – Airplane is a tailspin
Local – street numbering in Madison
Street numbering in New York / Salt Lake City
Note: easier to have a different coordinate system
Other examples:
Whiteboard
Paper (each piece)
Within the room
Ego centric (forward relative to me)
Screen vs. window
1st quadrant coordinates vs. upper left corner coordinates
Normalized Device Coordinates
Convenient coordinates (0-100, same in both directions)
Page 6 of 9
Changing coordinate systems
Where does a point in one coordinate system go into the other?
Need to know the relationship between coordinate systems
What do we need to know to change coordinate systems:
Where does the origin go?
Where does each basis vector go?
If we don’t consider the origin – it’s multiplication
Matrix * vector multiplication
Matrix is a set of basis vectors
Transforms from one coordinate system into another
Sloppiness – rows vs. column vectors
Another way to think about it: Transformations
Functions: maps tuples to tuples (vectors to vectors)
R^n -> R^n
F(x,y) = [ … ]
Easy way to effect a large number of points
What happens to the object --- what happens to the coordinate system that the object is in
Where does each point on the piece of graph paper go
If linear, enough just to know what happens to 2 points
Can be complex functions (deformations)
Important case is linear function (linear combinations, matrix multiplication)
Composition of functions
x->F->G->H->x’
x’ = H ( G ( F ( x ) ) )
Page 7 of 9
Linear Transformations
Output on each axis is a linear combination of inputs
Matrix multiplication [ abcd] [xy] = [ax+by, cx+dy]
Note:
Basis vectors (where do the unit axes go)
Preserves zero
Straight lines -> straight lines
Need for inverses
Application is matrix vector multiply
Composition is matrix multiply
Post-Multiply convention
F(x) = F x
(points in on right, answer out on left)
Basic transforms
Scale, nuscale, reflect, skew
Translation is not a linear operator (doesn’t persevere 0)
Homogeneous coordinates
Real value comes later for projections
Rotations
Rigid – but with fixed zero point (can always translate and translate back)
-
Preserves distance
Preserves handedness (not a reflection)
Preserves zero
Special set of matrices have this property
-
Orthogonal
Normal
Positive Determinant
Page 8 of 9
Linear Algebra Things we need here:
-
Length of a vector, normality
Determinant (signed area of the parallelogram)
Orthogonal -> Projection -> Dot Product
Page 9 of 9
Download