-
Notifications
You must be signed in to change notification settings - Fork 0
/
broken_ellipse.c
85 lines (68 loc) · 1.64 KB
/
broken_ellipse.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include <stdio.h>
#include <stdlib.h>
#include <GL/glut.h>
#include <math.h>
#define PI 3.14
#include "main.h"
//code to draw the broken ellipse
//void draw_broken_ellipse(void)
void draw_broken_ellipse(GLfloat x,GLfloat y,float r,float g,float bl)
{
/*GLfloat x=200;
GLfloat y=300;
float r=1.0;
float g=0.0;
float bl=0.0;*/
// glPointSize(10.0);
///glColor3f( 0 ,0, 1);
// glBegin(GL_POINTS);
// glVertex2f(100.0,105.0) ;
// glEnd();
int i;
GLfloat radius=10;
int triangleAmount = 20; //# of triangles used to draw circle
glColor3f(r,g,bl);
//GLfloat radius = 0.8f; //radius
GLfloat twicePi = 2.0f * PI;
glPushMatrix();
glBegin(GL_TRIANGLE_FAN);
glVertex2f(x+10, y+40); // center of circle
for(i = 0; i<= triangleAmount;i++)
{
if(i>6 && i<15)
{
//if(y + (2*radius * sin(i * twicePi / triangleAmount))<100.0)
{
glVertex2f(
x + (radius * cos(i * twicePi / triangleAmount)),
y + (2*radius * sin(i * twicePi / triangleAmount))
);}
}
}
for(i = 0; i<= triangleAmount;i++)
{
if(i>6 && i<15)
{
//if(y + (2*radius * sin(i * twicePi / triangleAmount))<100.0)
{
glVertex2f(
x - (radius * cos(i * twicePi / triangleAmount)),
y + (2*radius * sin(i * twicePi / triangleAmount))
);}
}
}
for(i = 0; i<= triangleAmount;i++)
{
if(i>10)
{
//if(y + (2*radius * sin(i * twicePi / triangleAmount))<100.0)
{
glVertex2f(
x + (radius * cos(i * twicePi / triangleAmount)),
y + (2*radius * sin(i * twicePi / triangleAmount))
);}
}
}
glEnd();
glPopMatrix();
}