πŸŽ“ Computer Science & Engineering Portal

Master Engineering Disciplines with Structured Notes

Comprehensive academic lecture notes, exam-oriented unit summaries, laboratory manuals, and previous year question papers designed strictly for university students.

πŸ“‘

University Syllabi

AKTU & AICTE aligned semester guidelines.

πŸ“

Exam Question Papers

Previous 5 years solved university papers.

πŸ’‘

Lab Manuals & Viva

Practical codes with outputs & interview Qs.

Core Subjects & Units Hub

Click on any specific unit to immediately view its lecture notes below

Viewing All Lectures

circle using Polar Co-ordinates

Defining a circle using Polar Co-ordinates :

The second method of defining a circle makes use of polar coordinates as shown in fig:

            x=r cos ΞΈ             y = r sin ΞΈ
Where ΞΈ=current angle
r = circle radius
x = x coordinate
y = y coordinate

By this method, ΞΈ is stepped from 0 to Defining a circle using Polar Co-ordinates & each value of x & y is calculated.

Defining a circle using Polar Co-ordinates

Algorithm:

Step1: Set the initial variables:

            r = circle radius

            (h, k) = coordinates of the circle center
                i = step size
            ΞΈ_end=Defining a circle using Polar Co-ordinates
            ΞΈ=0

Step2: If ΞΈ>ΞΈendthen stop.

Step3: Compute

            x = r * cos ΞΈ            y=r*sin?ΞΈ

Step4: Plot the eight points, found by symmetry i.e., the center (h, k), at the current (x, y) coordinates.

Plot (x + h, y +k)             Plot (-x + h, -y + k)
Plot (y + h, x + k)             Plot (-y + h, -x + k)
Plot (-y + h, x + k)             Plot (y + h, -x + k)
Plot (-x + h, y + k)             Plot (x + h, -y + k)

Step5: Increment ΞΈ=ΞΈ+i

Step6: Go to step (ii).

Program to draw a circle using Polar Coordinates:

#include <graphics.h>  
#include <stdlib.h>  
#define color 10  
void eightWaySymmetricPlot(int xc,int yc,int x,int y)  
{  
    putpixel(x+xc,y+yc,color);  
    putpixel(x+xc,-y+yc,color);  
    putpixel(-x+xc,-y+yc,color);  
    putpixel(-x+xc,y+yc,color);  
    putpixel(y+xc,x+yc,color);  
    putpixel(y+xc,-x+yc,color);  
    putpixel(-y+xc,-x+yc,color);  
    putpixel(-y+xc,x+yc,color);  
}  
void PolarCircle(int xc,int yc,int r)  
{  
    int x,y,d;  
    x=0;  
    y=r;  
    d=3-2*r;  
    eightWaySymmetricPlot(xc,yc,x,y);  
    while(x<=y)  
    {  
        if(d<=0)  
        {  
            d=d+4*x+6;  
        }  
        else  
        {  
            d=d+4*x-4*y+10;  
            y=y-1;  
        }  
        x=x+1;  
        eightWaySymmetricPlot(xc,yc,x,y);  
    }  
}  
int main(void)  
{  
    int gdriver = DETECT, gmode, errorcode;  
    int xc,yc,r;  
    initgraph(&gdriver, &gmode, "c:\\turboc3\\bgi");  
errorcode = graphresult();  
if (errorcode != grOk)    
    {  
        printf("Graphics error: %s\n", grapherrormsg(errorcode));  
        printf("Press any key to halt:");  
        getch();  
        exit(1);               
    }  
printf("Enter the values of xc and yc ,that is center points of circle : ");  
    scanf("%d%d",&xc,&yc);  
    printf("Enter the radius of circle : ");  
    scanf("%d",&r);  
    PolarCircle(xc,yc,r);  
    getch();  
    closegraph();  
    return 0;  
}

  

Output:

Defining a circle using Polar Co-ordinates

Labels: ,

Discussion & Queries (<$I18NNumComments$>):

<$CommentPager$>
<$I18NAtCommentTimeWithPermalink$>, <$I18NCommentAuthorSaid$>

<$BlogCommentBody$>

<$BlogCommentDeleteIcon$>
<$CommentPager$>