So i ran into a problem with circle. I could draw a whole circle easily, but when i tried half of the circle, it doesn't go in the way i wanted.
in my draw circle function, i set the vectors' coordinate base on the information of the class. Then use "gl triangle fan" to draw the circle:
and this is how it looks like:Code:vect2* BuildBar() { //Pi() is the function return Pi's value Vertices = new vect2[numVertices+2]; for(int j=0; j<numVertices+2; j++) { double a = 2*Pi() * (j/double(numVertices)); Vertices[j] = vect2(cos(a), sin(a)) * (R); //R is the radius } return Vertices; } void Render() { glLoadIdentity(); glTranslatef(Pos.x, Pos.y, 0); glBegin(GL_TRIANGLE_FAN); for(int j=0; j<numVertices+2; j++) { glVertex2d(Vertices[j].x, Vertices[j].y); } glEnd(); }
http://www.albumtown.com/data/953ecc...66_p935793.gif
But my intention is just only part of the circle. I was trying to get something like this:
http://www.albumtown.com/data/953ecc...66_p935796.gif
so i change my build function and tried to get that half circle:
and i get this:Code:vect2* BuildBar() { /**/ Vertices = new vect2[numVertices+2]; for(int j=0; j<numVertices+2; j++) { double a = Pi()/1.5 * (j/double(numVertices)); Vertices[j] = vect2(cos(a), sin(a)) * (R); } return Vertices; }
http://www.albumtown.com/data/953ecc...66_p935794.gif
No matter what way i rotate, the whole thing just won't stay straight like the second picture. So, what should i set for the sin() and cos() in order to straight up the circle like the second picture?