Page 131 - DCAP313_LAB_ON_COMPUTER_GRAPHICS
P. 131
Unit 8: Implementing of Scaling in 2D Transformation
8.2.1 Scaling Notes
We scale an object by scaling the x and y coordinates of each vertex in the object (See Figure 8.11):
Figure 8.11: Scaling
Similarity
y Translation
y
Euclidean
Projective
Affine
o x o x
2D Transformations Scaling
This is a really neat feature to include if you are going to use 2d points for an overhead map
because you can zoom in an out to get the amount of aspect you like. This function is also
dependent on the fact that all points must be centered around (0, 0). If we do not follow this
rule we will get object flying all over the place. Take a look at the equation and (See Figure 8.12).
Figure 8.12: Scaling
1.25 × Scale
point2d Transform2d::Scale(float scale,point2d &point)
{
point2d newpoint;
newpoint.x = point.x*scale;
newpoint.y = point.y*scale;
return newpoint;
}
As you can see with this simple equation, if an object’s points are not centered around (0,0) it
will be hurled in a direction and look like its being translated and if it does handle to seem to
be scaled, it would not look correct. So one more time, confirm that you objects are centered
around (0,0)!!
8.2.2 Scaling Matrix
• Change size:
1. x’ = sx * x
2. y’ = sy * y
LOVELY PROFESSIONAL UNIVERSITY 125