Fix a bug with the calculation of the CoM

Signed-off-by: eldr4d <nikofinas@gmail.com>