2013/12/17

miniDooM: More Polygons

So I fixed the issue with the edges not rotating properly. The problem was... that I wasn't using the proper method (of the ones I programmed myself), so yeah, a bit silly, but, on the bright side, I got to test that other method too!

I've also realized why the polygons kept growing as I added more sides, and, again, it was a case of the algorithm working properly and me not using it correctly.

The thing is that, in order to create regular polygons, I would calculate the radius (distance from the center to a vertex) based on the side length, the formula being:

radius = sideLength / ( 2 * Sin ( 180 / numberOfSides ) )

Which means that, for a constant side length (as was the case in my tests), the radius will change as the number of sides changes.

So I've added a method that accepts a fixed polygon radius rather than side length, and here's the result:




For those who care to know:

Polygon2d( Point2d center, double radius, int edgeCount )

Oh, and yes, they are all rotating.


Incidentally, I need to rework that hexagon grid floor, it pops way too much for a floor texture.

No comments:

Post a Comment