To rotate a point at a given angle

//To rotate a point at a given angle

#include<iostream.h>
#include<graphics.h>
#include<conio.h>
#include<math.h>
void main()
{
int x,y,theta;
float n=3.14159/180;
cout<<“\n\t\t\t\*Rotation of a point*\n”;
cout<<“\nenter the x and y coordinates:-\n”;
cin>>x>>y;
cout<<“\nenter the angle of rotation:-\n”;
cin>>theta;
int gd=DETECT,gm;
initgraph(&gd,&gm,””);
setbkcolor(WHITE);
setcolor(8);
putpixel(x,y,8);
x=x*cos(theta*n)-y*sin(theta*n);
y=x*sin(theta*n)+y*cos(theta*n);
putpixel(int(x+0.5),int(y+0.5),8);
setcolor(8);
outtextxy(100,60,”Rotation at a given angle”);
getch();
}

Leave a Reply

Your email address will not be published. Required fields are marked *