Top Banner
Transformations
59

Transformations - Technionwebcourse.cs.technion.ac.il/.../ho/WCFiles/02_Transformations.pdfTransformations • Transforming an object = transforming all its points • For a polygon

Sep 20, 2019

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Transformations - Technionwebcourse.cs.technion.ac.il/.../ho/WCFiles/02_Transformations.pdfTransformations • Transforming an object = transforming all its points • For a polygon

Transformations

Page 2: Transformations - Technionwebcourse.cs.technion.ac.il/.../ho/WCFiles/02_Transformations.pdfTransformations • Transforming an object = transforming all its points • For a polygon

Specifying Complex Scenes

(x,y,z) y(rx,ry,rz)

(0,0,0)2

Page 3: Transformations - Technionwebcourse.cs.technion.ac.il/.../ho/WCFiles/02_Transformations.pdfTransformations • Transforming an object = transforming all its points • For a polygon

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

Page 4: Transformations - Technionwebcourse.cs.technion.ac.il/.../ho/WCFiles/02_Transformations.pdfTransformations • Transforming an object = transforming all its points • For a polygon

Transformations

• Transforming an object  = transforming all its points

• For a polygon  =  transforming its vertices

4

Page 5: Transformations - Technionwebcourse.cs.technion.ac.il/.../ho/WCFiles/02_Transformations.pdfTransformations • Transforming an object = transforming all its points • For a polygon

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

Page 6: Transformations - Technionwebcourse.cs.technion.ac.il/.../ho/WCFiles/02_Transformations.pdfTransformations • Transforming an object = transforming all its points • For a polygon

ScalingMatrix Form

• Independent in  and – Non‐uniform scaling is allowed

,

6

Page 7: Transformations - Technionwebcourse.cs.technion.ac.il/.../ho/WCFiles/02_Transformations.pdfTransformations • Transforming an object = transforming all its points • For a polygon

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

Page 8: Transformations - Technionwebcourse.cs.technion.ac.il/.../ho/WCFiles/02_Transformations.pdfTransformations • Transforming an object = transforming all its points • For a polygon

Rotation

• Matrix form:

• Rotation operator  with parameter  :

8

Page 9: Transformations - Technionwebcourse.cs.technion.ac.il/.../ho/WCFiles/02_Transformations.pdfTransformations • Transforming an object = transforming all its points • For a polygon

Rotation Properties

• is orthogonal

• Rotation by  is

cos sinsin cos

9

Page 10: Transformations - Technionwebcourse.cs.technion.ac.il/.../ho/WCFiles/02_Transformations.pdfTransformations • Transforming an object = transforming all its points • For a polygon

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

Page 11: Transformations - Technionwebcourse.cs.technion.ac.il/.../ho/WCFiles/02_Transformations.pdfTransformations • Transforming an object = transforming all its points • For a polygon

Homogeneous Coordinates in 

• Points of the form

• Where we identify

• For all nonzero 

11

Page 12: Transformations - Technionwebcourse.cs.technion.ac.il/.../ho/WCFiles/02_Transformations.pdfTransformations • Transforming an object = transforming all its points • For a polygon

Conversion Formulae

• From Euclidean to homogeneous

• From homogeneous to Euclidean

12

Page 13: Transformations - Technionwebcourse.cs.technion.ac.il/.../ho/WCFiles/02_Transformations.pdfTransformations • Transforming an object = transforming all its points • For a polygon

Example

• In homogeneous coordinates 

13

Page 14: Transformations - Technionwebcourse.cs.technion.ac.il/.../ho/WCFiles/02_Transformations.pdfTransformations • Transforming an object = transforming all its points • For a polygon

Translation usingHomogeneous Coordinates 

,

14

Page 15: Transformations - Technionwebcourse.cs.technion.ac.il/.../ho/WCFiles/02_Transformations.pdfTransformations • Transforming an object = transforming all its points • For a polygon

Matrix Form

Why bother writing transformations in matrix form?

15

Page 16: Transformations - Technionwebcourse.cs.technion.ac.il/.../ho/WCFiles/02_Transformations.pdfTransformations • Transforming an object = transforming all its points • For a polygon

Transformation Composition

What operation rotates by  around  ?– Translate  to origin– Rotate around origin by – Translate back

16

P P

16

Page 17: Transformations - Technionwebcourse.cs.technion.ac.il/.../ho/WCFiles/02_Transformations.pdfTransformations • Transforming an object = transforming all its points • For a polygon

Transformation Composition

• performs one transformation• performs a second transformation

• performs the composed transformation

17

Page 18: Transformations - Technionwebcourse.cs.technion.ac.il/.../ho/WCFiles/02_Transformations.pdfTransformations • Transforming an object = transforming all its points • For a polygon

Transformation Composition

, ,

18

Page 19: Transformations - Technionwebcourse.cs.technion.ac.il/.../ho/WCFiles/02_Transformations.pdfTransformations • Transforming an object = transforming all its points • For a polygon

Transformation Quiz

• What do these Euclidean transformations do?

19

Page 20: Transformations - Technionwebcourse.cs.technion.ac.il/.../ho/WCFiles/02_Transformations.pdfTransformations • Transforming an object = transforming all its points • For a polygon

Transformation Quiz

• And these homogeneous ones?

20

Page 21: Transformations - Technionwebcourse.cs.technion.ac.il/.../ho/WCFiles/02_Transformations.pdfTransformations • Transforming an object = transforming all its points • For a polygon

Transformation Quiz

• Can one rotate in the plane by reflection?

• How can one reflect through an arbitrary line in the plane?

21

Page 22: Transformations - Technionwebcourse.cs.technion.ac.il/.../ho/WCFiles/02_Transformations.pdfTransformations • Transforming an object = transforming all its points • For a polygon

Arbitrary Reflection

• Shift by • Rotate by • Reflect through • Rotate by • Shift by 

, ,

22

,

Page 23: Transformations - Technionwebcourse.cs.technion.ac.il/.../ho/WCFiles/02_Transformations.pdfTransformations • Transforming an object = transforming all its points • For a polygon

Rotate by Shear

• Shear

• Rotation by  composition of 3 shears

23

Page 24: Transformations - Technionwebcourse.cs.technion.ac.il/.../ho/WCFiles/02_Transformations.pdfTransformations • Transforming an object = transforming all its points • For a polygon

Rotate by Shear

cos sinsin cos

11

• Solve for  , , :cos 1sin

• Solution:sin

tan 2• When is this useful?

24

Page 25: Transformations - Technionwebcourse.cs.technion.ac.il/.../ho/WCFiles/02_Transformations.pdfTransformations • Transforming an object = transforming all its points • For a polygon

Rotate by Shear

• Can we rotate with two (scaled) shears?

• What happens for  ?

25

Page 26: Transformations - Technionwebcourse.cs.technion.ac.il/.../ho/WCFiles/02_Transformations.pdfTransformations • Transforming an object = transforming all its points • For a polygon

Rotation Approximation• For small angles  we have:

cos → 1 and sin → (Taylor expansion of sin/cos)

• Can approximate:

Examples (steps of  ):

26

Page 27: Transformations - Technionwebcourse.cs.technion.ac.il/.../ho/WCFiles/02_Transformations.pdfTransformations • Transforming an object = transforming all its points • For a polygon

3D Transformations• All 2D transformations extend to 3D• In homogeneous coordinates:

, ,

1

, , ,1

11

1cos sinsin cos

1

1

• What is  ?  ?

27

Page 28: Transformations - Technionwebcourse.cs.technion.ac.il/.../ho/WCFiles/02_Transformations.pdfTransformations • Transforming an object = transforming all its points • For a polygon

3D Transformations

• Questions (commutativity):

– Scaling:        Is S1S2 = S2S1?

– Translation:  Is T1T2 = T2T1?

– Rotation:       Is R1R2 = R2R1?

28

Page 29: Transformations - Technionwebcourse.cs.technion.ac.il/.../ho/WCFiles/02_Transformations.pdfTransformations • Transforming an object = transforming all its points • For a polygon

3D Coordinate Systems

29

left right

Page 30: Transformations - Technionwebcourse.cs.technion.ac.il/.../ho/WCFiles/02_Transformations.pdfTransformations • Transforming an object = transforming all its points • For a polygon

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

Page 31: Transformations - Technionwebcourse.cs.technion.ac.il/.../ho/WCFiles/02_Transformations.pdfTransformations • Transforming an object = transforming all its points • For a polygon

Arbitrary Rotation• Answer: 

– Transformation matrix R whose columns are U, V, W:

• Proof:

• Similarly  R(Y) = V and R(Z) = W31

Page 32: Transformations - Technionwebcourse.cs.technion.ac.il/.../ho/WCFiles/02_Transformations.pdfTransformations • Transforming an object = transforming all its points • For a polygon

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

Page 33: Transformations - Technionwebcourse.cs.technion.ac.il/.../ho/WCFiles/02_Transformations.pdfTransformations • Transforming an object = transforming all its points • For a polygon

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

Page 34: Transformations - Technionwebcourse.cs.technion.ac.il/.../ho/WCFiles/02_Transformations.pdfTransformations • Transforming an object = transforming all its points • For a polygon

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

Page 35: Transformations - Technionwebcourse.cs.technion.ac.il/.../ho/WCFiles/02_Transformations.pdfTransformations • Transforming an object = transforming all its points • For a polygon

Parallel Projection

35

Page 36: Transformations - Technionwebcourse.cs.technion.ac.il/.../ho/WCFiles/02_Transformations.pdfTransformations • Transforming an object = transforming all its points • For a polygon

Parallel ProjectionProjectors are all parallel

– Orthographic: Projectors perpendicular to projection plane– Axonometric: Rotation + translation + orthographic projection

36

Page 37: Transformations - Technionwebcourse.cs.technion.ac.il/.../ho/WCFiles/02_Transformations.pdfTransformations • Transforming an object = transforming all its points • For a polygon

Pinhole Camera Model

37

Page 38: Transformations - Technionwebcourse.cs.technion.ac.il/.../ho/WCFiles/02_Transformations.pdfTransformations • Transforming an object = transforming all its points • For a polygon

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

Page 39: Transformations - Technionwebcourse.cs.technion.ac.il/.../ho/WCFiles/02_Transformations.pdfTransformations • Transforming an object = transforming all its points • For a polygon

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

Page 40: Transformations - Technionwebcourse.cs.technion.ac.il/.../ho/WCFiles/02_Transformations.pdfTransformations • Transforming an object = transforming all its points • For a polygon

40

Page 41: Transformations - Technionwebcourse.cs.technion.ac.il/.../ho/WCFiles/02_Transformations.pdfTransformations • Transforming an object = transforming all its points • For a polygon

original

41

Page 42: Transformations - Technionwebcourse.cs.technion.ac.il/.../ho/WCFiles/02_Transformations.pdfTransformations • Transforming an object = transforming all its points • For a polygon

Scale Dolly

42

Page 43: Transformations - Technionwebcourse.cs.technion.ac.il/.../ho/WCFiles/02_Transformations.pdfTransformations • Transforming an object = transforming all its points • For a polygon

Perspective ProjectionWhat is the difference between:• Moving the projection plane• Moving the viewpoint (center of projection)

Z

Z

y yyScale Dolly

Zz z z43

Page 44: Transformations - Technionwebcourse.cs.technion.ac.il/.../ho/WCFiles/02_Transformations.pdfTransformations • Transforming an object = transforming all its points • For a polygon

Examples

Orthographic view                 Perspective view

44

Page 45: Transformations - Technionwebcourse.cs.technion.ac.il/.../ho/WCFiles/02_Transformations.pdfTransformations • Transforming an object = transforming all its points • For a polygon

Perspective Warp• Matrix formulation 

d

zd

dzyx

dd

dddzyx ,)(,,

000

10000100001

)1,,,(

zd

zddz

ydz

xzyx ppp 2

,/

,/

),,(

45

Page 46: Transformations - Technionwebcourse.cs.technion.ac.il/.../ho/WCFiles/02_Transformations.pdfTransformations • Transforming an object = transforming all its points • For a polygon

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

Page 47: Transformations - Technionwebcourse.cs.technion.ac.il/.../ho/WCFiles/02_Transformations.pdfTransformations • Transforming an object = transforming all its points • For a polygon

Perspective Warp

47

Page 48: Transformations - Technionwebcourse.cs.technion.ac.il/.../ho/WCFiles/02_Transformations.pdfTransformations • Transforming an object = transforming all its points • For a polygon

QuizWhich transformation preserves which geometric form ?

linesparallellines distance angles normals convexity conics

scaling

rotation

translation

shear

perspective

48

Page 49: Transformations - Technionwebcourse.cs.technion.ac.il/.../ho/WCFiles/02_Transformations.pdfTransformations • Transforming an object = transforming all its points • For a polygon

49

Page 50: Transformations - Technionwebcourse.cs.technion.ac.il/.../ho/WCFiles/02_Transformations.pdfTransformations • Transforming an object = transforming all its points • For a polygon

3D Sidewalk Art by Julian Beever

50

Page 51: Transformations - Technionwebcourse.cs.technion.ac.il/.../ho/WCFiles/02_Transformations.pdfTransformations • Transforming an object = transforming all its points • For a polygon

51

Page 52: Transformations - Technionwebcourse.cs.technion.ac.il/.../ho/WCFiles/02_Transformations.pdfTransformations • Transforming an object = transforming all its points • For a polygon

52

Page 53: Transformations - Technionwebcourse.cs.technion.ac.il/.../ho/WCFiles/02_Transformations.pdfTransformations • Transforming an object = transforming all its points • For a polygon

53

Page 54: Transformations - Technionwebcourse.cs.technion.ac.il/.../ho/WCFiles/02_Transformations.pdfTransformations • Transforming an object = transforming all its points • For a polygon

54

Page 55: Transformations - Technionwebcourse.cs.technion.ac.il/.../ho/WCFiles/02_Transformations.pdfTransformations • Transforming an object = transforming all its points • For a polygon

55

Page 56: Transformations - Technionwebcourse.cs.technion.ac.il/.../ho/WCFiles/02_Transformations.pdfTransformations • Transforming an object = transforming all its points • For a polygon

56

Page 57: Transformations - Technionwebcourse.cs.technion.ac.il/.../ho/WCFiles/02_Transformations.pdfTransformations • Transforming an object = transforming all its points • For a polygon

57

Page 58: Transformations - Technionwebcourse.cs.technion.ac.il/.../ho/WCFiles/02_Transformations.pdfTransformations • Transforming an object = transforming all its points • For a polygon

58

Page 59: Transformations - Technionwebcourse.cs.technion.ac.il/.../ho/WCFiles/02_Transformations.pdfTransformations • Transforming an object = transforming all its points • For a polygon

59