private static function computeSignedAreaP($path,  $radius) {
        $size = count($path);
        if ($size < 3) { return 0; }
        $total = 0;
        $prev = $path[$size - 1];
        $prevTanLat = tan((M_PI / 2 - deg2rad($prev['lat'])) / 2);
        $prevLng = deg2rad($prev['lng']);
        // For each edge, accumulate the signed area of the triangle formed by the North Pole
        // and that edge ("polar triangle").
        foreach($path as $point) {
            $tanLat = tan((M_PI / 2 - deg2rad($point['lat'])) / 2);
            $lng = deg2rad($point['lng']);
            $total += self::polarTriangleArea($tanLat, $lng, $prevTanLat, $prevLng);
            $prevTanLat = $tanLat;
            $prevLng = $lng;
        }
        return $total * ($radius * $radius);
    }
private static function computeSignedAreaP($path,  $radius) {
        $size = count($path);
        if ($size < 3) { return 0; }
        $total = 0;
        $prev = $path[$size - 1];
        $prevTanLat = tan((M_PI / 2 - deg2rad($prev['lat'])) / 2);
        $prevLng = deg2rad($prev['lng']);
        // For each edge, accumulate the signed area of the triangle formed by the North Pole
        // and that edge ("polar triangle").
        foreach($path as $point) {
            $tanLat = tan((M_PI / 2 - deg2rad($point['lat'])) / 2);
            $lng = deg2rad($point['lng']);
            $total += self::polarTriangleArea($tanLat, $lng, $prevTanLat, $prevLng);
            $prevTanLat = $tanLat;
            $prevLng = $lng;
        }
        return $total * ($radius * $radius);
    }
private static function computeSignedAreaP ( $ path , $ radius ) { $ size = count ( $ path ) ; if ( $ size < 3 ) { return 0 ; } $ total = 0 ; $ prev = $ path [ $ size - 1 ] ; $ prevTanLat = tan ( ( M_PI / 2 - deg2rad ( $ prev [ 'lat' ] ) ) / 2 ) ; $ prevLng = deg2rad ( $ prev [ 'lng' ] ) ; // For each edge, accumulate the signed area of the triangle formed by the North Pole // and that edge ("polar triangle"). foreach ( $ path as $ point ) { $ tanLat = tan ( ( M_PI / 2 - deg2rad ( $ point [ 'lat' ] ) ) / 2 ) ; $ lng = deg2rad ( $ point [ 'lng' ] ) ; $ total += self :: polarTriangleArea ( $ tanLat , $ lng , $ prevTanLat , $ prevLng ) ; $ prevTanLat = $ tanLat ; $ prevLng = $ lng ; } return $ total * ( $ radius * $ radius ) ; }
Returns the signed area of a closed path on a sphere of given radius.
The computed area uses the same units as the radius squared.
Used by SphericalUtilTest.
Returns the signed area of a closed path on a sphere of given radius . The computed area uses the same units as the radius squared . Used by SphericalUtilTest .