问题
I'm looking for a solution to calculate the boundary of an irregular shape.
Lats take a look at Square example:
if i have Minimum x
and y
and Maximum x
and y
like:
MaxX = 5
MinX = 1
MaxY = 5
MinY = 1
in python language:
#Python Code
X = {"Min":1, "Max":5} # is Dictionary of x Axis
Y = {"Min":1, "Max":5} # is Dictionary of y Axis
I can check if any coordinate is in the square boundary or not, simpley by comparing the axis against min and max of square boundary.
now let's look at these 2 irregular example:
Now how can i calculate the boundary and coordinates of the shape? i do have the point coordinate but i don't have the coordinates inside the shape and lines coordinate that connecting every points of the shape.
Note: you might suggest for Point-in-Polygon but that's like calculating every time for specific coordinate, and if shape is huge it will take time.
Note: even if you heard of a solution in any book, speech, video, website, or even you are guessing, please do let me know in the comment, that could help me out.
回答1:
If you want to get full list of integer coordinates inside the shape, consider using of floodfill algorithm
来源:https://stackoverflow.com/questions/34784774/calculating-the-boundary-of-irregular-shape-in-cartesian-coordinate-2d