Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 41

Proseminar Computer Graphics :

Transformation & Projection


Feng Yu

Transformations

What is a transformation?

What kind of transformations are there?

How can we compute them?

Transformation :

2D Transformations
Homogeneous Coordinates and Matrix
Representation of 2D Transformations
Matrix Representation of 3D Transformations
Transformations as a Change in Coordinate
System

2D Translations.
Point P defined as P ( x, y ),
translate to Point P( x, y) a distance d x parallel to x axis, d y parallel to y axis.
x x d x y y d y
Define the column vectors
x

P , P
y

Now
P P T

x
dx
,T

y
dy

P
P

2D Scaling from the origin.


Point P defined as P ( x, y ),
Perform a scale (stretch) to Point P( x, y) by a factor s x along the x axis,
and s y along the y axis.
x s x . x,

y s y . y

Define the matrix


sx
S
0

P
P

0
s y

Now
P S P or

x s x
y 0

0
s y

x
y

2D Rotation about the origin.


y

P(x,y)

P(x,y)

r
x

2D Rotation about the origin.


y

x r. cos( ) r. cos . cos r. sin . sin


y r. sin( ) r. cos . sin r. sin . cos
P(x,y)

P(x,y)

x r. cos
y r. sin

r
x

2D Rotation about the origin.


x r. cos( ) r. cos . cos r. sin . sin
y r. sin( ) r. cos . sin r. sin . cos
Substituting for r :

x r. cos
y r. sin
Given us:

x x. cos y. sin
y x. sin y. cos

2D Rotation about the origin.


x x. cos y. sin
y x. sin y. cos
Rewriting in matrix form gives us :

x cos
y sin

sin
cos

x
y

cos
Define the matrix R
sin

sin
, P R P

cos

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 .

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

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.

W=1 plane
X
Y

Translations in homogenised
coordinates

Transformation matrices for 2D translation are now 3x3.

x 1 0 d x x
y 0 1 d . y
y

1 0 0 1 1

x x d x
y y d y
11

Concatenation.

We perform 2 translations on the same point:

P P T (d x1 , d y1 )
P P T (d x 2 , d y 2 )
P P T (d x1 , d y1 ) T (d x 2 , d y 2 ) P T (d x1 d x 2 , d y1 d y 2 )
So we expect :
T (d x1 , d y1 ) T (d x 2 , d y 2 ) T (d x1 d x 2 , d y1 d y 2 )

Concatenation.
The matrix product T (d x1 , d y1 ) T (d x 2 , d y 2 ) is :
1 0 d x1
0 1 d
y1

0 0 1

1 0 d x 2 1 0 d x1 d x 2
. 0 1 d 0 1 d d
y2
y1
y2

0 0 1 0 0

Matrix product is variously referred to as compounding,


concatenation, or composition.
This single matrix is called the Coordinate Transformation Matrix or
CTM.

Homogeneous form of scale.


Recall the (x,y) form of Scale

sx
S (sx , s y )
0

s y

In homogeneous coordinates :

sx
S ( s x , s y ) 0
0

0
sy
0

0
0
1

Concatenation of scales.
The matrix product S ( s x1 , s y1 ) S ( s x 2 , s y 2 ) is :
0
0
s x1 0 0 s x2 0 0 s x1 s x2
0 s

0
.
0
s
0

0
s

s
0
y1
y2
y1
y2

0 0 1 0
0 1 0
0
1
Only diagonal elements in the matrix - easy to multiply !

Homogeneous form of rotation.


x cos
y sin

1 0

sin
cos
0

0
0
1

y
1

For rotation matrices,


R ( ) R ( ).
Rotation matrices are orthogonal, i.e :
1

R 1 ( ) R T ( )

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 ).
y

x
z (out of page)

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

Translation in 3D.
Simple extension to the 3D case:

1
0
T (d x , d y , d z )
0

0
1
0
0

0 dx
0 d y
1 dz

0 1

Scale in 3D.
Simple extension to the 3D case:

sx
0
S (s x , s y , s z )
0

0
sy
0
0

0
0
sz
0

0
0
0

Rotation in 3D

Need to specify which axis the rotation is


about.
z-axis rotation is the same as the 2D case.
cos
sin
R z ( )
0

sin
cos
0
0

0
0
1
0

0
0
0

Rotation in 3D

For rotation about the x and y axes:

0
1
0 cos
R x ( )
0 sin

0
0

0
sin
cos
0

0
,
0

cos
0
R y ( )
sin

0 sin

1
0
0 cos

0
0

Transformations of coordinate
systems.
Define P (i ) as a point in coordinate system i
Define M i j as the transform that converts a point in system j to a point in system i
P (i ) M i j P ( j )
and
P ( j ) M j k P ( k )
we obtain by substitution :
M i k M i j M j k
It can also be shown that :
M j i M i1 j

Transform Left-Right, Right-Left


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

M R L M LR

1
0

0 0
1 0
0 1
0 0

0
0
0

Projections

Perspective Projection
Parallel Projection

Planar Geometric
Projections

Standard projections project onto a plane


Projectors are lines that either
converge at a center of projection
are parallel
Such projections preserve lines
but not necessarily angles
Nonplanar projections are needed for applications
such as map construction

Perspective Projection

Parallel Projection

Taxonomy of Planar
Geometric Projections
planar geometric projections

parallel

perspective

1 point
multiview axonometric oblique
orthographic
isometric

dimetric

trimetric

2 point

3 point

Orthographic Projection
Projectors are orthogonal to projection
plane

Multiview Orthographic
Projection

Projection plane parallel to principal face


Usually form front, top, side views

isometric (not multiview


orthographic view)

in CAD and architecture,


we often display three
multiviews plus isometric
top

front

side

Advantages and Disadvantages


Preserves both distances and angles
Shapes preserved
Can be used for measurements
Building plans
Manuals
Cannot see what object really looks like because
many surfaces hidden from view
Often we add the isometric

Oblique Projection
Arbitrary relationship between projectors
and projection plane

Advantages and Disadvantages


Can pick the angles to emphasize a particular
face
Architecture: plan oblique, elevation oblique
Angles in faces parallel to projection plane are
preserved while we can still see around side

In physical world, cannot create with simple


camera; possible with bellows camera or special
lens (architectural)

Perspective Projection
Projectors coverge at center of projection

Vanishing Points
Parallel lines (not parallel to the projection
plan) on the object converge at a single
point in the projection (the vanishing point)
Drawing simple perspectives by hand uses
these vanishing point(s)

vanishing point

One-Point Perspective
One principal face parallel to projection
plane
One vanishing point for cube

Two-Point Perspective
On principal direction parallel to projection
plane
Two vanishing points for cube

Advantages and Disadvantages


Objects further from viewer are projected smaller
than the same sized objects closer to the viewer
(diminution)
Looks realistic
Equal distances along a line are not projected into
equal distances (nonuniform foreshortening)
Angles preserved only in planes parallel to the
projection plane
More difficult to construct by hand than parallel
projections (but not more difficult by computer)

END
Thank you for your attentions

You might also like