# Transformations - Technion – Israel Institute of ?· Geometric Transformations Transformation τis…

• View
212

0

Embed Size (px)

Transcript

• TransformationsTransformations

• Geometric Transformations

Transformation is one-to-one and onto mapping of Rn to itself (in general)

Affine transformation (V) = AV+bA matrix

b scalar

Transformations Transformations -- Center for Graphics and Geometric Computing, Center for Graphics and Geometric Computing,

TechnionTechnion

3

b scalar

In CG Geometric Transformations are, for the most

part, affine transformations with geometric meaning

Note: transformation has meaning only for vectors for point P, (P) is a transformation of vector from the origin to P

• Transformations

Transforming an object = transforming all its points

For a polygonal model = transforming its vertices

Is it true for any transformation?

Why is it true for us?

Transformations Transformations -- Center for Graphics and Geometric Computing, Center for Graphics and Geometric Computing,

TechnionTechnion

4

• Applications

Viewing

Modeling

Animation

Transformations Transformations -- Center for Graphics and Geometric Computing, Center for Graphics and Geometric Computing,

TechnionTechnion

5

Animation

Image manipulation

• Scaling

V = (vx,vy) vector in XY plane

Scaling operator S with parameters (sx,sy):

( )( ) ( )yyxxss svsvVS yx ,, =

Transformations Transformations -- Center for Graphics and Geometric Computing, Center for Graphics and Geometric Computing,

TechnionTechnion

6

( ) ( )yyxx svsvVS ,=

• Scaling Matrix form:

( )( ) ( ) ( )yyxxy

x

yx

sssvsv

s

svvVS yx ,

0

0,

, =

=

Transformations Transformations -- Center for Graphics and Geometric Computing, Center for Graphics and Geometric Computing,

TechnionTechnion

7

Independent in x and y

Non uniform scaling is allowed

What is the meaning of scaling by zero?

• Rotation

Polar form:

W

y

V

x

r

Transformations Transformations -- Center for Graphics and Geometric Computing, Center for Graphics and Geometric Computing,

TechnionTechnion

8

Polar form:

V=(vx,vy)=(r cos, r sin) Rotating V anti-clockwise by to W:

)cossinsincos

,sinsincoscos(

))sin(),cos((

),(

rr

rr

rr

yw

xwW

+=

++=

=

• Rotation

Matrix form:

=

=

cossin

sincos

cossin

sincos)sin,cos(

V

rrW

)cossinsincos

,sinsincoscos(

rr

rrW

+=

Transformations Transformations -- Center for Graphics and Geometric Computing, Center for Graphics and Geometric Computing,

TechnionTechnion

9

Rotation operator R with parameter at the origin:

=

cossin

sincosR

• Rotation Properties

R is orthogonal

R- - rotation by - is

( ) ( )TRR =1

Transformations Transformations -- Center for Graphics and Geometric Computing, Center for Graphics and Geometric Computing,

TechnionTechnion

10

R - rotation by - is

( ) 1cossin

sincos),()(

=

=

RvvVR yx

• Translation

Transformations Transformations -- Center for Graphics and Geometric Computing, Center for Graphics and Geometric Computing,

TechnionTechnion

11

Translation operator T with parameters (tx,ty):

Can you express T in a matrix form?

( )( ) ( )yyxxtt tvtvVT yx ++= ,,

• Translation - Homogeneous

Coordinates To represent T in matrix form

introduce homogeneous

coordinates:

Conversion (projection) from

( ) ( )1,,,, hyhxhwhyhxh vvvvvV ==

Transformations Transformations -- Center for Graphics and Geometric Computing, Center for Graphics and Geometric Computing,

TechnionTechnion

12

Conversion (projection) from

homogeneous space to

Euclidean:

In homogeneous

coordinates:

(2, 2, 1) = (4, 4, 2) = (1, 1, 0.5)

==

h

w

h

y

h

w

h

xyx

v

v

v

vvvV ,),(

• Translation

Using homogeneous coordinates, the translation

operator may be expressed as:

001

Transformations Transformations -- Center for Graphics and Geometric Computing, Center for Graphics and Geometric Computing,

TechnionTechnion

13

)1,,(

1

010

001

)1,,()(),(

yyxx

yx

yx

htt

tvtv

tt

vvVTyx

++=

=

• Matrix Form

Why did we insist on using a Matrix form to

represent the transformations?

Hint: How would you go about transforming

an object of m vertices through a sequence of

Transformations Transformations -- Center for Graphics and Geometric Computing, Center for Graphics and Geometric Computing,

TechnionTechnion

14

an object of m vertices through a sequence of

n transformations?

• Transformation Composition

What operation rotates XY by around P = (px,py) ?

Translate P to origin

Rotate around origin by

Transformations Transformations -- Center for Graphics and Geometric Computing, Center for Graphics and Geometric Computing,

TechnionTechnion

15

Rotate around origin by

Translate back

• Transformation Composition

=

0010sincos001

),(),( ppppTRT yxyx

Transformations Transformations -- Center for Graphics and Geometric Computing, Center for Graphics and Geometric Computing,

TechnionTechnion

16

1

010

100

0cossin-

1

010

yxyx pppp

• Transformations Quiz

What do these

transformations do?

And these homogeneous

ones?

01

10

01

5.000

010

001

1-00

010

001

Transformations Transformations -- Center for Graphics and Geometric Computing, Center for Graphics and Geometric Computing,

TechnionTechnion

17

How can one mirror a planar

object through an arbitrary

line in XY?

Can one rotate a planar

object in the XY plane via

mirroring?

10

1

11

01

10

01

10

a

• Rotate by Shear

Shear

Rotation by 0 /2 composition of 3 shears

1011sincos zx

1

01,

10

1,

10

11,

11

01

a

a

Transformations Transformations -- Center for Graphics and Geometric Computing, Center for Graphics and Geometric Computing,

TechnionTechnion

18

.1

1

10

1

1

1

10

1

1

01

10

1

cossin-

sincos

+

+++=

+=

=

yzy

xxyzzxy

z

y

xxy

z

y

x

• Rotate by Shear (cont.)

Solve for x, y, z :

cos = 1+xy = yz+1sin = y = z+xyz+x

.1

1

cossin-

sincos

+

+++=

yzy

xxyzzxy

Transformations Transformations -- Center for Graphics and Geometric Computing, Center for Graphics and Geometric Computing,

TechnionTechnion

19

Solution:

y = sin x = z = tan( / 2)

QuestionQuestion: When is rotation-using-three-shears useful?

QuestionQuestion: Can we derive a rotation via two shears?

• Rotate by Shear (cont.)

What does the composition of

the following two scaled shears

do?

=

sincos0secsin1

Transformations Transformations -- Center for Graphics and Geometric Computing, Center for Graphics and Geometric Computing,

TechnionTechnion

20

Why use it?

Is it convenient?

What happens when /2 ?

=

cossin-

sincos

1tan

0sec

cos0

sin1

• Rotation Approximation

For small angles can approximate:

x=x cos y sin x yy=x sin + y cos x + y

Since cos 1 and sin as 0 (Taylor expansion of sin/cos)

Example (steps of ):

Transformations Transformations -- Center for Graphics and Geometric Computing, Center for Graphics and Geometric Computing,

TechnionTechnion

21

When is this rotation approximation useful?

• App. rotation matrix

Matrix has to be orthogonal & normalized

Rotation Approximation

=1

1

AR

Transformations Transformations -- Center for Graphics and Geometric Computing, Center for Graphics and Geometric Computing,

TechnionTechnion

22

Matrix has to be orthogonal & normalized

AR is orthogonal

AR not normalized

Normalize

2

1

1

1

+=

= cAR

cc

cc

• 3D Transformations

All 2D transformations extend to 3D

In homogeneous coordinates:

Scale Translate Rotate (around z axis)

Transformations Transformations -- Center for Graphics and Geometric Computing, Center for Graphics and Geometric Computing,

TechnionTechnion

23

QuestionQuestion: What is ? ?

=

=

=

1000

0100

00cossin

00sincos

1

0100

0010

0001

1000

000

000

000

),,(),,(

z

zyx

ttt

z

y

x

sssR

ttt

Ts

s

s

S zyxzyx

xR

yR transformations

• 3D Transformations

Questions (commutativity):

Scaling: