math/Vector.php
public function cartesianDistanceTo(Vector $that) : float
    {
        if (!$this->isSameDimension($that)) {
            throw new \DomainException('The given input Vector is not in the same dimension as this Vector.');
        }

        $result = 0;

        foreach ($this->components as $i => $component) {
            $result += pow($component - $that->components[$i], 2);
        }

        return sqrt($result);
    }
public function cartesianDistanceTo(Vector $that) : float
    {
        if (!$this->isSameDimension($that)) {
            throw new \DomainException('The given input Vector is not in the same dimension as this Vector.');
        }

        $result = 0;

        foreach ($this->components as $i => $component) {
            $result += pow($component - $that->components[$i], 2);
        }

        return sqrt($result);
    }
public function cartesianDistanceTo ( Vector $ that ) : float { if ( ! $ this -> isSameDimension ( $ that ) ) { throw new \ DomainException ( 'The given input Vector is not in the same dimension as this Vector.' ) ; } $ result = 0 ; foreach ( $ this -> components as $ i => $ component ) { $ result += pow ( $ component - $ that -> components [ $ i ] , 2 ) ; } return sqrt ( $ result ) ; }
Returns the cartesian distance of this Vector to the given Vector.

@param   Vector  $that       The Vector to calculate the distance to.
@return  float               The cartesian distance.
@throws  \DomainException    When the given Vector is not in the same space as this Vector.
Returns the cartesian distance of this Vector to the given Vector .