相关疑难解决方法(0)

如何确定多边形点列表是否按顺时针顺序?

有一个点列表,我如何找到顺时针顺序?

例如:

point[0] = (5,0)
point[1] = (6,4)
point[2] = (4,5)
point[3] = (1,5)
point[4] = (1,0)
Run Code Online (Sandbox Code Playgroud)

会说它是逆时针(或逆时针,对某些人来说).

math geometry polygon computational-geometry

242
推荐指数
7
解决办法
12万
查看次数

按顺时针顺序排序点?

给定一个x,y点数组,如何按顺时针顺序(围绕它们的整体平均中心点)对该数组的点进行排序?我的目标是将点传递给线创建函数,以最终看起来相当"坚实"的东西,尽可能凸起,没有相交的线.

为了它的价值,我正在使用Lua,但任何伪代码都会受到赞赏.非常感谢您的帮助!

更新:作为参考,这是基于Ciamej优秀答案的Lua代码(忽略我的"app"前缀):

function appSortPointsClockwise(points)
    local centerPoint = appGetCenterPointOfPoints(points)
    app.pointsCenterPoint = centerPoint
    table.sort(points, appGetIsLess)
    return points
end

function appGetIsLess(a, b)
    local center = app.pointsCenterPoint

    if a.x >= 0 and b.x < 0 then return true
    elseif a.x == 0 and b.x == 0 then return a.y > b.y
    end

    local det = (a.x - center.x) * (b.y - center.y) - (b.x - center.x) * (a.y - center.y)
    if det < 0 then return true
    elseif det > 0 then …
Run Code Online (Sandbox Code Playgroud)

algorithm math lua geometry computational-geometry

148
推荐指数
3
解决办法
7万
查看次数

给定3分,我该如何计算法向量?

给定三个3D点(A,B和C),如何计算法向量?这三个点定义了一个平面,我希望矢量垂直于这个平面.

我可以获得演示此示例的示例C#代码吗?

c# math geometry .net-3.5

27
推荐指数
2
解决办法
4万
查看次数

用 Python 计算 3D 多面体的体积?

我试图找出用 Python 计算 3D 多面体体积的最佳方法,我希望有一个简单的解决方案,但我似乎找不到。

示例多面体 示例多面体

我确实发现这篇文章描述了计算 3D 空间中平面多边形的面积,但这似乎没有帮助。

python spatial

5
推荐指数
1
解决办法
5225
查看次数