Finding coordinates of a n-sided polygon given the radius
I need a function that draws a polygon(with equal length sides) when given a number of sides and a radius.
For example:
int DrawPoly(GLfloat radius,GLint NumOfSides)
{
//What goes here?
}
Thanks in advance.
[edited by - heavymetalman on February 21, 2004 9:30:07 PM]
Sounds like a homework problem to me.
In any case, just draw a sphere that consists of n evenly-spaced points to get a n-sided poly (ie. define a sphere with n points and draw lines between them).
In any case, just draw a sphere that consists of n evenly-spaced points to get a n-sided poly (ie. define a sphere with n points and draw lines between them).
One simple way might be to divide 360 degrees by the number of sides (N) to get the angle (in degrees) between each vertex of the polygon. Then rotate a unit vector N times around the center point by the calculated angle, creating a vertex at each step by scaling the rotated vector by the radius.
Golem
Blender--The Gimp--Python--Lua--SDL
Nethack--Crawl--ADOM--Angband--Dungeondweller
Golem
Blender--The Gimp--Python--Lua--SDL
Nethack--Crawl--ADOM--Angband--Dungeondweller
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement