A scaling transformation alters size of an object. In the scaling process, we either compress or expand the dimension of the object.
Scaling operation can be achieved by multiplying each vertex coordinate (x, y) of the polygon by scaling factor sx and sy to produce the transformed coordinates as (x’, y’).
So, x’ = x * sx and y’ = y * sy.
The scaling factor sx, sy scales the object in X and Y direction respectively. So, the above equation can be represented in matrix form:
Or P’ = S . P
Note: If the scaling factor S is less than 1, then we reduce the size of the object. If the scaling factor S is greater than 1, then we increase size of the object.
1. Make a 2x2 scaling matrix S as: Sx 0 0 Sy 2. For each point of the polygon. (i) Make a 2x1 matrix P, where P equals to x coordinate of the point and P equals to y coordinate of the point. (ii) Multiply scaling matrix S with point matrix P to get the new coordinate. 3. Draw the polygon using new coordinates.
Below is C implementation:
This article is contributed by Anuj Chauhan. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Window to Viewport Transformation in Computer Graphics with Implementation
- Composite Transformation in 2-D graphics
- Translation of objects in computer graphics
- 2D Transformation | Rotation of objects
- DDA Line generation Algorithm in Computer Graphics
- Point Clipping Algorithm in Computer Graphics
- Segments in Computer Graphics
- Computer Graphics | Cathode ray tube (video display device)
- Computer Graphics | Antialiasing
- Draw a moving car using computer graphics programming in C
- Computer Graphics | The RGB color model
- Refresh type output devices in Computer Graphics
- Applications of Computer Graphics
- Display Processor in Computer Graphics
- Introduction to Computer Graphics
- Difference between Parallel and Perspective Projection in Computer Graphics
- Interactive Graphical Techniques in Computer Graphics
- Painter's Algorithm in Computer Graphics
- Methods for Text Clipping in Computer Graphics
- Interpolation Methods in Computer Graphics