<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>circle drawing | Student Projects</title>
	<atom:link href="https://studentprojects.in/tag/circle-drawing/feed/" rel="self" type="application/rss+xml" />
	<link>https://studentprojects.in</link>
	<description>Microcontroller projects, Circuit Diagrams, Project Ideas</description>
	<lastBuildDate>Fri, 02 Oct 2009 10:09:47 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.1.7</generator>
	<item>
		<title>C Program to implement the midpoint circle drawing algorithm</title>
		<link>https://studentprojects.in/software-development/c-tutorials/c/graphics/c-program-to-implement-the-midpoint-circle-drawing-algorithm/</link>
					<comments>https://studentprojects.in/software-development/c-tutorials/c/graphics/c-program-to-implement-the-midpoint-circle-drawing-algorithm/#comments</comments>
		
		<dc:creator><![CDATA[Editorial Team]]></dc:creator>
		<pubDate>Fri, 02 Oct 2009 10:09:47 +0000</pubDate>
				<category><![CDATA[Graphics]]></category>
		<category><![CDATA[c program]]></category>
		<category><![CDATA[algorithm]]></category>
		<category><![CDATA[midpoint circle]]></category>
		<category><![CDATA[circle drawing]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=825</guid>

					<description><![CDATA[<p>C Program to implement the midpoint circle drawing algorithm to draw a circle. Modify the algorithm toimplement specified arc or sector.</p>
<p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c/graphics/c-program-to-implement-the-midpoint-circle-drawing-algorithm/">C Program to implement the midpoint circle drawing algorithm</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>C Program to implement the midpoint circle drawing algorithm to draw a circle. Modify the algorithm toimplement specified arc or sector.</p>
<pre lang="c" escaped="true" line="1">
#include <graphics.h>
#include <conio.h>
#include <math.h>
#include <stdio.h>

#define PI 3.14

float startangle,endangle;
int x,y;

int Can_draw( float theta )
{
	if( theta >= startangle && theta<= endangle )
		return 1;
	return 0;
}

void Circlepoints(int x,int y,int xc,int yc)
{
	float theta;
	theta = atan( (float)y/x );
	theta = theta * (180/M_PI);
	
if( Can_draw(theta))
		putpixel(xc+x,yc-y,WHITE);
	if( Can_draw(360-theta))
		putpixel(xc+x,yc+y,WHITE);
	
if( Can_draw(90-theta))
		putpixel(xc+y,yc-x,WHITE);
	if( Can_draw(270+theta))
		putpixel(xc+y,yc+x,WHITE);
	
if( Can_draw(180-theta))
		putpixel(xc-x,yc-y,WHITE);
	if( Can_draw(180+theta))
		putpixel(xc-x,yc+y,WHITE);
	
if( Can_draw(90+theta))
		putpixel(xc-y,yc-x,WHITE);
	if( Can_draw(270-theta))
		putpixel(xc-y,yc+x,WHITE);
}

void MidPointcircle(int xc,int yc,int rad)
{
	float d = (5/4.0) - rad;
	x=0,y=rad;

	while(y>x)
	{
		if(d<0) 
 			d += 2*x+3;
		else 	
			d+=(2*x)-(2*y)+5,y--;
		x++;
		Circlepoints(x,y,xc,yc);
		delay(90);
	}
}
void main()
{
	int gd=DETECT,gm;
	int radius,xc,yc,choice,temp;
	float xstart,ystart,xend,yend;
	initgraph(&#038;gd,&#038;gm,"..\\bgi");
	do
	{
		clrscr();
		cleardevice();
		printf("\n Enter your choice\n");
		printf("\n 1.Draw a Circle\n 2.Draw a Sector\n 3.Draw an Arc\n 4.Exit\n");
		scanf("%d",&#038;choice);
		switch(choice)
		{
			case 1: printf("\n Enter the center:");
				scanf("%d %d",&#038;xc,&#038;yc);
				printf("\n Enter the radius:");
				scanf("%d",&#038;radius);
				cleardevice();
				startangle=0,endangle=360;
				MidPointcircle(xc,yc,radius);
				getch();
				break;

			case 2: printf("\n Enter the center:");
				scanf("%d %d",&#038;xc,&#038;yc);
				printf("\n Enter the radius:");
				scanf("%d",&#038;radius);
				printf("\n Enter the startangle:");
				scanf("%f",&#038;startangle);
				printf("\n Enter the endangle:");
				scanf("%f",&#038;endangle);
				cleardevice();
				if(startangle>endangle)
				{
					temp=startangle;
					startangle=endangle;
					endangle=temp;
				}
				MidPointcircle(xc,yc,radius);
				xstart=xc+radius*cos(PI/180*startangle);
				ystart=yc-radius*sin(PI/180*startangle);
				xend=xc+radius*cos(PI/180*endangle);
				yend=yc-radius*sin(PI/180*endangle);
				line(xc,yc,xstart,ystart);
				line(xc,yc,xend,yend);
				getch();
				break;

			case 3: printf("\n Enter the center:");
				scanf("%d %d",&xc,&yc);
				printf("\n Enter the radius:");
				scanf("%d",&radius);
				printf("\n Enter the startangle:");
				scanf("%f",&startangle);
				printf("\n Enter the endangle:");
				scanf("%f",&endangle);
				cleardevice();
				if(startangle>endangle)
				{
					temp=startangle;
					startangle=endangle;
					endangle=temp;
				}
				MidPointcircle(xc,yc,radius);
				getch();
				break;

		       case 4:  closegraph();
		}
	}while(choice!=4);
}
</pre><p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c/graphics/c-program-to-implement-the-midpoint-circle-drawing-algorithm/">C Program to implement the midpoint circle drawing algorithm</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/c-tutorials/c/graphics/c-program-to-implement-the-midpoint-circle-drawing-algorithm/feed/</wfw:commentRss>
			<slash:comments>12</slash:comments>
		
		
			</item>
	</channel>
</rss>
