0% found this document useful (0 votes)
46 views5 pages

Name - Rakesh Choudhary Sap-ID-500071544 Enrollment-no-R172218167 CSE-Big Data Batch-B3

The document contains details of a student's computer graphics experiment to implement the Midpoint Circle Drawing algorithm. It includes the student's name, ID number, course and batch details. It then provides an overview of the theory behind the algorithm, outlines the steps of the Bresenham circle drawing algorithm, includes the code implementation with functions to plot pixels and draw the circle, and describes that the output is a circle drawn using the algorithm.

Uploaded by

Rakesh Choudhary
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views5 pages

Name - Rakesh Choudhary Sap-ID-500071544 Enrollment-no-R172218167 CSE-Big Data Batch-B3

The document contains details of a student's computer graphics experiment to implement the Midpoint Circle Drawing algorithm. It includes the student's name, ID number, course and batch details. It then provides an overview of the theory behind the algorithm, outlines the steps of the Bresenham circle drawing algorithm, includes the code implementation with functions to plot pixels and draw the circle, and describes that the output is a circle drawn using the algorithm.

Uploaded by

Rakesh Choudhary
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Name –Rakesh Choudhary

Sap-ID-500071544
Enrollment-no-R172218167
CSE-Big Data
Batch-B3

Computer Graphics
Experiment-9
Title: To implement Mid Point Circle drawing algorithm.
Theory:-
 This algorithm is needed for rasterizing a circle.
 It plot the points of one octant.
 After plotting the points of first octant, it prints the mirror points in
other octants.
 In every iteration we have to choose between two points i.e. (x+1 ,y1)
or (x+1 ,y-1).
Algorithm:-
bresenhamCircle(int xc,int yc,int r)
{
x=0,y=r;
d=(5/4)-r;
plotpixel(xc,yc,x,y);
while(x<=y)
{
if(d<=0)
{
d=d+(2*x)+3;
}
else
{
d=d+(2*x)-(2*y)+5;
y--;
}
x++;
plotpixel(xc,yc,x,y);
}
}
Code:-
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <math.h>

void plotpixel(int xc,int yc,int x,int y)


{
putpixel(x+xc,y+yc,WHITE);
putpixel(x+xc,-y+yc,WHITE);
putpixel(-x+xc,-y+yc,WHITE);
putpixel(-x+xc,y+yc,WHITE);
putpixel(y+xc,x+yc,WHITE);
putpixel(y+xc,-x+yc,WHITE);
putpixel(-y+xc,-x+yc,WHITE);
putpixel(-y+xc,x+yc,WHITE);
}

void bresenhamCircle(int xc,int yc,int r)


{
int x=0;
int y=r;
float d=(5/4)-r;
plotpixel(xc,yc,x,y);

while(x<=y)
{
if(d<=0)
{
d=d+(2*x)+3;
}
else
{
d=d+(2*x)-(2*y)+5;
y--;
}
x++;
plotpixel(xc,yc,x,y);
}
}
int main(void)
{
int xc,yc,r,gdriver = DETECT, gmode, errorcode;
initgraph(&gdriver, &gmode, "C:\\TURBOC3\\BGI");
bresenhamCircle(250,250,200);
getch();
return 0;
}
Output:-

You might also like