Upload
others
View
1
Download
0
Embed Size (px)
Citation preview
Specifying Complex Scenes
• Absolute position is not very natural
• Need a way to describe “relative” relationship:– “The lego is on top of the roof, which is above the house”
• Work “locally” for every object and then combine
3
Transformations
• Transforming an object = transforming all its points
• For a polygon = transforming its vertices
4
Scaling
• – vector in plane
• Scaling operator with parameters :
(0,0) (sx,sy)=(0.7, 0.7) (sx,sy)=(0.7, 1.0) (sx,sy)=(3.0, 1.5)
,,
5
Rotation
• Polar form:cossin
• Rotate V anti‐clockwise by to W:
cossin
cos sinsin cos
(0,0)
W
V
r
(0,0)
vy
vx
= -45o = -135o
7
Translation
• Translation operator with parameters :
,
• Can we express in a matrix form?
(tx,ty)=(0.0, 1.0) (tx,ty)=(1.0, 0.0) (tx,ty)=(1.5, 0.3)
10
Transformation Composition
What operation rotates by around ?– Translate to origin– Rotate around origin by – Translate back
16
P P
16
Transformation Composition
• performs one transformation• performs a second transformation
• performs the composed transformation
17
Transformation Quiz
• Can one rotate in the plane by reflection?
• How can one reflect through an arbitrary line in the plane?
21
Rotate by Shear
cos sinsin cos
11
• Solve for , , :cos 1sin
• Solution:sin
tan 2• When is this useful?
24
Rotation Approximation• For small angles we have:
cos → 1 and sin → (Taylor expansion of sin/cos)
• Can approximate:
Examples (steps of ):
26
3D Transformations• All 2D transformations extend to 3D• In homogeneous coordinates:
, ,
1
, , ,1
11
1cos sinsin cos
1
1
• What is ? ?
27
3D Transformations
• Questions (commutativity):
– Scaling: Is S1S2 = S2S1?
– Translation: Is T1T2 = T2T1?
– Rotation: Is R1R2 = R2R1?
28
Example: Arbitrary Rotation
• Problem: Given two orthonormal coordinate systems XYZ and UVW,find a transformation from one to the other.
Y Z
X
W
V
U
30
Arbitrary Rotation• Answer:
– Transformation matrix R whose columns are U, V, W:
• Proof:
• Similarly R(Y) = V and R(Z) = W31
Arbitrary Rotation (cont.)• Inverse (=transpose) transformation, R-1, provides mapping from UVW to XYZ
• E.g.
X
uuu
wvuwvuwvu
uuuUR
zyx
zzz
yyy
xxx
zyx
)0,0,1(
)0,0,(
),,()(
222
1
32
Line Objects
• Line through two points in parametric form:
1 1 0 .
0 01 1,
0.5 0 1 /2,
• Ray: 0,• Segment: 0,1
• Intuitively: Coordinates of trajectory of particle at time .
0 0, 0
1 1, 1
0.5
0
1
1
33
Viewing Transformations• Question: How can we view (draw) 3D
objects on a 2D screen?• Answer:
– Project the transformed object along Zaxis onto XY plane ‐ and from there to screen (space)
– Canonical projection:
1000000000100001
In practice “ignore” the z axis – simply use the x and ycoordinates for screen coordinates
z
Objectspace
Viewspace
Screenspace
projectors
34
Parallel ProjectionProjectors are all parallel
– Orthographic: Projectors perpendicular to projection plane– Axonometric: Rotation + translation + orthographic projection
36
Perspective Projection• Viewing is from point at a finite distance
• Without loss of generality:– Viewpoint at origin– Viewing plane is
• Given triangle similarity gives:
dzyy
dzxx
dy
zy
dx
zx
pppp
/ and
/ and
center of projection
projectors
projectionplane
X
x2p
x1p= x3
p
z = d
p1= (x1, y1, z1)
p2 p3
Z
38
Perspective Projection (cont’d)• In homogeneous coordinates:
• In Euclidean coordinates:
• P not injective & singular: det 0
.,,,
0000/110000100001
)1,,,()1,,,(
dzzyx
dzyxzyxP
).,,(,/
,//
,/
,/
dyxddz
ydz
xdz
zdz
ydz
xpp
39
Perspective ProjectionWhat is the difference between:• Moving the projection plane• Moving the viewpoint (center of projection)
Z
Z
y yyScale Dolly
Zz z z43
Perspective Warp• Matrix formulation
d
zd
dzyx
dd
dddzyx ,)(,,
000
10000100001
)1,,,(
zd
zddz
ydz
xzyx ppp 2
,/
,/
),,(
45
2 2( )( ) 1( )
d z df zd z d z
α
d2/(d-α)
d
d
z
f(z)
monotonic increasing in zpreserves z ordering
z1 z2
46
QuizWhich transformation preserves which geometric form ?
linesparallellines distance angles normals convexity conics
scaling
rotation
translation
shear
perspective
48