Untitled

 avatar
unknown
plain_text
2 years ago
1.4 kB
4
Indexable
//#include <windows.h>
#include <stdio.h>
#include <iostream>
#include <GL/glut.h>
#include <bits/stdc++.h>
#define PI 3.1416
using namespace std;

int pntX1, pntY1, r1;


void myInit (void)
{
        glClearColor(1.0, 1.0, 1.0, 0.0);
        glColor3f(0.0f, 0.0f, 0.0f);
        glPointSize(4.0);
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        gluOrtho2D(0.0, 640.0, 0.0, 480.0);
}

void PolarCircleAlgo()
{
        float x,y;

        for (float n=0; n<=45; n++)
        {
            x=r1*cos(PI * n / 180.0);
            y=r1*sin(PI * n / 180.0);


        glBegin(GL_POINTS);
        glVertex2i(x+pntX1, y+pntY1);
        glEnd();

        }

}


void myDisplay(void)
{
        glClear (GL_COLOR_BUFFER_BIT);
        glColor3f (1.0, 0.0, 0.0);
        glPointSize(1.0);

        PolarCircleAlgo();

        glFlush();
}

int main(int argc, char** argv)
{
        cout << "Enter the coordinates of the center:" << endl;
        cin >> pntX1;
        cin >> pntY1;
        cout << "\nEnter the value of radius : "; cin >> r1;




        glutInit(&argc, argv);
        glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
        glutInitWindowSize (640, 480);
        glutInitWindowPosition (100, 150);
        glutCreateWindow ("Polar Circle Alogrithm");
        glutDisplayFunc(myDisplay);

        myInit ();
        glutMainLoop();

}