Bresenham's algorithm to generate circle in third quadrant in anticlockwise direction

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void main()
{
 
   int gd = DETECT, gm;
   int x1,y1=0,di,limit=0,R,d,d1,xi,yi;
    clrscr();
 
   initgraph(&gd, &gm,"C:\TC\BGI");
   xi=getmaxx()/2;
   yi=getmaxy()/2;
   setcolor(2);
   setbkcolor(8);
 
   printf("\n\n Enter the radius :");
   scanf("%d",&R);
   line(0,yi,xi*2,yi);
   line(xi,0,xi,yi*2);
   x1=-R;                 
   di=2*(1-R);
   putpixel(xi,yi,RED);
   while(x1<=limit)
     {
 putpixel(xi+x1,yi-y1,RED);         
 delay(75);
 if(di<0)
 {
    d=(2*di)-(2*y1)-1;
    if(d<=0)
    {
         y1=y1-1;
         di=di-2*y1+1;          
    }
    else
    {
         x1=x1+1;
        y1=y1-1;
        di=di+2*x1-2*y1+2;    
    }
 }
 else
 {
    if(di>0)
    {
       d1=2*di-2*x1-1;
       if(d1<=0)
       {
          x1=x1+1;
         y1=y1-1;
         di=di+2*x1-2*y1+2;   
       }
       else
       {
    x1=x1+1;
    di=di+2*x1+1;       
       }
    }
    else
    {
       if(di==0)
       {
    x1=x1+1;
          y1=y1-1;
          di=di+2*x1-2*y1+2;   
       }
    }
 }
     }     
     getch();
     closegraph();
     }
Previous
Next Post »

5 comments

Write comments
Anonymous
AUTHOR
19 February 2013 at 01:35 delete

http://kothadiahardik.blogspot.in/2012/06/black-books-of-java-20-pdf-by-steven.html

Reply
avatar
Anonymous
AUTHOR
27 February 2013 at 02:09 delete

This comment has been removed by a blog administrator.

Reply
avatar
Anonymous
AUTHOR
3 March 2013 at 04:23 delete

http://www.wegversity.com/wegilant-summer-training-and-internship-program/

Reply
avatar
Anonymous
AUTHOR
5 March 2013 at 23:49 delete

#include
#include
#include
#include
void push(int,int);
void pop(int *,int *);
int s[12000][2];
long top=-1;
void main()
{
int gd=DETECT,gm,i,x,y,xi,n,yi,sx,sy,a[10][10];

initgraph(&gd,&gm," ");
//xi=getmaxx()/2;
//yi=getmaxx()/2;
setcolor(RED);
printf("\n\n\tEnter the no. of edges of polygon : ");
scanf("%d",&n);
printf("\n\n\tEnter the cordinates of polygon :\n\n\n ");

for(i=0;i<n;i++)
{
printf("\tX%d Y%d : ",i,i);
scanf("%d %d",&a[i][0],&a[i][1]);
}
a[n][0]=a[0][0];
a[n][1]=a[0][1];
//line(0,yi,xi*2,yi);
//line(xi,0,xi,yi*2);
printf("enter seed pt:");
scanf("%d\t%d",&sx,&sy);
clrscr();
for(i=0;i<n;i++)
{
line(a[i][0],a[i][1],a[i+1][0],a[i+1][1]);
}



x=sx;
y=sy;
push(x,y);
while(top!=-1)
{
pop(&x,&y);
if(getpixel(x,y)!=WHITE)
putpixel(x,y,WHITE);
if(getpixel(x+1,y)!=WHITE && getpixel(x+1,y)!=RED)
push(x+1,y);
if(getpixel(x,y+1)!=WHITE && getpixel(x,y+1)!=RED)
push(x,y+1);


if(getpixel(x-1,y)!=WHITE && getpixel(x-1,y)!=RED)
push(x-1,y);
if(getpixel(x,y-1)!=WHITE && getpixel(x,y-1)!=RED)
push(x,y-1);
delay(10);
}
getch();
}
void push(int x,int y)
{
top++;
s[top][0]=x;
s[top][1]=y;
}
void pop(int *x,int *y)
{
*x=s[top][0];
*y=s[top][1];
top--;
}

Reply
avatar
Anonymous
AUTHOR
6 March 2013 at 07:18 delete

http://www.conferencealerts.com/country-listing?country=India

http://www.cs.sfu.ca/~vis/Tasks/camera.html

http://www.theired.org/ceee/paper_submission.html

Reply
avatar