Computer Graphics in C,C++

Tuesday, 6 January 2009

Rectangle by trigonometric method.

#include"stdio.h"
#include"conio.h"
#include"graphics.h"
#define PI 3.1416
#include
void main()
{
int gd=DETECT,M;
int h,k,x,y,t;
float a,b;
clrscr();
initgraph(&gd,&M,"");
printf("Enter h,k,a,b;");
scanf("%d%d%f%f",&h,&k,&a,&b);
for(t=0;t<90;t++)
{
x=a*cos((PI/180)*t);
y=b*sin((PI/180)*t);
putpixel(x+h,y+k,4);
putpixel(-x+h,y+k,4);
putpixel(x+h,-y+k,4);
putpixel(-x+h,-y+k,4);
}
getch();
}
-------------
Sandeep Kumar

No comments:

Post a Comment