def compute_centroid(coords): """Compute the centroid of coordinates. .. math:: \\mathbf{C} = \\frac{\\sum_{i=1}^{N}m_i\\mathbf{r}_i}{\\sum_{i=1}^{N}m_i} Returns ------- C : `~sknano.core.math.Vector` The position vector of the centroid coordinates. """ C = Vector(np.mean(coords, axis=0)) C.rezero() return C
def centroid(self): """Centroid of `Atoms`. Computes the position vector of the centroid of the `Atoms` coordinates. .. math:: \\mathbf{C} = \\frac{\\sum_{i=1}^{N_{\\mathrm{atoms}}} \\mathbf{r}_i}{N_{\\mathrm{atoms}}} Returns ------- C : :class:`~sknano.core.math.Vector` The position vector of the centroid coordinates. """ C = Vector(np.mean(self.coords, axis=0)) C.rezero() return C
def center_of_mass(self): """Center-of-Mass coordinates of `Atoms`. Computes the position vector of the center-of-mass coordinates: .. math:: \\mathbf{R}_{COM} = \\frac{1}{M}\\sum_{i=1}^{N_{\\mathrm{atoms}}} m_i\\mathbf{r}_i Returns ------- com : :class:`~sknano.core.math.Vector` The position vector of the center of mass coordinates. """ masses = np.asarray([self.masses]) coords = self.coords MxR = masses.T * coords com = Vector(np.sum(MxR, axis=0) / np.sum(masses)) com.rezero() return com