Professional Documents
Culture Documents
Computer Graphics
Outline
• World window to viewport transformation
3D Transformations • 3D transformations
World Window to Viewport Transformation • Coordinate system transformation
Week 2, Lecture 3
1 2
1 2
3 4
P ic s /M a th c o u rte s y o f D a v e M o u n t @ U M D -C P 1 9 9 4 F o le y /V a n D a m /F in e r/H u g e s /P h illip s IC G
3 4
Transforming World
Clipping to the Viewport
Coordinates to Viewports
• 3 steps • Viewport size may • Transform lines in world
1. Translate not be big enough • Then clip in world
for everything •Transform to image
2. Scale
• Then draw
3. Translate • Display only the • Do not transform pixels
pixels inside the
Overall Transformation: viewport
P'= M wv P 5 6
1 9 9 4 F o le y /V a n D a m /F in e r/H u g e s /P h illip s IC G 1 9 9 4 F o le y /V a n D a m /F in e r/H u g e s /P h illip s IC G
5 6
€
1
Representation of 3D
3D Transformations
Transformations
• Z axis represents depth
• Right-Handed System
– When looking “down” at the
origin, positive rotation is CCW
• Left-Handed System
– When looking “down”, positive
rotation is in CW
– More natural interpretation for
displays, big z means “far” (into screen)
9 10
1 9 9 4 F o le y /V a n D a m /F in e r/H u g e s /P h illip s IC G
9 10
3D Transformations:
3D Homogenous Coordinates
Scale & Translate
• Homogenous • Scale
coordinates for 2D – Parameters for each
space requires 3D axis direction
vectors & matrices
• Homogenous
coordinates for 3D • Translation
space requires 4D
vectors & matrices
• [x,y,z,w]
11 12
11 12
% (
$ 0 0 0 1'
• c = cos(q)
• s = sin(q)
€ • t = (1 - c)
13 Graphics Gems I, p. 466 & 498 14
13 14
2
Rotation Around an
Arbitrary Axis Improved Rotations
• Also can be expressed as the • Euler Angles have problems
Rodrigues Formula – How to interpolate keyframes?
– Angles aren’t independent
– Interpolation can create Gimble Lock, i.e.
loss of a degree of freedom when axes
Prot = P cos(ϑ ) + (n × P)sin(ϑ ) + n(n ⋅ P)(1− cos(ϑ )) align
• Solution: Quaternions!
€ 15 16
15 16
17 18
17 18
p = (0, x )
19 20
19 20
3
A & B are quaternions
21 22
23 24
3D Transformations:
Shear Example
" X'% " 1 Shxy Shxz 0% " X %
$ ' $ x ' $ '
$ Y ' ' = $ Shy 1 Shyz 0' $ Y '
∗
$ Z' ' $ Shzx Shzy 1 0' $ Z '
$ ' $ ' $ '
#1& # 0 0 0 1& # 1 &
X ' = X + ShxyY + Shxz Z
Y ' = Shyx X +Y + Shyz Z
€
Z ' = Shzx X + ShzyY + Z
25 26
Pics/Math courtesy of Dave Mount @ UMD-CP
25 26
4
Example: Composition of 3D
Example (Cont.)
Transformations
(1-2)
• Goal: Transform P1P2 and P1P3 • Process
1. Translate P 1 to (0,0,0)
2. Rotate about y D1
3. Rotate about x
4. Rotate about z
(3)
(4)
27 28
1 9 9 4 F o le y /V a n D a m /F in e r/H u g e s /P h illip s IC G 1 9 9 4 F o le y /V a n D a m /F in e r/H u g e s /P h illip s IC G
27 28
Example 2: Composition of 3D
Final Result
Transformations
• What we’ve really
done is transform • Airplane defined in x,y,z
the local coordinate • Problem: want to point
system Rx, Ry, Rz it in Dir of Flight (DOF)
to align with the centered at point P
origin x,y,z • Note: DOF is a vector
• Process:
– Rotate plane
– Move to P
29 30
1 9 9 4 F o le y /V a n D a m /F in e r/H u g e s /P h illip s IC G 1 9 9 4 F o le y /V a n D a m /F in e r/H u g e s /P h illip s IC G
29 30
Transformations to Change
Example 2 (cont.) Coordinate Systems
• Issue: the world has many different relative
• Zp axis to be DOF frames of reference
• Xp axis to be a horizontal • How do we transform among them?
vector perpendicular to • Example: CAD Assemblies & Animation Models
DOF
– y x DOF
• Yp, vector perpendicular to
both Zp and Xp (i.e.Zp x Xp)
31 32
1 9 9 4 F o le y /V a n D a m /F in e r/H u g e s /P h illip s IC G
31 32
5
Transformations to Change
Coordinate System Example (1)
Coordinate Systems
• 4 coordinate systems • Translate the House
1 point P to the origin
33 34
€
35 36
€
• Go to web site
37
37