#### 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 5381 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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 on other sites
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 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

##### Share on other sites
got it working thanks!

1. 1
Rutin
32
2. 2
3. 3
4. 4
5. 5

• 13
• 9
• 9
• 9
• 14
• ### Forum Statistics

• Total Topics
633328
• Total Posts
3011376
• ### Who's Online (See full list)

There are no registered users currently online

×

## Important Information

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!