Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.

68
Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.

Transcript of Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.

Page 1: Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.

Geometric TransformationsHearn & Baker Chapter 5

Some slides are taken from Robert Thomsons notes.

Page 2: Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.

OVERVIEW

• Two dimensional transformations• Matrix representations• Inverse transformations• Three dimensional transformations

Page 3: Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.

Geometric transformation functions

• Translation• Rotation• Scaling• Reflection• Shearing

• We first discuss the 2D transformations, then we will continue with 3D.

Page 4: Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.

2D Translations

TPP

d

dT

y

xP

y

xP

dyydxx

yxP

yxPP

yx

Now

,,

torscolumn vec theDefine

axis.y toparallel d axis, x toparallel d distance a ),(Point totranslate

),,( as defined Point

y

x

yx

PP’

Page 5: Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.

2D Scaling from the origin.

y

x.

0

0

y

xor

Now

0

0

matrix theDefine

. ,.

axis.y thealong s and

axis, x thealong sfactor aby ),(Point to(stretch) scale a Perform

),,( as defined Point

y

x

y

x

y

x

yx

s

sPSP

s

sS

ysyxsx

yxP

yxPP

PP’

Page 6: Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.

2D Rotation about the origin.

y

x

r

r

P’(x’,y’)

P(x,y)

Page 7: Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.

2D Rotation about the origin.

y

x

r

r

P’(x’,y’)

P(x,y)

y

sin.

cos.

ry

rx

x

Page 8: Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.

2D Rotation about the origin.

y

x

r

r

P’(x’,y’)

P(x,y)

y

sin.

cos.

ry

rx

x

cos.sin.sin.cos.)sin(.

sin.sin.cos.cos.)cos(.

rrry

rrrx

Page 9: Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.

2D Rotation about the origin.

sin.

cos.

ry

rx

cos.sin.sin.cos.)sin(.

sin.sin.cos.cos.)cos(.

rrry

rrrx

Substituting for r :

Gives us :

cos.sin.

sin.cos.

yxy

yxx

Page 10: Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.

2D Rotation about the origin.

cos.sin.

sin.cos.

yxy

yxx

Rewriting in matrix form gives us :

y

x

y

x.

cossin

sincos

PRPR

,

cossin

sincosmatrix theDefine

Page 11: Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.

Transformations.

• Translation.– P=T + P

• Scale– P=S P

• Rotation– P=R P

• We would like all transformations to be multiplications so we can concatenate them express points in homogenous

coordinates.

Page 12: Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.

Homogeneous coordinates

• Add an extra coordinate, W, to a point.– P(x,y,W).

• Two sets of homogeneous coordinates represent the same point if they are a multiple of each other.– (2,5,3) and (4,10,6) represent the same point.

• At least one component must be non-zero (0,0,0) is not defined.

• If W 0 , divide by it to get Cartesian coordinates of point (x/W,y/W,1).

• If W=0, point is said to be at infinity.

Page 13: Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.

Homogeneous coordinates

• If we represent (x,y,W) in 3-space, all triples representing the same point describe a line passing through the origin.

• If we homogenize the point, we get a point of form (x,y,1)– homogenised points form a plane at W=1.

P

X

Y

W

W=1 plane

Page 14: Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.

Translations in homogenised coordinates

• Transformation matrices for 2D translation are now 3x3.

1

.

100

10

01

1

y

x

d

d

y

x

y

x

11

y

x

dyy

dxx

Page 15: Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.

Concatenation.

• We perform 2 translations on the same point:

),(),(),(

:expect weSo

),(),(),(

),(

),(

21212211

21212211

22

11

yyxxyxyx

yyxxyxyx

yx

yx

ddddTddTddT

ddddTPddTddTPP

ddTPP

ddTPP

Page 16: Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.

Concatenation.

?

100

10

01

.

100

10

01

: is ),(),(product matrix The

2

2

1

1

2211

y

x

y

x

yxyx

d

d

d

d

ddTddT

Matrix product is variously referred to as compounding, concatenation, or composition

Page 17: Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.

Concatenation.

Matrix product is variously referred to as compounding, concatenation, or composition.This single matrix is called the Coordinate Transformation Matrix or CTM.

100

10

01

100

10

01

.

100

10

01

: is ),(),(product matrix The

21

21

2

2

1

1

2211

yy

xx

y

x

y

x

yxyx

dd

dd

d

d

d

d

ddTddT

Page 18: Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.

Properties of translations.

),(),(T 4.

),(),(),(),( 3.

),(),(),( 2.

)0,0( 1.

1-yxyx

yxyxyxyx

yyxxyxyx

ssTss

ssTttTttTssT

tstsTttTssT

IT

Note : 3. translation matrices are commutative.

Page 19: Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.

Homogeneous form of scale.

y

xyx s

sssS

0

0),(

Recall the (x,y) form of Scale :

100

00

00

),( y

x

yx s

s

ssS

In homogeneous coordinates :

Page 20: Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.

Concatenation of scales.

!multiply easy to -matrix in the elements diagonalOnly

100

0ss0

00ss

100

0s0

00s

.

100

0s0

00s

: is ),(),(product matrix The

y2y1

x2x1

y2

x2

y1

x1

2211

yxyx ssSssS

Page 21: Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.

Reflection

corresponds to negative scale factors

originalsx = -1 sy = 1

sx = -1 sy = -1 sx = 1 sy = -1

Page 22: Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.

Homogeneous form of rotation.

1

.

100

0cossin

0sincos

1

y

x

y

x

)()(

: i.e ,orthogonal are matricesRotation

).()(

matrices,rotation For

1

1

TRR

RR

i.e. the inverse is the transpose

Page 23: Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.

Orthogonality of rotation matrices.

100

0cossin

0sincos

)( ,

100

0cossin

0sincos

)(

TRR

100

0cossin

0sincos

100

0cossin

0sincos

)(

R

Page 24: Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.

Other properties of rotation.

matters.order Otherwise

same, thearerotation of centres theifonly

)()()()(

and

)()()(

)0(

RRRR

RRR

IR

Page 25: Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.
Page 26: Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.

2D Composite Transformations

• Combine transformations of different type– translate, rotate, translate– translate, scale, translate– translate, reflect, translate

• Use to rotate or scale an object w.r.t. a point that is not the origin

• Implement by multiplication of the corresponding homogeneous matrices

Page 27: Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.
Page 28: Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.
Page 29: Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.
Page 30: Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.
Page 31: Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.
Page 32: Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.

reflection in x and y axes reflection in origin

Page 33: Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.

1 0

1

x x

y xb b y

1

0 1

x x y

y y

a a

Shx gives the slope of a vertical line after shear, as dx/dy

Page 34: Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.

Example 1

y

yx

x

y

xyxT

4.0

14.0

01),(

)1,0(

)0,1(

)1,1(

)0,0(

S

x

Page 35: Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.

Example 1

x

y

yx

x

yxT

4.0

),(

S

)1,0(

)0,1(

)1,1(

)0,0(

Page 36: Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.

Example 1

y

)1,0(

)4.0,1(

)0,0(

T(S)

yx

x

yxT

4.0

),()4.1,1(

x

Page 37: Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.

Example 2

0.6

0.6

1( , )

0 1

xT x y

y

x y

y

y

Sx

)1,0(

)0,1(

)1,1(

)0,0(

Page 38: Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.

Example 2

0.6( , )

x yT x y

y

x

y

S

)1,0(

)0,1(

)1,1(

)0,0(

Page 39: Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.

Example 2

( , ) 0.6x y

T x yy

x

y

)1,0(

)0,1()0,0(

T(S)

(0.6,1) (1.6,1)

Page 40: Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.

Summary

Shear in x:

Shear in y:

y

yshx

y

xshSh xx

x 10

1

yxsh

x

y

x

shSh

yyy .1

01

Page 41: Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.

Double Shear: not commutative!

ab)(10

1

1

01

1

1

b

aa

b

1

1 ab)(

1

01

10

1

b

a

b

a

Page 42: Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.

Shear Matrix defined by angle, not slope

e.g. simple shear along x axis

x’ = x + y cot y’ = yz’ = z

1000

0100

0010

00cot 1

H() =

Page 43: Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.
Page 44: Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.
Page 45: Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.
Page 46: Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.
Page 47: Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.
Page 48: Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.

3D Transformations.

• Use homogeneous coordinates, just as in 2D case.• Transformations are now 4x4 matrices.• We will use a right-handed (world) coordinate system -

( z out of page ).

z (out of page)

y

x

Note:Convenient to think of display asBeing left-handed !!( z into the screen )

Page 49: Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.

Simple extension to the 3D case:

Page 50: Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.

Scale in 3D.

1000

000

000

000

),,(z

y

x

zyx s

s

s

sssS

Simple extension to the 3D case:

Page 51: Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.

Rotation in 3D

• Need to specify which axis the rotation is about.• z-axis rotation is the same as the 2D case.

1000

0100

00cossin

00sincos

)(

zR

Page 52: Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.
Page 53: Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.
Page 54: Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.
Page 55: Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.

Rotation around an axis parallel to x-axis

Page 56: Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.
Page 57: Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.
Page 58: Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.
Page 59: Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.
Page 60: Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.
Page 61: Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.

H&B p271

Page 62: Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.

Rows of upper-left 3x3 submatrix, when rotated by R lie on the x,y and z axes

1

1

0

0

1

1

0

1

0

1

1

0

0

1

1

33

32

31

23

22

21

13

12

11

r

r

r

Rr

r

r

Rr

r

r

R

Page 63: Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.
Page 64: Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.

Scaling an object with this transformation will also move its position relative to the origin - so move it to the origin, scale it, then move it back...

Page 65: Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.
Page 66: Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.
Page 67: Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.
Page 68: Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.