Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Rotation
- #include<stdio.h>
- #include<conio.h>
- #include<graphics.h>
- #include<math.h>
- void main(){
- int gd=DETECT, r, gm, d, x1, y1, x2, y2, xn1, yn1, xn2, yn2;
- float ra, si, co;
- initgraph(&gd, &gm, "C:\\TURBOC3\\BGI");
- printf("Enter the value of X1 and Y1: ");
- scanf("%d %d", &x1, &y1);
- printf("Enter the value of X2 and Y2: ");
- scanf("%d %d", &x2, &y2);
- line(x1, y1, x2, y2);
- printf("Enter the degree of rotation: ");
- scanf("%d", &d);
- //Starting point would be same
- xn1 = x1;
- yn1 = y1;
- //Convert Degree into radian
- r = x2-x1;
- ra = 0.0175 * d;
- si = sin(ra);
- co = cos(ra);
- //second point
- xn2 = x1 + r*co + 1;
- yn2 = y1 + r*si + 1;
- line(xn1, yn1, xn2, yn2);
- getch();
- closegraph();
- }
- //translation
- //Transation
- #include<stdio.h>
- #include<conio.h>
- #include<graphics.h>
- #include<math.h>
- void main(){
- int gd=DETECT,gm;
- int x1,y1,x2,y2,tx,ty,x3,y3,x4,y4;
- initgraph(&gd,&gm,"C:\\TurboC3\\BGI");
- printf("Enter the starting point of line segment:");
- scanf("%d %d",&x1,&y1);
- printf("Enter the ending point of line segment:");
- scanf("%d %d",&x2,&y2);
- printf("Enter translation distances tx,ty:\n");
- scanf("%d%d",&tx,&ty);
- setcolor(5);
- line(x1,y1,x2,y2);
- outtextxy(x2+2,y2+2,"Original line");
- x3=x1+tx;
- y3=y1+ty;
- x4=x2+tx;
- y4=y2+ty;
- setcolor(7);
- line(x3,y3,x4,y4);
- outtextxy(x4+2,y4+2,"Line after translation");
- getch();
- }
- //scalling
- #include<stdio.h>
- #include<conio.h>
- #include<graphics.h>
- #include<math.h>
- void main(){
- int gd=DETECT,gm;
- float x1,y1,x2,y2,sx,sy,x3,y3,x4,y4;
- initgraph(&gd,&gm,"C:\\TurboC3\\BGI");
- printf("Enter the starting point coordinates:");
- scanf("%f %f",&x1,&y1);
- printf("Enter the ending point coordinates:");
- scanf("%f %f",&x2,&y2);
- printf("Enter scaling factors sx,sy:\n");
- scanf("%f%f",&sx,&sy);
- setcolor(5);
- line(x1,y1,x2,y2);
- outtextxy(x2+2,y2+2,"Original line");
- x3=x1*sx;
- y3=y1*sy;
- x4=x2*sx;
- y4=y2*sy;
- setcolor(7);
- line(x3,y3,x4,y4);
- outtextxy(x4+2,y4+2,"Line after scaling");
- getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment