You are on page 1of 41

Transformation & Projection

Feng Yu
Proseminar Computer Graphics :
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
T P P
d
d
T
y
x
P
y
x
P
d y y d x x
y x P
y x P P
y x
+ =
'
(

=
(

'
'
=
'
(

=
+ =
'
+ =
'
' ' '
Now
, ,
tors column vec the Define

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

=
(

'
'
=
'
(

=
=
'
=
'
' ' '
y
x
.
0
0
y
x
or
Now
0
0
matrix the Define
. , .
axis. y the along s and
axis, x the along s factor a by ) , ( Point to (stretch) scale a Perform
), , ( as defined Point
y
x
y
x
y
x
y x
s
s
P S P
s
s
S
y s y x s x
y x P
y x P P
2D Scaling from the origin.
P
P
2D Rotation about the origin.
y
x
r
r
P(x,y)
P(x,y)
u
2D Rotation about the origin.
y
x
r
r
P(x,y)
P(x,y)
u
|
y
|
|
sin .
cos .
r y
r x
=
=
x
u | u | | u
u | u | | u
cos . sin . sin . cos . ) sin( .
sin . sin . cos . cos . ) cos( .
r r r y
r r r x
+ = + =
'
= + =
'
2D Rotation about the origin.
|
|
sin .
cos .
r y
r x
=
=
u | u | | u
u | u | | u
cos . sin . sin . cos . ) sin( .
sin . sin . cos . cos . ) cos( .
r r r y
r r r x
+ = + =
'
= + =
'
Substituting for r :
Given us:
u u
u u
cos . sin .
sin . cos .
y x y
y x x
+ =
'
=
'
2D Rotation about the origin.
u u
u u
cos . sin .
sin . cos .
y x y
y x x
+ =
'
=
'
Rewriting in matrix form gives us :
(


=
(

'
'
y
x
y
x
.
cos sin
sin cos
u u
u u
P R P R =
'
(


= ,
cos sin
sin cos
matrix the Define
u u
u u
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.

P
X
Y
W
W=1 plane
Translations in homogenised
coordinates
Transformation matrices for 2D translation are now 3x3.
(
(
(

(
(
(

=
(
(
(

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

=
+ =
'
+ =
'
y
x
d y y
d x x
Concatenation.
We perform 2 translations on the same point:

) , ( ) , ( ) , (
: expect we So
) , ( ) , ( ) , (
) , (
) , (
2 1 2 1 2 2 1 1
2 1 2 1 2 2 1 1
2 2
1 1
y y x x y x y x
y y x x y x y x
y x
y x
d d d d T d d T d d T
d d d d T P d d T d d T P P
d d T P P
d d T P P
+ + =
+ + = =
' '

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

+
+
=
(
(
(

(
(
(


1 0 0
1 0
0 1
1 0 0
1 0
0 1
.
1 0 0
1 0
0 1
: is ) , ( ) , ( product matrix The
2 1
2 1
2
2
1
1
2 2 1 1
y y
x x
y
x
y
x
y x y x
d d
d d
d
d
d
d
d d T d d T
Homogeneous form of scale.
(

=
y
x
y x
s
s
s s S
0
0
) , (
Recall the (x,y) form of Scale :
(
(
(

=
1 0 0
0 0
0 0
) , (
y
x
y x
s
s
s s S
In homogeneous coordinates :
Concatenation of scales.
! multiply easy to - matrix in the elements diagonal Only
1 0 0
0 s s 0
0 0 s s
1 0 0
0 s 0
0 0 s
.
1 0 0
0 s 0
0 0 s
: is ) , ( ) , ( product matrix The
y2 y1
x2 x1
y2
x2
y1
x1
2 2 1 1
(
(
(

=
(
(
(

(
(
(


y x y x
s s S s s S
Homogeneous form of rotation.
(
(
(

(
(
(


=
(
(
(

'
'
1
.
1 0 0
0 cos sin
0 sin cos
1
y
x
y
x
u u
u u
) ( ) (
: i.e , orthogonal are matrices Rotation
). ( ) (
matrices, rotation For
1
1
u u
u u
T
R R
R R
=
=

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 as
Being left-handed !!
( z into the screen )
Translation in 3D.
(
(
(
(

=
1 0 0 0
1 0 0
0 1 0
0 0 1
) , , (
z
y
x
z y x
d
d
d
d d d T
Simple extension to the 3D case:
Scale in 3D.
(
(
(
(

=
1 0 0 0
0 0 0
0 0 0
0 0 0
) , , (
z
y
x
z y x
s
s
s
s s s S
Simple extension to the 3D case:
Rotation in 3D
Need to specify which axis the rotation is
about.
z-axis rotation is the same as the 2D case.
(
(
(
(


=
1 0 0 0
0 1 0 0
0 0 cos sin
0 0 sin cos
) (
u u
u u
u
z
R
Rotation in 3D
For rotation about the x and y axes:
(
(
(
(

=
(
(
(
(

=
1 0 0 0
0 cos 0 sin
0 0 1 0
0 sin 0 cos
) ( ,
1 0 0 0
0 cos sin 0
0 sin cos 0
0 0 0 1
) (
u u
u u
u
u u
u u
u
y x
R R
Transformations of coordinate
systems.
1
) ( ) (
) ( ) (
j i
) (
: shown that be also can It
: on substituti by obtain we
and
i system in point a to j system in point a converts that transform the as M Define
system coordinate in point a as Define

=
=
=
=
j i i j
k j j i k i
k
k j
j
j
j i
i
i
M M
M M M
P M P
P M P
i P
Transform Left-Right, Right-Left
(
(
(
(

= =

1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1
R L L R
M M
Transforms between world coordinates and viewing
coordinates. That is: between a right-handed set and a left-
handed set.
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
paralle
l
perspective
axonometric
multiview
orthographic
oblique
isometric dimetric trimetric
2 point 1 point 3 point
planar geometric projections
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)
front
side
top
in CAD and architecture,
we often display three
multiviews plus isometric
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