How to evaluate if a point is inside a closed curve?

Hi all, I would like to know if there's a way of evaluating if a point is inside a closed curve. At the moment I haven't found nothing similar in the forum, can anyone help me? Thank you, J

Answers

  • Is the curve smooth or made from straight lines?

  • At the moment the curve is smooth but eventually I can try to find a way of approximate it with straight lines

  • Answer ✓

    A smooth curve can always be approximated with straight lines, the shorter the lines the smoother the shape will be. :)

    If you have straight lines then the solution is straight forward. Select any point that is outside the shape, easy enough pick one withh extremely large x and y coordinates [ox,oy]

    Now to test a point [x,y] to see if it inside the shape test the line [x,y]-[ox,oy] and see how many lines in the shape it intersects with (n)

    If n is odd then the point [x,y] is inside the shape if even it is outside the shape. Note zero is even.

  • J_DJ_D
    edited September 2015

    Thanks quark, I started working on that but I can't figure out how to evaluate the intersection between two lines and I haven't found examples yet..can you suggest me something? Thanks again

  • Answer ✓

    This webpage might help. Goto page 6 and you are looking foe intersection of 2 finite lines. There are loads more like this on the web.

  • That's exactly what I was looking for..thanks a lot

Sign In or Register to comment.