Computer Graphics – 16. Circle Drawing – Naive Polar Form

[wpdm_package id=’1246′]
Sample Input –Draw a circle using the naive polar form of circle. The center of circle should be accepted using mouse clicks. Use 1 to 9 keyboard keys to specify the radius of circle.
Sample Output –Circle_Naive_Polar

[sourcecode lang=”cpp”]
void circle_using_polar_coordinates(int a, int b, int radius){
double x=0.0, y=0.0;
for(double i=0;i<=(2*3.14159);i+=(1.0/radius)){
x=a+(radius*cos(i));
y=b+(radius*sin(i));
draw_dot((int)x,(int)y);
}
}
[/sourcecode]

To compile the above program in ubuntu terminal –
# g++ -lGL -lGLU -lglut Circle_Naive_Polar.cpp
# ./a.out

Leave a Reply

Your email address will not be published. Required fields are marked *