computing center of mass