Thread: Half of the circle

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Computer guy
    Join Date
    Sep 2005
    Location
    I'm lost!!!
    Posts
    200

    Half of the circle

    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:
    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();
    
    	}
    and this is how it looks like:
    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:
    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;
    	}
    and i get this:
    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?
    Last edited by hdragon; 03-07-2006 at 01:37 PM.
    Hello, testing testing. Everthing is running perfectly...for now

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. circle problem
    By gunghomiller in forum C++ Programming
    Replies: 10
    Last Post: 07-14-2007, 06:40 PM
  2. Half life Problem which I am right and the teacher is wrong
    By Shadow12345 in forum A Brief History of Cprogramming.com
    Replies: 13
    Last Post: 11-06-2002, 04:28 PM
  3. circle filling
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 06-08-2002, 05:37 AM
  4. The glass is half full
    By dirkduck in forum A Brief History of Cprogramming.com
    Replies: 11
    Last Post: 03-30-2002, 03:08 PM
  5. point lies in circle?
    By cozman in forum Game Programming
    Replies: 3
    Last Post: 12-20-2001, 04:39 PM