/** * Calcule la distance séparant ce point et $point * @param IPoint $point * @return float|int La distance entre cet objet point et $point * @throws \Exception Si les 2 points n'ont pas la même dimension (2D ou 3D) */ public function getDistance(IPoint &$point) { $distance = 0; if ($this->getDimension() === $point->getDimension()) { switch ($point->getDimension()) { case '2D': $distance = $this->get2dDistance($point); break; case '3D': $distance = $this->get3dDistance($point); break; } } else { throw new \Exception("Les points doivent avoir la même dimension."); } return $distance; }