Adding verts - regular polygons

Blitz3D Forums/Blitz3D Programming/Adding verts - regular polygons

_PJ_(Posted 2009) [#1]
I suck at this 3D malarkey :S

Essentially I am kinda making a cylindrical type object, but for reasons, I can't just use the primitive. (Well, maybe I might be able to, but I'd still have to fiddle with verts, so I might as well try to learn from the bottom up (quite literally ;) ) )

What I wish to do first off, is construct the base of the cylinder. It stands vertically up the Y axis. The base must be centred around the origin, flat on an XZ plane, as a regular polygon. The number of sides are defined by a parameter.

Already I can make a trianglular base, the equilateral points for the vertices of the triangle being:

AddVertex(Surface,0-a%,nIterSides-(nSides Shr True),0-b)
AddVertex(Surface,0,nIterSides-(nSides Shr True),b)
AddVertex(Surface,a,nIterSides-(nSides Shr True),0-b)

However, this is only because I know the relationships for an equilateral triangle, plus of course the fact only 1 tri is needed, so only the set of 3 verts.

Where I get stuck is being able to figure the a's and b's for a ny number of sides and I really am poor at trig.

I have somewhere a forumla I think that gives the minimum number of triangles required to build a n-sided polygon, but these seem to start from a vertex not a central origin...

Sorry if my explanation isn't very clear!


Yasha(Posted 2009) [#2]
Have you taken a look at this?


_PJ_(Posted 2009) [#3]
Thanks for that link, Yasha - I Hadn't seen that!

It looks a little confusing at firstglance, but I'll give it a shot tomorrow and see how I get on.