|P is for Practical|
RFC: Creating unicursal starsby Fox (Pilgrim)
|on Nov 06, 2009 at 14:17 UTC||Need Help??|
All started a week ago when I saw a unicursal hexagram and I started wondering the logic behind drawing a n-points unicursal star, so I gone thorough some wikipedia articles and finally created a method that can draw a unicursal star polygon of n points for any natural* number.
For those wondering, any non-convex polygon in star form could be considered a star polygon, but only those where the lines can be draw starting and ending at the same point, passing through all the other points exactly one time are unicursal star polygons
Although my code works like I wanted, I still don't like how it does it, so I would like to hear what the perlmonks have to say about it.
And here is the code:
$perl draw_star.pl N > img.svg ,where N is the points number
and open the result in your favorite browser/image viewer.
The main problem is finding the $mod number, this is how much points it will 'jump' from the current point to draw the next line.
Notice that this is where things get dirty, calcMagic was called this ways because I failed in understand the logic(if any) behind it.
There is also a side problem, take a look again in the unicursal hexagram and you will notice that it's irregular, which means the $mod number changes depending on the current point.
..and, although I was a Anonymous Monk for quite a time, I sill not sure if this is the right place for this, even after reading Where should I post X?, so I'm sorry if it isn't.