123456789101112131415161718 |
- /**
- * Approximately computes spherical coordinates given a normal.
- * Uses approximate inverse trigonometry for speed and consistency,
- * since inverse trigonometry can differ from vendor-to-vendor and when compared with the CPU.
- *
- * @name czm_approximateSphericalCoordinates
- * @glslFunction
- *
- * @param {vec3} normal arbitrary-length normal.
- *
- * @returns {vec2} Approximate latitude and longitude spherical coordinates.
- */
- vec2 czm_approximateSphericalCoordinates(vec3 normal) {
- // Project into plane with vertical for latitude
- float latitudeApproximation = czm_fastApproximateAtan(sqrt(normal.x * normal.x + normal.y * normal.y), normal.z);
- float longitudeApproximation = czm_fastApproximateAtan(normal.x, normal.y);
- return vec2(latitudeApproximation, longitudeApproximation);
- }
|