transformations -...

Post on 20-Sep-2019

1 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Transformations

Specifying Complex Scenes

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

(0,0,0)2

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

ScalingMatrix Form

• Independent in  and – Non‐uniform scaling is allowed

,

6

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

Rotation

• Matrix form:

• Rotation operator  with parameter  :

8

Rotation Properties

• is orthogonal

• Rotation by  is

cos sinsin cos

9

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

Homogeneous Coordinates in 

• Points of the form

• Where we identify

• For all nonzero 

11

Conversion Formulae

• From Euclidean to homogeneous

• From homogeneous to Euclidean

12

Example

• In homogeneous coordinates 

13

Translation usingHomogeneous Coordinates 

,

14

Matrix Form

Why bother writing transformations in matrix form?

15

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 Composition

, ,

18

Transformation Quiz

• What do these Euclidean transformations do?

19

Transformation Quiz

• And these homogeneous ones?

20

Transformation Quiz

• Can one rotate in the plane by reflection?

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

21

Arbitrary Reflection

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

, ,

22

,

Rotate by Shear

• Shear

• Rotation by  composition of 3 shears

23

Rotate by Shear

cos sinsin cos

11

• Solve for  , , :cos 1sin

• Solution:sin

tan 2• When is this useful?

24

Rotate by Shear

• Can we rotate with two (scaled) shears?

• What happens for  ?

25

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

3D Coordinate Systems

29

left right

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 Projection

35

Parallel ProjectionProjectors are all parallel

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

36

Pinhole Camera Model

37

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

40

original

41

Scale Dolly

42

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

Z

Z

y yyScale Dolly

Zz z z43

Examples

Orthographic view                 Perspective view

44

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

Perspective Warp

47

QuizWhich transformation preserves which geometric form ?

linesparallellines distance angles normals convexity conics

scaling

rotation

translation

shear

perspective

48

49

3D Sidewalk Art by Julian Beever

50

51

52

53

54

55

56

57

58

59

top related