Polygon cropping: viewable zone only

In the image below, you see in (1) a triangle and a circle. Given the highlighted X in this triangle, I want to copy everything that is not visible from now on. There is no problem removing only a circle using a simple multifaceted difference algorithm similar to (2). But what algorithm can I use to get a polygon like in (3)?

The landfill is always simple.

Edit: The circle is just an example. Every simple polygon should be possible.

Image # 1

You can imagine my needs by looking at the image of the game "Commando - Behind Enemies":

Image # 2

+6
source share
2 answers

This is the main idea.

I suppose the problem is somewhat more general, but it will be easier to adapt to your problem: considering a plan containing all the shapes, a point and a set of geometric shapes, we want to remove the area that is not visible from the point from the plan.

We want to get starting_polar and ending_polar points for each shape, which are two points with the minimum and maximum polar angles belonging to the shape.

Now we will remove the form from the plan form and we will remove the quadrilateral formed by the points: starting_polar , ending_polar , and the intersections between the two lines (x, starting_polar) and (x, ending_polar) and the border of the plan .

In your case, the plan will be just a triangle .

+3
source

C, parallel D, G, parallel A, B, parallel F, D - diameter.

Polygon

0
source

Source: https://habr.com/ru/post/896665/


All Articles