我可能必须实现一个重心类,但在此之前我会寻求帮助来寻找这样的 Java 类。我怀疑这已经被其他人作为数学库的一部分实现了。
在 n 维空间中,假设每个维度都是离散的。例如,在 3 维中,您可以拥有范围为 [0..a]
的 X 维度。您还有一个范围为 [0..b]
的 Y 维度和一个范围为 [0..c]
的 Z 维度。实现应该是通用的,以便维数可以大于 3,并且通常 a 不等于 b
,其中 a
和 b
是它们各自维度的最大坐标。
空间中的每个点都是 double float (非负)。
求重心坐标。
最佳答案
如果你使用物理引擎,你可以轻松获得重心——试试JBullet :) 您可以使用 API 获得的质心本质上是相同的,但略有不同:
The term center of mass is often used interchangeably with center of gravity, but they are physically different concepts. They happen to coincide in a uniform gravitational field, but where gravity is not uniform, center of gravity refers to the mean location of the gravitational force acting on a body. This results in small but measurable gravitational torque that must be accounted for in the operation of artificial satellites.
http://www.continuousphysics.com/Bullet/BulletFull/classbtRigidBody.html
关于java - Java 程序的重心类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6970229/