Answers for "How to keep and grow a polygonal area in 2D"
http://answers.unity.com/questions/1670742/how-to-keep-and-grow-a-polygonal-area-in-2d.html
The latest answers for the question "How to keep and grow a polygonal area in 2D"Answer by MisterKidX
http://answers.unity.com/answers/1670844/view.html
'+1 Jarvis
This has a mathematical solution to it, and it is called... Drum roll... Ray Casting!
Take the point you wish to test against your polygon. Draw a ray from it in any direction, although for simplicity sake make it horizontal. Check the times it intersects your polygon - this is an easy test done with line segments intersection, like 9th grade. If you are using a horizontal line then you can compare the points' Y values. If it intersects your polygon even times it is outside of it. If odd times then it is inside. If it is outside you can add it to your polygon's list of points in the right location, effectively making it larger.Wed, 09 Oct 2019 18:41:07 GMTMisterKidXAnswer by dweiss
http://answers.unity.com/answers/1670778/view.html
For a single convexed polygon to envelop the base:
I would add the points to the current polygon I have and than create a convex polygon from the new points and save the new Polygon.
https://www.geeksforgeeks.org/convex-hull-set-1-jarviss-algorithm-or-wrapping/amp/
I would wait on reducing the polygon until i see the results of a lot of test casesWed, 09 Oct 2019 12:31:55 GMTdweissAnswer by dobbersp
http://answers.unity.com/answers/1670765/view.html
Some thoughts:
I'd look to maintain separate rectangle lists. 1 list for each set of important regions, such as a farms, and then another list for the base footprint.
For the base footprint, you'd merge/trim rectangles whenever you add a new structure/zone.
You'd need to make design decisions about the rules that govern your establishment. For example, can buildings/zones overlap existing ones? Do new buildings/zones need to be adjacent to existing ones?
- The new rectangle can be fully
overlapped by 1 or more existing
rectangles. If this is the case,
nothing needs to be added fo the footprint rectangles list.
- The new rectangle can be partially
overlapped by 1 or more existing
rectangles. For this case, you would
split the new rectangle and only add
the portion that is not overlapping.
- The new rectangle could align with an
existing rectangle (if it shares an
edge with an existing rectangle)
where you would merge it into the
other rectangle.
- The new rectangle could not overlap
or share an edge with any existing
rectangles, and you can determine if
you want to discard it as an invalid
base placement (making an exception
if it's your first rectangle) or
allow for non-adjacent rectangles in
your base footprint (probably tricky
for perimeter patrols that way
though)Wed, 09 Oct 2019 11:18:28 GMTdobbersp