Answer the question
In order to leave comments, you need to log in
How to check whether a polygon belongs to some area of the coordinate plane?
Let there be some number of polygons on the coordinate plane. How can I check that one or more of them belong (or do not belong) to some pre-known area.
More specific examples.
1. How can I know if a part of a polygon belongs to my area? (red box 1)
2. How can I know that parts of multiple polygons are inside my area? (window 2)
3. ---//--- that none of the polygons belong to my area? (window 3)
4. ---//--- that my window is completely inside one or more polygons? (window 4)
5, ---//--- , that my window completely spans one or more polygons, while possibly capturing parts of other polygons? (window 5)
Absolutely something got confused with this task. At best, I was grateful to a step-by-step algorithm or an algorithm in some programming language or pseudo-language. Well, or at least just a mathematical justification for how to do it. Thanks for that too :)
Answer the question
In order to leave comments, you need to log in
If the window is a rectangle with sides parallel to the coordinate axes (vertical and horizontal), then you should use this, it will greatly simplify life.
What are the options:
1 the polygon is completely inside the window
2 the polygon intersects the window
3 the window lies inside the rectangle
In the first case, all the vertices of the polygon lie inside, there are no intersections on the sides.
In the second, there are intersections on the sides. The vertices can be distributed in different ways(!)
In the third one, there are no intersections of the sides, all the vertices are outside.
It turns out that you need to be able to check 2 facts:
1 vertex inside the window -- elementary, x_min<=x<=x_max && y_min<=y<=y_max
2 side of the polygon intersects with the side of the square. A little more complicated, but given that the sides of the square are parallel to the axes, the code will be simple.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question