Title: Computer Graphics CS630
1Computer GraphicsCS630
- Lecture 3 Transformation And Coordinate Systems
2What is a Transformation?
- Maps points (x, y) in one coordinate system to
points (x', y') in another coordinate system
x' ax by c y' dx ey f
3Transformations
- Simple transformation
- Translation
- Rotation
- Scaling
4Transformations
- Deformable transformations
- Shearing
- Tapering
- Twisting
- Etc..
- Issues
- Can be combined
- Are these operations invertible?
5Transformations
- Why use transformations?
- Position objects in a scene (modeling)
- Change the shape of objects
- Create multiple copies of objects
- Projection for virtual cameras
- Animations
6Classes of Transformation
- Rigid-Body/ Euclidean transformation
- Similarity Transforms
- Linear Transforms
- Affine Transforms
- Projective Transforms
7Rigid-Body / Euclidean Transforms
- Preserves distances
- Preserves angles
Rigid / Euclidean
Identity
Translation
Rotation
8How are Transforms Represented?
x' ax by c y' dx ey f
c f
x y
x' y'
a b d e
p' M p t
9Translation
10Properties of Translation
11Scaling
Uniform scaling iff
12Rotations (2D)
13Rotations 2D
14Rotations (3D)
15Properties of Rotations
order matters!
16Combining Translation Rotation
17Combining Translation Rotation
18Homogeneous Coordinates
- Add an extra dimension
- in 2D, we use 3 x 3 matrices
- In 3D, we use 4 x 4 matrices
- Each point has an extra value, w
x y z w
a e i m
b f j n
c g k o
d h l p
x' y' z' w'
p' M p
19Homogeneous Coordinates
- Most of the time w 1, and we can ignore it
x' y' z' 1
x y z 1
a e i 0
b f j 0
c g k 0
d h l 1
20Homogeneous Coordinates
can be represented as
where
21Translation Revisited
22Rotation Scaling Revisited
23Combining Transformations
where
24Transforming Tangents
25Transforming Normals
26Surface Normal
- Surface Normal unit vector that is locally
perpendicular to the surface
27Why is the Normal important?
- It's used for shading makes things look 3D!
object color only
Diffuse Shading
28Visualization of Surface Normal
29How do we transform normals?
nWS
nOS
World Space
Object Space
30Transform the Normal like the Ray?
- translation?
- rotation?
- isotropic scale?
- scale?
- reflection?
- shear?
- perspective?
31More Normal Visualizations
Incorrect Normal Transformation
Correct Normal Transformation
32Transforming Normals
33Rotations about an arbitrary axis
Rotate by around a unit axis
34An Alternative View
- We can view the rotation around an arbitrary axis
as a set of simpler steps - We know how to rotate and translate around the
world coordinate system - Can we use this knowledge to perform the rotation?
35Rotation about an arbitrary axis
- Translate the space so that the origin of the
unit vector is on the world origin - Rotate such that the extremity of the vector now
lies in the xz plane (x-axis rotation) - Rotate such that the point lies in the z-axis
(y-axis rotation) - Perform the rotation around the z-axis
- Undo the previous transformations
36Rotation about an arbitrary axis
y
(a,b,c)
x
x
(a,b,c)
z
37Closer Look at Y-Z Plane
- Need to rotate ? degrees around the x-axis
y
?
z
38Equations for ?
39Rotation about the Y-axis
- Using the same analysis as before, we need to
rotate ? degrees around the Y-axis
y
x
(a,b,c)Rx (?) (a,b,c)T
z
40Equations for ?
41Rotation about the Z-axis
- Now, it is aligned with the Z-axis, thus we can
simply rotate ? degrees around the Z-axis. - Then undo all the transformations we just did
42Equation summary
43Deformations
- Transformations that do not preserve shape
- Non-uniform scaling
- Shearing
- Tapering
- Twisting
- Bending
44Shearing
45Tapering
46Twisting
47Bending
48Quick Recap
- Computer Graphics is using a computer to generate
an image from a representation.
computer
Model
Image
49Modeling
- What we have been studying so far is the
mathematics behind the creation and manipulation
of the 3D representation of the object.
computer
Model
Image
50What have we seen so far?
- Basic representations (point, vector)
- Basic operations on points and vectors (dot
product, cross products, etc.) - Transformation manipulative operators on the
basic representation (translate, rotate,
deformations) 4x4 matrices to encode all
these.
51Why do we need this?
- In order to generate a picture from a model, we
need to be able to not only specify a model
(representation) but also manipulate the model in
order to create more interesting images.
52Overview
- The next set of slides will deal with the other
half of the process. - From a model, how do we generate an image
computer
Model
Image
53Scene Description
Scene
Materials
Lights
Camera
Objects
Background
54Graphics Pipeline
55Graphics Pipeline
- Modeling transforms orient the models within a
common coordinate frame (world space)
56Graphics Pipeline
57Graphics Pipeline
- Maps world space to eye space
- Viewing position is transformed to origin
direction is oriented along some axis (usually z)
58Graphics Pipeline
- Transform to Normalized Device Coordinates (NDC)
- Portions of the object outside the view volume
(view frustum) are removed
59Graphics Pipeline
- The objects are projected to the 2D image place
(screen space)
60Graphics Pipeline
61Graphics Pipeline
- Z-buffer - Each pixel remembers the closest
object (depth buffer)
62Graphics Pipeline
- Almost every step in the graphics pipeline
involves a change of coordinate system.
Transformations are central to understanding 3D
computer graphics.
63Intuitively
World Space
Object Space
Camera Space Projection NDC
Rasterization
64Coordinate Systems
- Object coordinates
- World coordinates
- Camera coordinates
- Normalized device coordinates
- Window coordinates
65Object Coordinates
- Convenient place to model the object
66World Coordinates
- Common coordinates for the scene
67Positioning Synthetic Camera
What are our degrees of freedom in camera
positioning? To achieve effective visual
simulation, we want 1) the eye point to be in
proximity of modeled scene 2) the view to be
directed toward region of interest, and 3) the
image plane to have a reasonable twist
68Eye Coordinates
Eyepoint at origin u axis toward right of image
plane v axis toward top of image plane view
direction along negative n axis
69Transformation to Eye Coordinates
Our task construct the transformation M that
re-expresses world coordinates in the viewer frame
70Machinery Changing Orthobases
Suppose you are given an orthobasis u, v, n What
is the action of the matrix M with rows u, v, and
n as below?
71Applying M to u, v, n
Two equally valid interpretations, depending on
reference frame 1 Think of uvn basis as a rigid
object in a fixed world space Then M rotates
uvn basis into xyz basis 2 Think of a fixed axis
triad, with labels from xyz space Then M
reexpresses an xyz point p in uvn coords! It is
this second interpretation that we use today to
relabel world-space geometry with eye space
coordinates
72Positioning Synthetic Camera
Given eyepoint e, basis u, v, n Deduce M that
expresses world in eye coordinates Overlay
origins, then change bases
73Positioning Synthetic Camera
Check does M re-express world geometry in eye
coordinates?
74Positioning Synthetic Camera
Camera specification must include World-space
eye position e World-space lookat direction -n
Are e and -n enough to determine the camera DOFs
(degrees of freedom)?
75Positioning Synthetic Camera
Are e and -n enough to determine the camera
DOFs? No. Note that we were not given u and
v! (Why not simply require the user to specify
them?)
We must also determine u and v, i.e., camera
twist about n. Typically done by specification
of a world-space up vector provided by user
interface, e.g., using gluLookat(e, c,
up) Twist constraint Align v with world up
vector (How?)
76Positioning Synthetic Camera
77Where are we?
78What is Projection?
Any operation that reduces dimension (e.g., 3D to
2D)
Orthographic Projection Perspective Projection
79Orthographic Projection
- focal point at infinity
- rays are parallel and orthogonal to the image
plane
80 Comparison
81 Simple Perspective Camera
- camera looks along z-axis
- focal point is the origin
- image plane is parallel to xy-plane at distance d
- d is call focal length
82Similar Triangles
- Similar situation with x-coordinate
- Similar Triangles point x,y,z projects to
(d/z)x, (d/z)y, d
83 Projection Matrix
- Projection using homogeneous coordinates
- transform x, y, z to (d/z)x, (d/z)y, d
- 2-D image point
- discard third coordinate
- apply viewport transformation to obtain physical
pixel coordinates
84Perspective Projection
85Perspective Projection
z 0 not allowed (what happens to points on
plane z 0?) Operation well-defined for all
other points
86Perspective Projection
Matrix formulation using homogeneous 4-vectors
Finally, recover projected point using homogenous
convention Divide by 4th element to convert
4-vector to 3-vector
87Camera Coordinates
- Coordinate system with the camera in a convenient
pose
y
x
z
88View Volume and Normalized Device Coordinates
89Normalized Device Coordinates
- Device independent coordinates
- Visible coordinate usually range from
90Perspective Projection
- Taking the camera coordinates to NDC
91Perspective Projection
92Perspective Projection NDC
93Window Coordinates
- Adjusting the NDC to fit the window
is the lower left of the window
94Window Coordinates
- Adjusting the NDC to fit the window
is the lower left of the window
height
width
95Window Coordinates
96Summary Object Coordinate to Device Coordinate
- Take your representation (points) and transform
it from Object Space to World Space (Mwo) - Take your World Space point and transform it to
Camera Space (Mcw) - Perform the remapping and projection onto the
image plane in Normalized Device Coordinates
(Mw_p Mpc) - Perform this set of transformations on each point
of the polygonal object (M Mw_pMpcMcwMwo)