Transformations

advertisement
Computer Graphics
Transformations
Transformations
Transformation is the backbone of computer graphics, it enables us to
manipulate the shape, size, and location of the object. It can be used to effect
the following changes in a geometric object:
 Change the location
 Change the shape
 Change the size
 Rotate
 Copy
 Generate a surface from a line
 Generate a solid from a surface
 Animate the object
Basic transformations are translation, scaling, rotation, reflection and,
shearing. We look at transformations as ways of moving the points that
describe one or more geometric objects to new locations. Although there are
many transformations that will move a particular point to a new location, there
will almost always be only a single way to transform a collection of points to
new locations while preserving the spatial relationships among them. Hence,
although we can find many matrices that will move one corner of our color cube
from P0 to Q0, only one of them, when applied to all the vertices of the cube,
will result in a displaced cube of the same size and orientation.
1. Translation
Translation is an operation that displaces points by a fixed distance in a
given direction. To specify a translation we need only to specify a displacement
vector d, because the transformed points are given by:
1
Computer Technology _ Software Dep. _ Wadhah R. Baiee _2011
Computer Graphics
Transformations
p2=p1+d
This equation can be written is a scalar form as:
x2=x1+dx
and
y2=y1+dy
In matrix form, the translation is expressed as:
The translation matrix is given by:
This method of representing translation using the addition of column
matrices does not combine well with our representations of other affine
transformations. However, we can also get this result using the matrix
multiplication:
p' = TP, where
[
]
,
[ ]
And for 3D transformation we have:
2
Computer Technology _ Software Dep. _ Wadhah R. Baiee _2011
Computer Graphics
Transformations
,
[ ]
We can obtain the inverse of a translation matrix either by applying an
inversion algorithm or by noting that if we displace a point by the vector d, we
can return to the original position by a displacement of( - d ). By either method,
we find that
2. Scaling :
In scaling transformation, the original coordinates of an object are multiplied
by the given scale factor. There are two types of scaling transformations:
uniform and non-uniform. In the uniform scaling, the coordinate values change
uniformly along the x and y coordinates, whereas, in non-uniform scaling, the
change is not necessarily the same in all the coordinate directions.
3
Computer Technology _ Software Dep. _ Wadhah R. Baiee _2011
Computer Graphics
Transformations
a. Uniform Scaling
For uniform scaling, the scaling transformation matrix is given as:
Where s is the scaling vector.
b. Non-uniform Scaling
Matrix equation of a non-uniform scaling has the form :
P'=SP
[ ]
[
] [ ]
Where sx and sy are the scale factors for the x and y coordinates of the
object.
There is a fixed point that is unchanged by the transformation. We let the
fixed point be the origin, and we show how we can concatenate
transformations to obtain the transformation for an arbitrary fixed point. A
scaling matrix with a fixed point of the origin allows for
independent scaling along the coordinate axes. The three
equations are
4
Computer Technology _ Software Dep. _ Wadhah R. Baiee _2011
Computer Graphics
Transformations
These three equations can be combined in homogeneous form as
We obtain the inverse of a scaling matrix by applying the reciprocals of the
scale factors:
Note : Invers of Scale is S-1 =
3. Scaling about an arbitrary point :
If we want to scale an object about a fixed point we have to walk through the
following algorithm :
Step1 : Translate the object to the origin.
Step2 : Scale the object by given Scale factor.
5
Computer Technology _ Software Dep. _ Wadhah R. Baiee _2011
Computer Graphics
Transformations
Step3 : Translate the object back to the original position.
These three steps can be combine with transformation matrix as below:
TFixPointScale = T3 S2 T1
Exercise
:
give
the
[
]
[
]
[
]
result
of
the
following
matrices
multiplication.
[
] [
] [
]
6
Computer Technology _ Software Dep. _ Wadhah R. Baiee _2011
Download