Transformation of any object in a 2D or 3D plane means the change in the looks of the object by applying certain rules.

### Scaling-

It is one of the transformation technique. Scaling changes the size of an object.This operation is carried out in any polygon by multiplying the scaling factor (Sx,Sy) with each vertex coordinate value (x,y) of the polygon.This results in transform coordinates (x',y') and then we plot the transformed coordinates.

Here is the program to scale a triangle so

Let's suppose (x1,y1) (x2,y2) (x3,y3) are the coordinates of a triangle and the scaling factor is (Sx,Sy) then transform coordinates will be- (x1',y1')=(Sx*x1,Sy*y1)

(x2',y2')=(Sx*x2,Sy*y2)

(x3',y3')=(Sx*x3,Sy*y3)

One thing you need to keep in mind that theco-ordinates you are providing must form a triangle.

## C program for triangle scaling-

#include<stdio.h> #include<graphics.h> #include<math.h> //function for triangle scaling void scaling(int x1,int y1,int x2,int y2,int x3,int y3) { int sx,sy,xn1,yn1,xn2,xn3,yn3,yn2,gd,gm; printf("enter the scaling vector\n"); scanf("%d %d",&sx,&sy); //scale the co-ordinates of triangle vertices by multiplying the scaling vector xn1=x1*sx; yn1=y1*sy; xn2=x2*sx; yn2=y2*sy; xn3=x3*sx; yn3=y3*sy; //initializing the graph initgraph(&gd,&gm,""); //print the intitial triangle line(x1,y1,x2,y2); line(x1,y1,x3,y3); line(x2,y2,x3,y3); delay(600); //print the scaled triangle line(xn1,yn1,xn2,yn2); line(xn1,yn1,xn3,yn3); line(xn2,yn2,xn3,yn3); delay(600); cleardevice(); } int main() { int ch,x1,y1,x2,y2,x3,y3; printf("enter the vertex co-ordinates of triangle\n"); scanf("%d %d %d %d %d %d",&x1,&y1,&x2,&y2,&x3,&y3); scaling(x1,y1,x2,y2,x3,y3); return 0; }

## OUTPUT-

### Execution steps for Linux users-

- first of all, save the code given above with .c extension i.e.(filename.c)
- After that open your terminal in the same folder where you have saved the file.
- Run the command given below in terminal-

` gcc filename.c -lgraph`

- type ./a.out and see the output.

sxdcfsdfg

ReplyDeleteAs soon as we’re absolutely clear we’ll start the proofing procedure. Just about all evidence are sent by way of email till you’re 100% satisfied

ReplyDeletebest company logos

They knew what they promised me and delivered on time

ReplyDeletebrand consulting firm

That said, it's always overwhelming to consider learning a fresh skill. Before learning how to become web designer, you must consider, "Should I become a web designer?"

ReplyDeleteweb design melbourne