Scan Convert a circle using polynomial method C++ code
Learn here Scan Convert a circle using polynomial method C++ code.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
#include<graphics.h> #include<stdio.h> #include<conio.h> #include<math.h> void plotcircle(int,int,int,int); int main() { int gd = DETECT, gm;; int xc,yc,x,y,xend,r,d; initgraph(&gd, &gm, ""); printf("\n\n Enter xc:"); scanf("%d",&xc); printf("\n\n Enter yc:"); scanf("%d",&yc); printf("\n\n Enter r:"); scanf("%d",&r); x=0; xend=r/sqrt(2); plotcircle(xc,yc,x,y); while(x<xend) { x=x+1; y=sqrt((r*r)-(x*x)); plotcircle(xc,yc,x,y); } getch(); } void plotcircle(int xc,int yc,int x,int y) { putpixel(xc+x,yc+y,2); putpixel(xc-x,yc+y,2); putpixel(xc+x,yc-y,2); putpixel(xc+y,yc+x,2); putpixel(xc-y,yc-x,2); putpixel(xc-y,yc+x,2); putpixel(xc+y,yc-x,2); putpixel(xc-x,yc-y,2); } |
Thanks for watching this C++ code about computer graphics.