To draw a circle using trignometric method

//To draw a circle using trignometric method

#include<iostream.h>
#include<graphics.h>
#include<conio.h>
#include<math.h>
void put8pixel(int,int,int,int);
void main()
{
int x,y,x1,y1,r,h,k,theta;
float n=3.14159/180;
cout<<“\n\t\t\t\*Trignometric Method to draw a circle*\n”;
cout<<“\nenter the x and y coordinates:-\n”;
cin>>h>>k;
cout<<“\nenter the radius:-\n”;
cin>>r;
int gd=DETECT,gm;
initgraph(&gd,&gm,””);
for(theta=0;theta<=45;theta++)
{
x1=r*cos(theta*n);
y1=r*sin(theta*n);
x=int(x1+0.5);
y=int(y1+0.5);
put8pixel(x,y,h,k);
}
outtextxy(115,70,”circle using Trigonometric method”);
getch();
closegraph();
}
void put8pixel(int x,int y,int h,int k)
{
putpixel(x+h,y+k,6);
putpixel(x+h,-y+k,6);
putpixel(-x+h,y+k,6);
putpixel(-x+h,-y+k,6);
putpixel(y+h,x+k,6);
putpixel(y+h,-x+k,6);
putpixel(-y+h,x+k,6);
putpixel(-y+h,-x+k,6);
}

Leave a Reply

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