2D
ROTATION
AIM:
To write
a program to implement 2D transformation as rotation
ALGORITHM:
·
Declare
the header file
·
Declare
the variables and values
·
Using
the graphics function create an image to implement the 2D Rotation
·
Print
the output of 2D image rotation
·
Stop
the program
CODINGS:
#include<stdio.h>
#include<math.h>
#include<conio.h>
#include<graphics.h>
void
main()
{
int gd=DETECT,gm;
int
a1,a2,a3,a4,a5,b1,b2,b3,b4,b5;
float q;
int
x1,x2,x3,x4,x5,y1,y2,y3,y4,y5;
initgraph(&gd,&gm,"");
x1=50;y1=50;x2=100;y2=50;x3=x1;
y3=x2;x4=x1+x2;y4=x2;
clrscr();
cleardevice();
line(x1,y1,x2,y2);
line(x1,y1,x3,y3);
line(x3,y3,x4,y4);
line(x4,y4,x2,y2);
printf("Enter
Q:");
scanf("%f",&q);
q=(3.14/180)*q;
a1=x1*cos(q)+y1*sin(q);
a2=x2*cos(q)+y2*sin(q);
a3=x3*cos(q)+y3*sin(q);
a4=x4*cos(q)+y4*sin(q);
b1=x1*-sin(q)+y1*cos(q);
b2=x2*-sin(q)+y2*cos(q);
b3=x3*-sin(q)+y3*cos(q);
b4=x4*-sin(q)+y4*cos(q);
line(a1+150,b1+150,a2+150,b2+150);
line(a1+150,b1+150,a3+150,b3+150);
line(a3+150,b3+150,a4+150,b4+150);
line(a4+150,b4+150,a2+150,b2+150);
getch();
}
OUTPUT:
Enter q:90
RESULT:
No comments:
Post a Comment