Fixed the centroid function bug.
The last commit only fixed a few cases.
This should fix a few more.

Signed-off-by: Pier-Luc Plante <pier-luc.plante.1@ulaval.ca>