Ad
  • Custom User Avatar
  • Custom User Avatar

    yeah, that's a point.
    with the test cases generated it shouldn't be any problem.
    i also looked through all the tests and it's looking good :) i can approve now.

  • Custom User Avatar

    Ah, I've read the article on Wikipedia. Well, I think that if other users implement an easier algorithm, there should not be issues in the test suite.

  • Custom User Avatar

    Could you give a link to the standard algorithm, please? Because I was pretty sure, that algorithm implemented by me is standard.

    As a note, you're right, that in ideal case this algorithm requires several additional checks, so as not to fail. However, generating an ideal test suite for this problem seems very difficult and lengthy to me, so I decided to only leave the check, that the randomly generated point is not too close to polygon.

    More than that, precision of 1e-9 is very rarely needed, in practice. In my previous job, I've used the same algorithm to validate, if client's home is in delivery zones of restaurant, where delivery zones were given as a list of geolocation coordinates. Even a precision of 1e-5 or 1e-6 already gives you a precision up to a corner of the house, so here's that.

  • Custom User Avatar

    Your approach to the problem of the ray intersecting with a polygon vertex is interesting.
    If i were nit-picky, you could construct a tiny polygon with vertices every 10^-9 distance units, to make your algorithm run in an endless loop.

    Wikipedia states the following to this problem
    If the intersection point is a vertex of a tested polygon side, then the intersection counts only if the second vertex of the side lies below the ray.

    Perhaps with this approach, the solution could be simpler? And easier to verify the correctnes for reviewers ;)
    Don't get me wrong, it's an interesting solution and probably works correctly, it would just be easier to review if you implemented a standard algorithm.
    Also, i want take a look at your generated polygons, but i don't have so much time right now.

  • Custom User Avatar

    allright, fair enough.

  • Custom User Avatar

    I prefer not to enforce visualization and leave it up to user. The method is preloaded in initial solution, either way.

  • Custom User Avatar

    thanks for the translation. still need to take a deeper look to approve.
    one thing i noticed right away

    • i think it's nice to have the visualization already in the sample tests, like in javascript