Avoid full random
Hi Daniel,
You may find here a pull request removing the full randomness to determine a good_ray. I've added missing test for closed polygons.
The test is based on the following gist : https://gist.github.com/PikachuEXE/71c6d0961e6bdc31846f Thanks to @PikachuEXE :-)
Instead of exiting the loop, when MAX_SEED is reached, one could raise an exception
I'm sorry for the delay of my answer. Instead of generating full random angles, the idea is to test opposed angles iteratively, trying to minimize good_ray duration. I've added an exit from the loop to avoid blocking all the process if we aren't able to find a good ray, and 1000000 is just a large number.
As a polygon is 'closed', which means that even if the ray might be parallel to an edge, it will cross some other edges. Why do we need to test for ray not to be parallel to any edge ?
In fact, this PR is more an idea to test another approach.