什么是计算3D(或Nd)质心的最好方法是什么?质心、方法、Nd

2023-09-08 10:25:39 作者:钢铁不是铁

正如在工作项目的一部分我要计算在三维空间中的一组点的质心。现在我做的,这似乎简单,但天真的方式 - 通过为各组点的平均值,如:

As part of a project at work I have to calculate the centroid of a set of points in 3D space. Right now I'm doing it in a way that seems simple but naive -- by taking the average of each set of points, as in:

centroid = average(x), average(y), average(z)

其中, X 以Z 是数组的浮点数。我似乎记得,有一种方式来获得更准确的质心,但我还没有找到一个简单的算法这样做。任何人有任何意见或建议?我使用Python这一点,但我能适应其他语言的例子。

where x, y and z are arrays of floating-point numbers. I seem to recall that there is a way to get a more accurate centroid, but I haven't found a simple algorithm for doing so. Anyone have any ideas or suggestions? I'm using Python for this, but I can adapt examples from other languages.

推荐答案

不,这是点的集合的质心的唯一公式。参见维基百科: http://en.wikipedia.org/wiki/Centroid

Nope, that is the only formula for the centroid of a collection of points. See Wikipedia: http://en.wikipedia.org/wiki/Centroid