在笛卡尔坐标系2D中计算不规则形状的边界 [英] Calculating the boundary of irregular shape in Cartesian Coordinate 2D

查看:182
本文介绍了在笛卡尔坐标系2D中计算不规则形状的边界的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种解决方案,以计算不规则形状的边界.

I'm looking for a solution to calculate the boundary of an irregular shape.

现在来看一下Square示例:

Lats take a look at Square example:

如果我有最低 xy以及最高 xy,例如:

if i have Minimum x and y and Maximum x and y like:

MaxX = 5
MinX = 1
MaxY = 5
MinY = 1

使用python语言:

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.

推荐答案

如果要获取形状内整数坐标的完整列表,请考虑使用

If you want to get full list of integer coordinates inside the shape, consider using of floodfill algorithm

这篇关于在笛卡尔坐标系2D中计算不规则形状的边界的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆