[IMPORTANT CHANGE] Take com as a 3d point rather than a 2d point (this should allow to consider cases in which gravityis not aligned with the z axis in the future).