CS488
Geometric Transformations
Luc RENAMBOT
1
CS488 Geometric Transformations Luc R ENAMBOT 1 Previous Lectures - - PowerPoint PPT Presentation
CS488 Geometric Transformations Luc R ENAMBOT 1 Previous Lectures Frame buffers Drawing a line (Midpoint Line Algorithm) Polygon Filling (Edge-table algorithm) Line Clipping (Cohen-Sutherland algorithm) Polygon Clipping
Luc RENAMBOT
1
2
the contents of the frame buffer. Now we are going to go up a level of abstraction and look at how geometric transformations are used to alter the view of a 2D model: how we can translate, scale, and rotate the model, and how transformations affect what the viewport 'sees' →Geometric Transformations
3
affect
the edges are drawn between the new vertices
4
in orthogonal directions
5
the rotation Y→Z is positive
Y axis the rotation Z→X is positive
the rotation X→Y is positive
6
X Y Z
RHS
the rotation Y→Z is positive
Y axis the rotation Z→X is positive
the rotation X→Y is positive
7
X Y Z
LHS
8
8
9
9
10
10
11
11
12
12
Dx and Dy to location P’(X',Y')
Y
13
P = X Y
Dx Dy
X Y
and Sy to location P’(X',Y')
Y
14
the center of the primitive
Scale = 1 leave the object alone Scale < 1 shrink the object and move it towards the
15
angle theta to location (X',Y') note that this does involve sin and cos which are much more costly than addition or multiplication
Y * sin(theta)
Y *cos(theta)
16
about the center of the line/polygon/whatever
angle of theta+phi from the X axis
same distance from the origin as (X,Y)
17
18
X Y P(x,y) P’(x’,y’) r
Phi Theta
X = r * cos(phi) Y = r * sin(phi)
Y' = r * sin(theta+phi)
cos(a+b) = cos(a) * cos(b) - sin(a) * sin(b) sin(a+b) = sin(a) * cos(b) + cos(a) * sin(b)
Y' = r * sin(theta) * cos(phi) + r * cos(theta) * sin(phi)
Y * sin(theta) Y' = X * sin(theta) + Y * cos(theta)
19
multiplication, in a consistent manner ?
20
(translation, scaling, rotation) in the same way - as multiplications
Y, W)
same point if they are multiples of each other e.g. (1,2,3) and (2,4,6)
nonzero
21
to get the cartesian coordinates of X and Y
the same point (X/W, Y/W, 1)
but they make graphics operations much easier
22
23
X W Y W=1 Plane
P (x,y,w) XYW homogeneous coordinate space
and Dy to location P’(X',Y',1)
Y
Y’ /1 ] P=[X / Y /1]
24
T = 1 Dx 1 Dy 1
to location P’(X',Y',1)
Y
Y’ /1 ] P=[X / Y /1]
25
angle theta to location (X',Y',1)
Y * sin(theta)
Y *cos(theta)
26
R = cos(theta) −sin(theta) sin(theta) cos(theta) 1
matrices to a point, we want to use the transformations to produce 1 matrix which can be applied to the point
same type of transformation (translation, rotation, scaling) more than once
27
types of transformations?
28
a polygon about an arbitrary point (e.g. the center
T(Dx,Dy)
29
P = T Dx Dy
−Dx −Dy
scale a polygon about an arbitrary point (e.g. the center of the polygon) rather than around the origin
at P1
30
polygon?
center of mass)
the polygon
31
32
a a
Rotation around (a)
32
a a
Rotation around (a)
a a
Applying rotation to segment →Wrong
32
a a
Rotation around (a)
a a
Applying rotation to segment →Wrong
a a a a
Rotation Translation Translation Initial Position
coordinates to be displayed in a rectangular region of the screen called the viewport
The viewport is in screen coordinates (with n=2)
33
points:
to (Xmax,Ymax)
to (Umax,Vmax)
34
coordinate system.
coordinate system.
35
M = T Umin Vmin
deltaU/deltaX deltaV/deltaY
−Xmin −Ymin
3x3 matrices (X,Y,W)
(X, Y, Z, W)
36
amount Dx, Dy and Dz to location (X',Y',Z',1) X' = Dx + X Y' = Dy + Y Z' = Dz + Z
37
T = 1 Dx 1 Dy 1 Dz 1
Sx, Sy and Sz X' = Sx * X Y' = Sy * Y Z' = Sz * Z
38
S = Sx Sy Sz 1
most common choices are the X-axis, the Y- axis, and the Z-axis
P’(X’,Y’,Z’,1) and angle theta
39
40
Rx = 1 cos(theta) −sin(theta) sin(theta) cos(theta) 1 Rz = cos(theta) −sin(theta) sin(theta) cos(theta) 1 1
P = X Y Z 1
P = X Y Z 1
Ry = cos(theta) sin(theta) 1 −sin(theta) cos(theta) 1
the 2D case
41
Y, Z)
Y, Z)
42
43