41
Transformation & Transformation & Projection Projection Feng Yu Feng Yu Proseminar Computer Graphics :

Transformation & Projection Feng Yu Proseminar Computer Graphics :

Embed Size (px)

Citation preview

Transformation & ProjectionTransformation & Projection

Feng YuFeng Yu

Proseminar Computer Graphics :

TransformationsTransformations

What is a transformation?What is a transformation?

What kind of transformations are there?What kind of transformations are there?

How can we compute them?How can we compute them?

Transformation :Transformation :

2D Transformations2D Transformations Homogeneous Coordinates and Matrix Homogeneous Coordinates and Matrix

Representation of 2D Transformations Representation of 2D Transformations Matrix Representation of 3D TransformationsMatrix Representation of 3D Transformations Transformations as a Change in Coordinate Transformations as a Change in Coordinate

System System

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

2D Translations.2D Translations.

PP’

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

2D Scaling from the origin.2D Scaling from the origin.

PP’

2D Rotation about the origin.2D Rotation about the origin.

y

x

r

r

P’(x’,y’)

P(x,y)

2D Rotation about the origin.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

2D Rotation about the origin.2D Rotation about the origin.

sin.

cos.

ry

rx

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

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

rrry

rrrx

Substituting for r :

Given us:

cos.sin.

sin.cos.

yxy

yxx

2D Rotation about the origin.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

Transformations.Transformations.

Translation.Translation.• PP=T + P=T + P

ScaleScale• PP=S =S P P

RotationRotation• PP=R =R P P

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

Homogeneous coordinates Homogeneous coordinates

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

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

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

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

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

Homogeneous coordinatesHomogeneous coordinates If we represent (x,y,W) in 3-space, all triples If we represent (x,y,W) in 3-space, all triples

representing the same point describe a line passing representing the same point describe a line passing through the origin.through the origin.

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

P

X

Y

W

W=1 plane

Translations in homogenised Translations in homogenised coordinatescoordinates

Transformation matrices for 2D translation are now 3x3.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

Concatenation.Concatenation.

We perform 2 translations on the same point:We perform 2 translations on the same point:

),(),(),(

:expect weSo

),(),(),(

),(

),(

21212211

21212211

22

11

yyxxyxyx

yyxxyxyx

yx

yx

ddddTddTddT

ddddTPddTddTPP

ddTPP

ddTPP

Concatenation.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

Homogeneous form of scale.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 :

Concatenation of scales.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

Homogeneous form of rotation.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

3D Transformations.3D Transformations.

Use homogeneous coordinates, just as in 2D Use homogeneous coordinates, just as in 2D case.case.

Transformations are now 4x4 matrices.Transformations are now 4x4 matrices. We will use a right-handed (world) coordinate We will use a right-handed (world) coordinate

system - ( z out of page ).system - ( z out of page ).

z (out of page)

y

x

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

Translation in 3D.Translation in 3D.

1000

100

010

001

),,(z

y

x

zyx d

d

d

dddT

Simple extension to the 3D case:

Scale in 3D.Scale in 3D.

1000

000

000

000

),,(z

y

x

zyx s

s

s

sssS

Simple extension to the 3D case:

Rotation in 3DRotation in 3D

Need to specify which axis the rotation is Need to specify which axis the rotation is about.about.

z-axis rotation is the same as the 2D case.z-axis rotation is the same as the 2D case.

1000

0100

00cossin

00sincos

)(

zR

Rotation in 3DRotation in 3D

For rotation about the x and y axes:For rotation about the x and y axes:

1000

0cos0sin

0010

0sin0cos

)( ,

1000

0cossin0

0sincos0

0001

)(

yx RR

Transformations of coordinate Transformations of coordinate systems.systems.

1

)()(

)()(

ji

)(

:shown that be alsocan It

:onsubstitutiby obtain we

and

i systemin point a toj systemin point a converts that transform theas M Define

system coordinatein point a as Define

jiij

kjjiki

kkj

j

jji

i

i

MM

MMM

PMP

PMP

iP

Transform Left-Right, Right-LeftTransform Left-Right, Right-Left

1000

0100

0010

0001

RLLR MM

Transforms between world coordinates and viewing coordinates. That is: between a right-handed set and a left-handed set.

ProjectionsProjections

Perspective ProjectionPerspective Projection Parallel ProjectionParallel Projection

Planar Geometric Planar Geometric ProjectionsProjections

Standard projections project onto a planeStandard projections project onto a plane Projectors are lines that eitherProjectors are lines that either

•converge at a center of projectionconverge at a center of projection•are parallelare parallel

Such projections preserve linesSuch projections preserve lines•but not necessarily anglesbut not necessarily angles

Nonplanar projections are needed for applications Nonplanar projections are needed for applications such as map constructionsuch as map construction

Perspective ProjectionPerspective Projection

Parallel ProjectionParallel Projection

Taxonomy of Planar Taxonomy of Planar Geometric ProjectionsGeometric Projections

parallelparallel perspective

axonometric multivieworthographic

oblique

isometric dimetric trimetric

2 point1 point 3 point

planar geometric projections

Orthographic ProjectionOrthographic Projection

Projectors are orthogonal to projection Projectors are orthogonal to projection plane plane

Multiview Orthographic Multiview Orthographic ProjectionProjection

Projection plane parallel to principal faceProjection plane parallel to principal faceUsually form front, top, side viewsUsually form front, top, side views

isometric (not multivieworthographic view)

front

sidetop

in CAD and architecture, we often display three multiviews plus isometric

Advantages and DisadvantagesAdvantages and Disadvantages

Preserves both distances and anglesPreserves both distances and angles• Shapes preservedShapes preserved• Can be used for measurementsCan be used for measurements

Building plansBuilding plans ManualsManuals

Cannot see what object really looks like because Cannot see what object really looks like because many surfaces hidden from viewmany surfaces hidden from view• Often we add the isometricOften we add the isometric

Oblique ProjectionOblique Projection

Arbitrary relationship between projectors Arbitrary relationship between projectors and projection planeand projection plane

Advantages and DisadvantagesAdvantages and Disadvantages

Can pick the angles to emphasize a particular Can pick the angles to emphasize a particular faceface• Architecture: plan oblique, elevation obliqueArchitecture: plan oblique, elevation oblique

Angles in faces parallel to projection plane are Angles in faces parallel to projection plane are preserved while we can still see “around” sidepreserved while we can still see “around” side

In physical world, cannot create with simple In physical world, cannot create with simple camera; possible with bellows camera or special camera; possible with bellows camera or special lens (architectural)lens (architectural)

Perspective ProjectionPerspective Projection

Projectors coverge at center of projectionProjectors coverge at center of projection

Vanishing PointsVanishing Points

Parallel lines (not parallel to the projection Parallel lines (not parallel to the projection plan) on the object converge at a single plan) on the object converge at a single point in the projection (the point in the projection (the vanishing pointvanishing point) )

Drawing simple perspectives by hand uses Drawing simple perspectives by hand uses these vanishing point(s)these vanishing point(s)

vanishing point

One-Point Perspective One-Point Perspective

One principal face parallel to projection One principal face parallel to projection planeplane

One vanishing point for cubeOne vanishing point for cube

Two-Point PerspectiveTwo-Point Perspective

On principal direction parallel to projection On principal direction parallel to projection planeplane

Two vanishing points for cubeTwo vanishing points for cube

Advantages and DisadvantagesAdvantages and Disadvantages

Objects further from viewer are projected smaller Objects further from viewer are projected smaller than the same sized objects closer to the viewer than the same sized objects closer to the viewer ((diminutiondiminution))•Looks realisticLooks realistic

Equal distances along a line are not projected into Equal distances along a line are not projected into equal distances (equal distances (nonuniform foreshorteningnonuniform foreshortening))

Angles preserved only in planes parallel to the Angles preserved only in planes parallel to the projection planeprojection plane

More difficult to construct by hand than parallel More difficult to construct by hand than parallel projections (but not more difficult by computer)projections (but not more difficult by computer)

ENDEND

Thank you for your attentions Thank you for your attentions