src/Math/Point.php
public function distance($target = null, $y = null, $z = null)
  {
    if(func_num_args() === 0 && isset($this->gps['vl']))
      return $this->gps['vl'];

    if($target instanceof self)
    {
      $_x = $this->x - $target->x;
      $_y = $this->y - $target->y;
      $_z = $this->z - $target->z;
    }
    else
    {
      $x = (float)$target;
      $y = (float)$y;
      $z = (float)$z;
      $_x = $this->x - $x;
      $_y = $this->y - $y;
      $_z = $this->z - $z;
    }

    $result = sqrt($_x*$_x + $_y*$_y + $_z*$_z);
    if(empty($x) && empty($y) && empty($z))
      $this->gps['vl'] = $result;

    return $result;
  }
public function distance($target = null, $y = null, $z = null)
  {
    if(func_num_args() === 0 && isset($this->gps['vl']))
      return $this->gps['vl'];

    if($target instanceof self)
    {
      $_x = $this->x - $target->x;
      $_y = $this->y - $target->y;
      $_z = $this->z - $target->z;
    }
    else
    {
      $x = (float)$target;
      $y = (float)$y;
      $z = (float)$z;
      $_x = $this->x - $x;
      $_y = $this->y - $y;
      $_z = $this->z - $z;
    }

    $result = sqrt($_x*$_x + $_y*$_y + $_z*$_z);
    if(empty($x) && empty($y) && empty($z))
      $this->gps['vl'] = $result;

    return $result;
  }
Distance between two coordinates.

[1] ->distance(static $target)
- Calculate distance to the target point.
[1] ->distance($x, $y, $z)
- Calculate distance to the target point given as a set of separate coordinates.

@param ?static|?numeric $target|$x the point to calculate distance from.
@param ?numeric $y the point to calculate distance from.
@param ?numeric $z the point to calculate distance from.
@return float distance