Geometric Transformations

62
Geometric Transformations UBI 516 Advanced Computer Graphics Aydın Öztürk [email protected] http://ube.ege.edu.tr/~ozturk

description

UBI 516 Advanced Computer Graphics. Geometric Transformations. Aydın Öztürk ozturk @ ube.ege.edu.tr http:// ube.ege.edu.tr/~ozturk. Two Dimensional Geometric Transformations. Basic Transformations. Translation. P '. y. P. x. Basic Transformations. Rotation. y. P ′=(x′,y′). r. θ. - PowerPoint PPT Presentation

Transcript of Geometric Transformations

Page 1: Geometric Transformations

Geometric Transformations

UBI 516 Advanced Computer GraphicsUBI 516 Advanced Computer Graphics

Aydın Öztü[email protected]://ube.ege.edu.tr/~ozturk

Page 2: Geometric Transformations

Two Dimensional Geometric Transformations

Page 3: Geometric Transformations

Basic TransformationsBasic Transformations

Translation

P

P'

x

yyx tyytxx ','

y

x

t

t

y

x

y

xTP'P ,

'

',

TPP'

Page 4: Geometric Transformations

Basic Transformations

Rotation

x

y

y)(x,P θ

φ

)('

)('

rSiny

rCosx

)(),( rSinyrCosx

)()('

)()('

yCosxSiny

ySinxCosx

P′=(x′,y′)

r

Page 5: Geometric Transformations

Rotation (Cont.)

R.PP'

y

x

y

x

CosSin

SinCos

CosSin

SinCosR

'

'

Basic Transformations

Page 6: Geometric Transformations

Scaling

yx syysxx .',.'

PSP

'

.0

0

'

'

y

x

s

s

y

x

y

x

x

y

Basic Transformations

Page 7: Geometric Transformations

3x3 Matrix Representations

We can combine the multiplicative and translational terms for 2D transformations into a single matrix representation by expanding the 2x2 matrix representations to 3x3 matrices.

This allows us to express all transformation equations as matrix multiplications.

Page 8: Geometric Transformations

Homogeneous Coordinates

We represent each Cartesian coordinate position (x,y) with the homogeneous coordinate triple

where

),,( hyx hh

hy

yhx

x hh ,

Page 9: Geometric Transformations

Homogeneous Coordinates(cont.)

Thus, a general homogeneous coordinate representation can also be written as

For 2D transformations we choose h=1.

Each 2D position is represented with

homogeneous coordinates

),.,.( hyhxh

)1,,( yx

Page 10: Geometric Transformations

Translation in homogeneous coordinates

1

.

100

10

01

1

'

'

y

x

t

t

y

x

y

x

PTP ),(' yx tt

Page 11: Geometric Transformations

Rotation in homogeneous coordinates

1

.

100

0

0

1

'

'

y

x

CosSin

SinCos

y

x

PRP ).('

Page 12: Geometric Transformations

Scaling in homogeneous coordinates

1

.

100

00

00

1

'

'

y

x

s

s

y

x

y

x

PSP ).,(' yx ss

Page 13: Geometric Transformations

Composite Transformations:Translation

If two successive translation are applied to a point P, then the final transformed location P' is calculated as

100

10

01

100

10

01

.

100

10

01

21

21

1

1

2

2

yy

xx

y

x

y

x

tt

tt

t

t

t

t

PTPTTP ),(),(),('21211122 yyxxyxyx tttttttt

Page 14: Geometric Transformations

Composite Transformations:Rotation

100

0)()(

0)()(

100

0

0

.

100

0

0

2121

2121

11

11

22

22

CosSin

SinCos

CosSin

SinCos

CosSin

SinCos

PRP )(' 21

Page 15: Geometric Transformations

Composite Transformations:Scalings

100

00

00

100

00

00

100

00

00

21

21

1

1

2

2

yy

xx

y

x

y

x

ss

ss

s

s

s

s

),(),(),(21211122 yyxxyxyx ssssssss SSS

Page 16: Geometric Transformations

General Pivot Point Rotation

Steps:

-Translate the object so that the pivot point is moved to the coordinate origin.

-Rotate the object about the origin.

-Translate the object so that the pivot point is returned to its original position.

Page 17: Geometric Transformations

General Pivot Point Rotation(Cont.)

Page 18: Geometric Transformations

General Pivot Point Rotation(Cont.)

100

)1(

)1(

100

10

01

.

100

1

0

.

100

10

01

SinxCosyCosSin

SinyCosxSinCos

y

x

CosSin

SinCos

y

x

rr

rr

r

r

r

r

),,(),()(),( rrrrrr yxyxyx RTRT

Page 19: Geometric Transformations

General Fixed Point Scaling

Steps:

-Translate the object so that the fixed point coincides with the coordinate origin.

-Scale the object about the origin.

-Translate the object so that the pivot point is returned to its original position.

Page 20: Geometric Transformations

General Fixed Point Scaling

(xr, yr) (xr, yr)

Page 21: Geometric Transformations

General Fixed Point Scaling

100

)1(0

)1(0

100

10

01

.

100

00

00

.

100

10

01

yfy

xfx

f

f

y

x

f

f

sys

sxs

y

x

s

s

y

x

),,,(),(),(),( yxffffyxff ssyxyxssyx STST

Page 22: Geometric Transformations

Concatenation Properties

Matrix multiplication is associative

Transformation product is not commutative

)()( CBACBACBA

ABBA

Page 23: Geometric Transformations

OTHER TRANSFORMATIONS

Reflection

About x-axis About y-axis

x

y

1

2 3

2 3

1

100

010

001

100

010

001

Page 24: Geometric Transformations

OTHER TRANSFORMATIONS

x

y

1

2

3

2

1

3

100

010

001

Reflection about the origin

Page 25: Geometric Transformations

OTHER TRANSFORMATIONS

Reflection about the line y=x.

x

y2

2

1

3

100

001

010

y = x

2

3

Page 26: Geometric Transformations

OTHER TRANSFORMATIONS

100

010

01xhs

Shear

x-direction shearx x

y y

Page 27: Geometric Transformations

TRANSFORMATION BETWEEN COORDINATE SYSTEMS

Individual objects may be defined in their local cartesian reference system.

The local coordinates must be transformed to position the objects within the scene coordinate system.

Page 28: Geometric Transformations

TRANSFORMATION BETWEEN COORDINATE SYSTEMS(Cont.)

Steps for coordinate transformation

-Translate so that the origin (x0, y0 ) of the x′-y′ system is moved to the origin of the x-y system.

-Rotate the x′ axis on to the axis x.

Page 29: Geometric Transformations

TRANSFORMATION BETWEEN COORDINATE SYSTEMS(Cont.)

y

x

x′y′

θ

x0

y0

0

Page 30: Geometric Transformations

TRANSFORMATION BETWEEN COORDINATE SYSTEMS(Cont.)

y

x

x′

x0

y0

0

y′

θ

Page 31: Geometric Transformations

TRANSFORMATION BETWEEN COORDINATE SYSTEMS(Cont.)

y

xx′ x0

y0

0

y′

Page 32: Geometric Transformations

TRANSFORMATION BETWEEN COORDINATE SYSTEMS(Cont.)

),()(

100

0

0

)(

100

10

01

),(

00'',

0

0

00

yx

CosSin

SinCos

y

x

yx

yxxy

TRM

R

T

Page 33: Geometric Transformations

TRANSFORMATION BETWEEN COORDINATE SYSTEMS(Cont.)

An alternative method: -Specify a vector V that indicates the direction for the positive y′ axis. Let

-Obtain the unit vector u=(ux ,u y) along the x′ axis by rotating v 900 clockwise.

),( yx vvVV

v

Page 34: Geometric Transformations

TRANSFORMATION BETWEEN COORDINATE SYSTEMS(Cont.)

-Elements of any rotation matrix can be expressed as elements of orhogonal unit vectors. That is, the rotation matrix can be written as

100

0

0

yx

yx

vv

uu

R

Page 35: Geometric Transformations

TRANSFORMATION BETWEEN COORDINATE SYSTEMS(Cont.)

y

x

x′y′

x0

y0

0

V

Page 36: Geometric Transformations

Three Dimensional Geometric Transformations

Page 37: Geometric Transformations

P=(x,y,z)

x

3D Translation

P′=(x′,y′,z′)y

z

Page 38: Geometric Transformations

PTP

'

1

.

1000

100

010

001

1

'

'

'

z

y

x

t

t

t

z

y

x

z

y

x

3D Translation

Page 39: Geometric Transformations

3D Rotation(z-axis)

z-axis rotation

P=(x,y,z)

x

y

z

Page 40: Geometric Transformations

3D Rotation(z-axis)

1

.

1000

0100

00

00

1

'

'

'

z

y

x

CosSin

SinCos

z

y

x

PRP ).(' z

zz

yxy

yxx

'

cossin'

sincos'

Page 41: Geometric Transformations

x-axis rotation

P=(x,y,z)

x

y

z

3D Rotation(x-axis)

Page 42: Geometric Transformations

3D Rotation(x-axis)

PRP ).(' x

1

.

1000

00

00

0001

1

'

'

'

z

y

x

CosSin

SinCos

z

y

x

xx

zyz

zyy

xzyx

'

cossin'

sincos'

Page 43: Geometric Transformations

y-axis rotation

P=(x,y,z)

x

y

z

3D Rotation(y-axis)

Page 44: Geometric Transformations

3D Rotation(y-axis)

11000

00

0010

00

1

'

'

'

z

y

x

CosSin

SinCos

z

y

x

PRP ).(' y

yy

xzx

xzz

'

cossin'

sincos'

Page 45: Geometric Transformations

General 3D Rotation Rotation about an axis that is parallel to

x-axes.

-Translate object so that the rotation axis coincides with the parallel coordinate axis.

-Perform specified rotation about the axis.

-Translate the object so that the rotation axis is moved back to its original position.

PTRTP 1 .)(' x

Page 46: Geometric Transformations

Rotation about an axis that is parallel to x-axes.

Rotation axis

x

y

z

Page 47: Geometric Transformations

General 3D Rotation

Rotation about an axis that is not parallel to one of the coordinate axes.

-Translate object so that the rotation axis passes through the coordinate origin.

-Rotate object so that the axis of rotation coincides with one of the coordinate axes.

-Perform the specified rotation about that coordinate axis

-Apply inverse rotations to bring the rotation axis back to its original orientation.

-Apply the inverse translation to brig the rotation axis back to its original position.

Page 48: Geometric Transformations

Rotation about an axis that is not parallel to one of the coordinate axes.

Rot

atio

n ax

isx

y

z

P2

P1

Initial Position

Page 49: Geometric Transformations

Rotation about an axis that is not parallel to one of the coordinate axes.

x

y

z

P2

P1

Translate P1 to the origin

Page 50: Geometric Transformations

Rotation about an axis that is not parallel to one of the coordinate axes.

x

y

z

P 2

P 1

Rotate P2 onto the z-axis and rotate the object around it.

Page 51: Geometric Transformations

Rotation about an axis that is not parallel to one of the coordinate axes.

x

y

z

P2

P1

Rotate the axis to the original orientation

Page 52: Geometric Transformations

Rotation about an axis that is not parallel to one of the coordinate axes.

x

y

z

P2

P1

Translate the rotation axis to the original position

Page 53: Geometric Transformations

Rotation about an axis that is not parallel to one of the coordinate axes.

An axis vector is defined by two points as

A unit vector is defined as

1PPV 2

),,( cbaVV

u

Page 54: Geometric Transformations

Rotation about an axis that is not parallel to one of the coordinate axes.

The first step is to set up the translation matrix

1000

100

010

001

1

1

1

z

y

x

T

Page 55: Geometric Transformations

Rotation about an axis that is not parallel to one of the coordinate axes. The next step is to put the rotation axis

on the z-axis.

x

y

z

u

Page 56: Geometric Transformations

Rotation about an axis that is not parallel to one of the coordinate axes. First, we rotate about the x-axis to transform u into the x-z

plane.

x

y

z

u

α

Page 57: Geometric Transformations

Rotation about an axis that is not parallel to one of the coordinate axes.

First, we rotate about the x-axis to transform u into the x-z plane.

x

y

z

u

α

u′

Uz=(0,0,1)

α

22

'

')(

),,(

cbd

d

cCos

cba

z

z

uu

uu

u

Page 58: Geometric Transformations

Rotation about an axis that is not parallel to one of the coordinate axes. We can define the sine of α from the cross product of u and u′.

dbSin

dSinb

Sindb

dand

bcb

Sin

xx

z

x

zyx

z

zxz

/

)1)((

'1

100

0'

''

uu

uu

u

uuu

uu

uuuuu

Page 59: Geometric Transformations

Rotation about an axis that is not parallel to one of the coordinate axes.

The rotation matrix is

1000

0//0

0//0

0001

)(dcdb

dbdcx R

Page 60: Geometric Transformations

Rotation about an axis that is not parallel to one of the coordinate axes.

x

y

z

u

β

Page 61: Geometric Transformations

Rotation about an axis that is not parallel to one of the coordinate x-axes.

1000

00

0010

00

)(da

ad

y R

Page 62: Geometric Transformations

Rotation about an axis that is not parallel to one of the coordinate x-axes.

TRRRRRTR

R

)()()()()()(

1000

0100

00sin

00sin

)(

111

xyzyx

z

Cos

Cos