How to determine which side of a polygon edge is inside a polygon, and which is outside?

后端 未结 2 510
-上瘾入骨i
-上瘾入骨i 2021-01-20 03:53

I have an edge of a polygon (convex or concave). I want to find out if, going straight from start to end point of that edge, I have to turn right or left to get inside or ou

2条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-20 04:33

    Another approach:

    Project a perpendicular line and count how many times it crosses other edges.

    odd -> interior

    zero or even -> exterior

    Equivalently If you happen to have a well optimized point-in-polygon routine available you can project a point some epsilon off the line and throw it into the inside test.

提交回复
热议问题