Archived

This topic is now archived and is closed to further replies.

Finding coordinates of a n-sided polygon given the radius

This topic is 5043 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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).

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites