src/Math/Point.php
protected function toCartesian($name)
  {
    if(!isset($this->gps['x'], $this->gps['y'], $this->gps['z']))
    {
      if(!isset($this->gps['vl'], $this->gps['ap'], $this->gps['av']))
        throw new \LogicException('Somehow, you managed to initialize instance with partial data.');

      $this->gps['x'] = $this->gps['vl'] * cos($this->gps['ap']) * cos($this->gps['av']);
      $this->gps['y'] = $this->gps['vl'] * sin($this->gps['ap']) * cos($this->gps['av']);
      $this->gps['z'] = $this->gps['vl'] * sin($this->gps['av']);
    }

    return $this->gps[$name];
  }
protected function toCartesian($name)
  {
    if(!isset($this->gps['x'], $this->gps['y'], $this->gps['z']))
    {
      if(!isset($this->gps['vl'], $this->gps['ap'], $this->gps['av']))
        throw new \LogicException('Somehow, you managed to initialize instance with partial data.');

      $this->gps['x'] = $this->gps['vl'] * cos($this->gps['ap']) * cos($this->gps['av']);
      $this->gps['y'] = $this->gps['vl'] * sin($this->gps['ap']) * cos($this->gps['av']);
      $this->gps['z'] = $this->gps['vl'] * sin($this->gps['av']);
    }

    return $this->gps[$name];
  }
Helper function to fill in missing properties, if needed.

@param $name the name of the requested property.
@return float the property value.