Sha256: 482ef841071c1f5db1c670c6e866d13e5dcd2d86e846706669be5fad8d0bcc6b

Contents?: true

Size: 1.48 KB

Versions: 8

Compression:

Stored size: 1.48 KB

Contents

/**
 * Computes the fraction of a Web Wercator extent at which a given geodetic latitude is located.
 *
 * @name czm_latitudeToWebMercatorFraction
 * @glslFunction
 *
 * @param {float} The geodetic latitude, in radians.
 * @param {float} The low portion of the Web Mercator coordinate of the southern boundary of the extent.
 * @param {float} The high portion of the Web Mercator coordinate of the southern boundary of the extent.
 * @param {float} The total height of the extent in Web Mercator coordinates.
 *
 * @returns {float} The fraction of the extent at which the latitude occurs.  If the latitude is the southern
 *          boundary of the extent, the return value will be zero.  If it is the northern boundary, the return
 *          value will be 1.0.  Latitudes in between are mapped according to the Web Mercator projection.
 */ 
float czm_latitudeToWebMercatorFraction(float latitude, float southMercatorYLow, float southMercatorYHigh, float oneOverMercatorHeight)
{
    float sinLatitude = sin(latitude);
    float mercatorY = 0.5 * log((1.0 + sinLatitude) / (1.0 - sinLatitude));
    
    // mercatorY - southMercatorY in simulated double precision.
    float t1 = 0.0 - southMercatorYLow;
    float e = t1 - 0.0;
    float t2 = ((-southMercatorYLow - e) + (0.0 - (t1 - e))) + mercatorY - southMercatorYHigh;
    float highDifference = t1 + t2;
    float lowDifference = t2 - (highDifference - t1);
    
    return highDifference * oneOverMercatorHeight + lowDifference * oneOverMercatorHeight;
}

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
cesium-0.25.0 app/assets/javascripts/Shaders/Builtin/Functions/latitudeToWebMercatorFraction.glsl
cesium-0.24.1 app/assets/javascripts/Shaders/Builtin/Functions/latitudeToWebMercatorFraction.glsl
cesium-0.24.0 app/assets/javascripts/Shaders/Builtin/Functions/latitudeToWebMercatorFraction.glsl
cesium-0.23.0 app/assets/javascripts/Shaders/Builtin/Functions/latitudeToWebMercatorFraction.glsl
cesium-0.22.0 app/assets/javascripts/Shaders/Builtin/Functions/latitudeToWebMercatorFraction.glsl
cesium-0.21.1 app/assets/javascripts/Shaders/Builtin/Functions/latitudeToWebMercatorFraction.glsl
cesium-0.21 app/assets/javascripts/Shaders/Builtin/Functions/latitudeToWebMercatorFraction.glsl
cesium-0.20.0 app/assets/javascripts/Shaders/Builtin/Functions/latitudeToWebMercatorFraction.glsl