Presentation is loading. Please wait.

Presentation is loading. Please wait.

GEOMETRIC TRANSFORMATIONS Yingcai Xiao

Similar presentations


Presentation on theme: "GEOMETRIC TRANSFORMATIONS Yingcai Xiao"— Presentation transcript:

1 GEOMETRIC TRANSFORMATIONS Yingcai Xiao

2 Roadmap to Geometric Transformations
Start with 2D GT Extend to 3D GT Preview mathematics Express GT in four type of notations Algebraic Matrix Logical Visual

3 Review of Mathematical Preliminaries Mathematical Notations Points:
Vectors: directional lines P1(x1,y1) P0(x0,y0)

4 1. A vector has a direction and a length: Length: |V|=(x2 + y2)1/2
A unit vector: |V| = 1 e.g.: Normalize a vector: 2. Add two vectors 3. Scalar Multiplication

5 4. Dot product of two vectors scalar
, V W V  W if  = 90 => cos = 0 => V  W = 0. if  < 90 => cos > 0 => V  W > 0. if  > 90 => cos < 0 => V  W < 0. 5.Normal: a unit vector perpendicular to a surface

6 A point p(xp,yp) is on the line if f(xp,yp) = 0. When b < 0:
Lines y = mx+b e.g.: y = x; ax+by+c=0 Let f(x,y) = ax + by + c A point p(xp,yp) is on the line if f(xp,yp) = 0. When b < 0: p(xp,yp) is above the line if f(xp,yp) < 0. p(xp,yp) is below the line if f(xp,yp) > 0. When b > 0: p(xp,yp) is above the line if f(xp,yp) > 0. p(xp,yp) is below the line if f(xp,yp) < 0.

7 Parametric Form: P(t)=P0+t(P1-P0); 0 <= t <= 1
P1(x1,y1) P0(x0,y0) P(t)=P0+t(P1-P0)

8 Where, x(t) = x0 + t * (x1 – x0) y(t) = y0 + t * (y1 – y0) 0 <= t <= 1 x(t) = (1-t) * x0 + t * x1 y(t) = (1-t) * y0 + t * y1

9 2D Transformations Translate a point
The algebraic representation of translation of point P(x,y) by D(dx,dy) is x’= x + dx y’= y + dy Its “matrix” representation is Its logical representation is P’ = P + D Its visual representation is P’ (x’,y’) P(x,y) D(dx,dy)

10 To move a shape: translate every vertex of the shape
5 10 X Y Before Translation (4,5) (7,5) After Translation 5 10 X Y (7,1) (10,1)

11 Scaling (relative to the origin) Scale a point P(x,y) by S(sx, sy)
Algebraic: x’=sx* x y’=sy* y Matrix: Logic: P’ = SP or P’ = S(sx, sy)P Scale a line P0P1 (scale each point) P0’=SP0 P1’=SP1

12 Scale a shape: scale every vertex of the shape. Visual representation
5 10 X Y After Scaling (2,5/4) (7/2,5/4) 5 10 X Y Before Scaling (4,5) (7,5) Uniform Scaling: sx=sy

13 Rotate (around the origin)
Positive angles are measured counterclockwise from x axis to y axis. Rotate point (x,y) around the origin Algebraic representation: x’ = x * cos - y * sin y’ = x * sin + y * cos Matrix representation: Logic representation: P’ = R P

14 Visual representation
5 10 X Y 5 10 X Y Before After Rotate a shape: rotate every vertex of the shape 5 10 X Y (2.1, 4.9) (4.9, 7.8) (5,2) (9,2) Before Rotation After Rotation

15 Summary Translation: P’ = P + D Scaling: P’ = S P Rotation: P’ = R P
Homogeneous Coordinates: P(x,y,w) (x,y) to (x,y,w) : (x,y,w) to (x,y)

16 y’= y + dy w’=1 x’= x + dx P’’ = T(dx2 , dy2)P’
= T(dx2 , dy2) T(dx1 , dy1) P = T(dx2+dx1, dy2+dy1) P

17 Scaling P’=S(Sx, Sy)P P’’ = S(Sx2 , Sy2)P’
= S(Sx2 , Sy2)S(Sx1 , Sy1) P = S(Sx2Sx1, Sy2Sy1)P

18 P’’=R(2)R(1)PP”=R(2+1)P
Rotation   P’=R()P P’’=R(2)R(1)PP”=R(2+1)P

19 Shear Transformation: SHx(a) and SHy(b) P’=SHx(a)P
Shear in x against y by a (or an angle). x’ = x+ay y’ = y w’=1

20 P’=SHy(b)P Shear in y against x by b (or an angle). x’=x y’=y + bx
w’=1.

21 5 10 X Y 5 10 X Y Sheared in x 5 10 X Y Before Shear Sheared in y

22 Rigid-body Transformation: T and R.
change: location, orientation; not change: size, angle between elements. Affine Transformation: S, SH change: size, location, angle; not change: line (parallelism). Note: uniform scaling is between the two. It changes size but not angle. So far, our S, R, SH are all around the origin.

23 Composition of 2D Transformation
Rotate the house around P1 For every vertex (P) on the object: P’ = T(P1)R()T(-P1)P y y x After translation of P1 to origin y x After rotation y x P1 After translation To P1

24 Scale and rotate the house around P1 and move it to P2
y x P1 Original house Translate P1 to origin Scale Rotate P2 Translate to final position P2

25 For every vertex (P) on the object:
P’ = T(P2) R()S(Sx,Sy)T(-P1)P. Swap the order of operations: not permitted, except uniform scaling (sx=sy) can be swapped with rotation.

26 Window-to-Viewport Transformation
world-coordinate: inches, feet etc & screen-coordinate: pixels y World coordinates Window x Screen coordinates Viewport 1 Viewport 2 Window in world coordinates Window translated to origin Window scale to size of viewport Translated by (u,v) to final position Maximum range of screen coordinates

27 Matrix Representation of 3D Transformation
y z Translation: Scaling:

28 Rotation, around Z-axis:
Rotation, around X-axis: Rotation, around Y-axis:

29 Projection: Project 3D objects on to a 2D surface
(0,0,0) d z P( x, y, z ) x P’(xp, yp, zp) xp Projection Plane (View Plane)

30 xp= x’ / w’ = x / (z/d + 1) yp= y’ / w’ = y / (z/d + 1)

31 Foreshortening: The size of the projected object becomes smaller when the object moves away from the eye. z P’1 P’2 P1 P2 Perspective Projection: the projection that has the foreshortening effect.

32 For computer-aided design (CAD), we can not have foreshortening
For computer-aided design (CAD), we can not have foreshortening. A meter long object should always measures to 1 meter regardless where it is. Parallel Projection: d  , lines of sight become parallel P1 z P2 View Plan (0,0,0)

33 Summary 2D GT Homogeneous coordinates 3D GT Rigid body transformation
Affine transformation Perspective Projection & Foreshortening Parallel Projection


Download ppt "GEOMETRIC TRANSFORMATIONS Yingcai Xiao"

Similar presentations


Ads by Google