I don’t know how to calculate the vertex out in order to draw n side polygon when the user enter a number(ie n)
please give me some idea
thanks
I don’t know how to calculate the vertex out in order to draw n side polygon when the user enter a number(ie n)
please give me some idea
thanks
Is it possible to use a for loop around glVertex within a glBegin/End block for what you are doing?
I would like to caculate the vertex of regular polygon
here is the equation I found
vi = ( (R cos (2ð(i-1)/N)), (R sin (2ð(i-1)/N)) ) for i = 1, 2, … N.
but I cannot find any function to implement the pi, sine and cosine function
sorry~~
I think i ask an stupid question. It should be found in programming language
I wrote a little routine that would produce a list of vertex points, based on the number of sides inputed.
n = 3 = triangle
n = 4 = square
etc.
With enought points start to look like a circle.
void buildquad( int sides, Point3F polygon[])
{
float angle, xangle;
float x, y, z;
float r;
int i;
r = 2.0f;
xangle = 3.1415927f / sides;
for (i=0; i <= sides; i++)
{
angle = xangle * i * 2;
polygon[i].xyz[0] = r * cos( angle ); // X
polygon[i].xyz[1] = r * sin( angle ); // Y
polygon[i].xyz[2] = 0.0f; // Z
}
polygon[i] = polygon[0];
}