如何找到位于环绕二维平面内的区域的 "Eastern" 个最点
How to find "Eastern" most point of Regions Located Within Wrapping 2-d Plane
我正在尝试找出一种方法来确定环绕二维平面上存在的连续区域的最远方(最东边、最西边等)。左下角的点是 [0,0],例如,右上角的点是 [244,244] 我在下面包含了我的数据示例。请注意,出现在 4 个角中的深灰色区域是同一区域。
通过检查给定区域内的每个方块并记录具有最高 X 的方块,我能够用我的数据解决这个问题。我也进行了相同的搜索,但仅限于 [0,width * .5]。但是,此解决方案仅适用于我的区域主要围绕一个点而不是细长。
@maraca 在评论中概述了一种方法,我认为可以提炼为:
* find an edge square
* assign 0 to current square
* walk around the edges, adding 1 when travelling east, -1 when travelling west (or north/ south)
* the square with the highest value is the furthest east, the square with the lowest value is the furthest west
@maraca 在评论中概述了一种方法,我认为可以提炼为:
* find an edge square
* assign 0 to current square
* walk around the edges, adding 1 when travelling east, -1 when travelling west (or north/ south)
* the square with the highest value is the furthest east, the square with the lowest value is the furthest west
效果很好。谢谢!
我正在尝试找出一种方法来确定环绕二维平面上存在的连续区域的最远方(最东边、最西边等)。左下角的点是 [0,0],例如,右上角的点是 [244,244] 我在下面包含了我的数据示例。请注意,出现在 4 个角中的深灰色区域是同一区域。
通过检查给定区域内的每个方块并记录具有最高 X 的方块,我能够用我的数据解决这个问题。我也进行了相同的搜索,但仅限于 [0,width * .5]。但是,此解决方案仅适用于我的区域主要围绕一个点而不是细长。
@maraca 在评论中概述了一种方法,我认为可以提炼为:
* find an edge square
* assign 0 to current square
* walk around the edges, adding 1 when travelling east, -1 when travelling west (or north/ south)
* the square with the highest value is the furthest east, the square with the lowest value is the furthest west
@maraca 在评论中概述了一种方法,我认为可以提炼为:
* find an edge square
* assign 0 to current square
* walk around the edges, adding 1 when travelling east, -1 when travelling west (or north/ south)
* the square with the highest value is the furthest east, the square with the lowest value is the furthest west
效果很好。谢谢!