2D Geometric Transformations Question : How do we represent a - - PDF document

2d geometric transformations
SMART_READER_LITE
LIVE PREVIEW

2D Geometric Transformations Question : How do we represent a - - PDF document

2D Geometric Transformations (Chapter 5 in FVD) 1 2D Geometric Transformations Question : How do we represent a geometric object in the plane? Answer : For now, assume that objects consist of points and lines. A point is represented


slide-1
SLIDE 1

1

2D Geometric Transformations

(Chapter 5 in FVD)

2

2D Geometric Transformations

  • Question: How do we represent a

geometric object in the plane?

  • Answer: For now, assume that
  • bjects consist of points and lines.

A point is represented by its Cartesian coordinates: (x,y).

  • Question: How do we transform a

geometric object in the plane?

  • Answer: Let (A,B) be a straight line

segment and T a general 2D transformation: T transforms (A,B) into another straight line segment (A’,B’), where A’=TA and B’=TB.

slide-2
SLIDE 2

3

Translation

  • Translate (a,b): (x,y) (x+a,y+b)

Translate(2,4)

4

Scale

  • Scale (a,b): (x,y) (ax,by)

Scale (2,3) Scale (2,3)

slide-3
SLIDE 3

5

  • How can we scale an object

without moving its origin (lower left corner)?

Translate(-1,-1) Translate(1,1) Scale(2,3)

6

Reflection

Scale(-1,1) Scale(1,-1)

slide-4
SLIDE 4

7

Rotation

  • Rotate(θ):

(x,y) (x cos(θ)+y sin(θ), -x sin(θ)+y cos(θ))

Rotate(90) Rotate(90)

8

  • How can we rotate an object

without moving its origin (lower left corner)?

Translate(-1,-1) Translate(1,1) Rotate(90)

slide-5
SLIDE 5

9

Shear

  • Shear (a,b): (x,y) (x+ay,y+bx)

Shear(1,0) Shear(0,2)

10

Composition of Transformations

  • Rigid transformation:

– Translation + Rotation (distance preserving).

  • Similarity transformation:

– Translation + Rotation + uniform Scale (angle preserving).

  • Affine transformation:

– Translation + Rotation + Scale + Shear (parallelism preserving).

  • All above transformations are groups

where Rigid ⊂ Similarity ⊂ Affine.

slide-6
SLIDE 6

11

Matrix Notation

  • Let’s treat a point (x,y) as a 2x1

matrix (a column vector):

  • What happens when this vector is

multiplied by a 2x2 matrix?

      y x

      + + =             dy cx by ax y x d c b a

12

2D Transformations

  • 2D object is represented by points

and lines that join them.

  • Transformations can be applied
  • nly to the the points defining the

lines.

  • A point (x,y) is represented by a

2x1 column vector, and we can represent 2D transformations using 2x2 matrices:

            =       x d b a x ' '

slide-7
SLIDE 7

13

Scale

  • Scale(a,b): (x,y) (ax,by)
  • If a or b are negative, we get

reflection.

      =             by ax y x b a

14

Reflection

  • Reflection through the y axis:
  • Reflection through the x axis:
  • Reflection through y=x:
  • Reflection through y=-x:

     − 1 1       −1 1

      1 1

      − − 1 1

slide-8
SLIDE 8

15

Shear, Rotation

  • Shear(a,b): (x,y) (x+ay,y+bx)
  • Rotate(θ):

(x,y) (xcosθ+ysinθ , -xsinθ + ycosθ)

      + + =             bx y ay x y x b a 1 1

      + − + =             − θ θ θ θ θ θ θ θ cos sin sin cos cos sin sin cos y x y x y x

16

Composition of Transformations

  • A sequence of transformations

can be collapsed into a single matrix:

  • Note: order of transformations is

important! (otherwise - commutative groups)

[ ][ ][ ] [ ]

      =       y x D y x C B A

translate rotate rotate translate

slide-9
SLIDE 9

17

Translation

  • Translation(a,b):
  • Problem: Cannot represent

translation using 2x2 matrices.

  • Solution:

Homogeneous Coordinates

      + + →       b y a x y x

18

Homogeneous Coordinates

  • Homogeneous Coordinates is a

mapping from Rn to Rn+1:

  • Note: (tx,ty,t) all correspond to

the same non-homogeneous point (x,y). E.g. (2,3,1)≡(6,9,3).

  • Inverse mapping:

) , , ( ) , , ( ) , ( t ty tx W Y X y x = →

      → W Y W X W Y X , ) , , (

slide-10
SLIDE 10

19

Translation

  • Translate(a,b):
  • Affine transformation now have

the following form:

          + + =                     1 1 1 1 1 b y a x y x b a

          1 f d c e b a

20

(X,Y,W)

y x

X Y W 1

(X,Y,1)

Geometric Interpretation

  • A 2D point is mapped to a line

(ray) in 3D. The non-homogeneous points are obtained by projecting the rays onto the plane Z=1.

slide-11
SLIDE 11

21

  • Example: Rotation about an

arbitrary point:

  • Actions:

– Translate the coordinates so that the

  • rigin is at (x0,y0).

– Rotate by θ. – Translate back.

(x0,y0) θ

                    − − + − − = =                     − −           −           1 1 sin ) cos 1 ( cos sin sin ) cos 1 ( sin cos 1 1 1 1 1 cos sin sin cos 1 1 1 y x x y y x y x y x y x θ θ θ θ θ θ θ θ θ θ θ θ

22

  • Another example: Reflection

about an Arbitrary Line:

  • Actions:

– Translate the coordinates so that P1 is at the origin. – Rotate so that L aligns with the x- axis. – Reflect about the x-axis. – Rotate back. – Translate back.

p1 p2

L=p1+t (p2-p1)=t p2+(1-t) p1

slide-12
SLIDE 12

23

Viewing in 2D

World Coordinates

Object in World

World Coordinate Window

Device Coordinates

Device Coordinate Viewport

2D:2D mapping

(Chapter 6 in FVD)

3 D : 2 D m a p p i n g

  • Objects are given in world coordinates.
  • The world is viewed through a world-

coordinate window.

  • The WC window is mapped onto a

device coordinate viewport.

24

Viewing in 2D (cont.)

World Coordinates

Window

Screen Coordinates

Viewport

Maximum range

  • f screen

coordinates

(Device Coordinates) Window to Viewport Transformation

slide-13
SLIDE 13

25 (xmin,ymin) (xmax,ymax) (umin,vmin) (umax,vmax)

Window in World Coordinates Window translated to origin Window scaled to viewport size. Translated to viewport position in screen coordinates.

Window to Viewport Transformation

Mwv = T(umin,vmin) S( , ) T(-xmin,-ymin)

umax-umin xmax-xmin vmax-vmin ymax-ymin

1 0 umin 0 1 vmin 0 0 1 1 0 -xmin 0 1 -ymin 0 0 1 0 0 0 0 0 0 1

umax-umin xmax-xmin vmax-vmin ymax-ymin

= 0 0 1

umax-umin xmax-xmin vmax-vmin ymax-ymin umax-umin xmax-xmin(-xmin) + umin vmax-vmin ymax-ymin(-ymin) + vmin

=