Proseminar Computer Graphics

advertisement
Proseminar Computer Graphics
Transformation and Projection
1. Transformation
1.1 Basics
The translation ,scaling and rotation discussed here are known together as Geometrical
transformations ,they are useful to many graphics applications .In general ,many applications
use the Geometrical transformations to change the position ,orientation and size of objects .
For example , a City-planning application programm would use translation to place symbols
for buildings and trees at appropriate positions ,rotation to orient the symbols ,and scaling to
size the symbols.
Basically ,we will talk about four points about transformations ,so that we know what kind of
transformations are there and how can we compute them .These four points are : 2D
Transformations
; Homogeneous Coordinates and Matrix Representation of
2D
Transformations ; Matrix Representation of 3D Transformations ; Transformations as a
change in Coordinate System.
1.2 2D Transformations
We can translate points in the (x,y) plane to new positions by adding translation amounts to
the coordinates of the points .The old point is defined as P(x,y), for each point P(x,y) to be
moved by dx parallel to the x axis ,and dy parallel to the y axis ,to the new point P(x’,y’),we
can write x’=x+dx ,y’=y+dy. If we define the column vectors we get a new equality
P’=P+T .We could translate an object by applying these equalities to every point of the
object .
Points can be scaled by Sx along the x axis and by Sy along the y axis into new points by the
multiplications in the form : x’=Sx*x , y’=Sy*y ,in matrix form ,this is P’=S.P .We should
notice that the scaling is about the origin.
Points can be rotated through an angle about the origin ,we can get the new point P’ from the
old point P through rotation easily .The rotation is about the origin .Through some operations
we can get the matrix form P’=R*P .
1.3 Homogeneous Coordinates
We have got
the matrix
representations for translation ,scaling and
rotation ,unfortunately ,translation is treated differently from scaling and rotation ,We would
like to be able to treat all three transformations in a consistent way , so that we can
concatenate them easily .If points are expressed in Homogeneous Coordinates ,all three
transformations can be treated as multiplications .In Homogeneous Coordinates ,we add a
third coordinate to a point , instead of being represented by a pair of numbers(x,y) ,each point
is represented by a triple (x,y,W) .At the same time, we say that two sets of homogeneous
coordinates (x,y,W) and (x’,y’,W’) represent the same point if and only if one is a multiple
of the other .For example ,(2,5,3) and (4,10,6) represents the same point .That is , each point
has many different homogeneous coordinates representations .Also ,at least one of the
coordinates must be nonzero .(0,0,0) is not allowed .If the W coordinate is nonzero ,we can
divide by it ,(x,y,W) represents the same point as (x/W,y/W,1) ,here x/W and y/W are called
the Cartesian coordinates of the homogeneous point .The points with W=0 are called points at
infinity .
Triples of coordinates typically represent points in 3-space ,but here we are using them to
represent points in 2-space .The connection is this ,if we take all the triples representing the
same point – that is ,all triples representing the same point describe a line passing through
the origin .Thus ,each homogeneous point represents a line in 3-space.If we homogenize the
point , we get a point of form (x,y,1) .Thus ,the homogenized points form the plane defined
by the equation W=1 in (x,y,W)-space ,the figure shows this relationship ,points at infinity are
not represented on this plane .
1.4 Matrix Representation of 3D Transformations
Because points are now three-element column vectors ,transformation matrices ,which
multiply a point vector to produce another point vector ,must be 3*3 (figure) , ths equation
can be expressed differently as P’=T(dx,dy).P , we translate point P by T(dx1,dy1) to P’ and
then translate by T(dx2,dy2) to p’’ ,the result that we expect is a net translation :
T(dx1,dy1).T(dx2,dy2) = T(dx1+dx2 ,dy1+dy2) , when we see the matrix product of
T(dx1,dy1).T(dx2,dy2) , it is indeed T(dx1+dx2,dy1+dy2) .The matrixproduct is variously
referred to as the compounding ,concatenation or composition . This single matrix is called
the Coordinate Transformation Matrix or CTM .Simlarly ,we can get the matrix form of
scaling equations ,through multiplicative concatenation we see the same result as translation .
Finally ,the rotation also has its own matrix form ,for rotaion matrices .
Just as 2D transformations can be represented by 3*3 matrices using homogeneous
coordinates ,3D transformations can be represented by 4*4 matrices.Here we use a righthanded (world)coordinate system as the figure shows (z axis is out of page) . We can just
derive simple extensions to the 3D case of translation in 3D , and scale in 3D ,rotation in 3D ,
we need to specify which axis the rotation is about , z –axis rotation is the same as the 2D
case , x-axis rotation and y-axis rotation are different.
1.5 Transformations as a Change in Coordinate System
We have been discussing transformations as transforming points. An alternative but
equivalent way of thinking about a transformation is as a change of coordinate systems, it’s
useful, because it’s unrealistic to think all objects are defined in the same coordinate system .
In general ,we transform model objects in a local coordinate system into the world system.
Transfors between world coordinates and viewing coordinated is actually between a righthanded set and a left-handed set.
2.Projections
2.1 Basics
Now we will see several basic types of Projections .In general ,projections transform points
in a coordinate system of dimension n into points in a coordinate system of dimension less
than n , in fact ,computer graphics has long been used for studying n-dimensional objects by
projecting them into 2D for viewing .
The projection of a 3D object is defined by straight projection rays ,called projectors,
emanating from a center of projection, passing through each point of the object ,and
intersecting a projection plane to form the projection. The class of projections with which we
deal here is known as planar Geometric Projection .Planar Geometric Projections can be
divided into two basic classed , perspective and parallel .The distinction lies in the relation of
the center of projection to the projection plane.If the distance from the one to the other is
finite, then the projection is perspective ,as the center of projection moves farther and farther
away ,the projector get closer and closer to be parallel to each other .The parallel projection is
so named because.
When we define a perspective projection ,we specify its center of projection ,for a parallel
projection ,we give its direction of projection . Both of them can be divided into many
subclasses further .
I
2.2 Parallel Projection
In orthographic parallel projections ,projectors are orthogonal to projection plane ,the most
common types of orthographic projections are the front-elevation ,top-elevation and sideelevation projections . In all these ,the projection plane is parallel to a principal face . In this
case ,the shape of the object ,distances and angles will be preserved ,so it can be used for
measurements ,but we can’t see what object really looks like ,because many surfaces hidden
from view ,usually we add a isometric projection .
Oblique projection is also a class of parallel projections, differ from orthographic projections
in that the projectors are not orthogonal to projection plane .In this case ,we can pick the
angles to emphasize a particular face ,the angles in faces parallel to projection plane are
preserved while we can still see “ around” side .
2.3 Perspective projection
The perspective projections of any set of parallel lines that are not parallel to the projection
plane converge to a vanishing point .In 3D ,the parallel lines meet only at infinity ,so the
vanishing point be thought of as the projection of a point at infinity .
If the set of lines is parallel to one of the three principal axes ,the vanishing point is called an
axis vanishing point ,there are at most three such points ,perspective projections are
categorized by their number of principal vanishing points .For example ,one-point perspective
projection has only a vanishing point , it means ,there is only one principal face parallel to
projection plane .
In perspective projection ,objects further from viewer are projected smaller than the same
sized objects closer to the viewer so that the object looks realistic ,but equal distances along a
line are not projected into equal distances ,angles preserved only in planes parallel to the
projection plane and it’s more difficult to construct by hand than parallel projections.
Be further we have many problems about projections ,for example implementation of Planer
Geometric Projections ,here we don’t deal with them anymore .
Download