Calculating the boundary of irregular shape in Cartesian Coordinate 2D

青春壹個敷衍的年華 提交于 2019-12-13 14:25:29

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!