src/Lootils/Geo/Location.php
public function cartesian() {

    // Convert from degrees to radians.
    $radLong = deg2rad($this->longitude());
    $radLat = deg2rad($this->latitude());

    $coslong = cos($radLong);
    $coslat = cos($radLat);
    $sinlong = sin($radLong);
    $sinlat = sin($radLat);

    $radius = $this->earthRadiusSemimajor() / sqrt(1 - $this->earthEccentricitySq() * $sinlat * $sinlat);

    $return = array();
    $return['x'] = ($radius + $this->height()) * $coslat * $coslong;
    $return['y'] = ($radius + $this->height()) * $coslat * $sinlong;
    $return['z'] = ($radius * (1 - $this->earthEccentricitySq()) + $this->height()) * $sinlat;

    return $return;
  }
public function cartesian() {

    // Convert from degrees to radians.
    $radLong = deg2rad($this->longitude());
    $radLat = deg2rad($this->latitude());

    $coslong = cos($radLong);
    $coslat = cos($radLat);
    $sinlong = sin($radLong);
    $sinlat = sin($radLat);

    $radius = $this->earthRadiusSemimajor() / sqrt(1 - $this->earthEccentricitySq() * $sinlat * $sinlat);

    $return = array();
    $return['x'] = ($radius + $this->height()) * $coslat * $coslong;
    $return['y'] = ($radius + $this->height()) * $coslat * $sinlong;
    $return['z'] = ($radius * (1 - $this->earthEccentricitySq()) + $this->height()) * $sinlat;

    return $return;
  }
Get the Cartesian coordinates (x, y, z) for this location.

@return array
An array of floats keyed with x, y, z for the location.