compute COM taking non-uniform model into account

This commit is contained in:
Chuyuan Fu
2019-10-25 12:14:38 -07:00
committed by Xuchen Han
parent 74571d79e7
commit ae7c3e0dee

View File

@@ -974,12 +974,14 @@ public:
/* Return the volume */ /* Return the volume */
btScalar getVolume() const; btScalar getVolume() const;
/* Cluster count */ /* Cluster count */
btVector3 getCenterOfMass() const{ btVector3 getCenterOfMass() const
{
btVector3 com(0, 0, 0); btVector3 com(0, 0, 0);
for(int i = 0; i<m_nodes.size(); i++){ for (int i = 0; i < m_nodes.size(); i++)
com += m_nodes[i].m_x; {
com += (m_nodes[i].m_x / m_nodes[i].m_im);
} }
com/=m_nodes.size(); com /= this->getTotalMass();
return com; return com;
} }
int clusterCount() const; int clusterCount() const;