lineDistance.js 681 B

12345678910111213141516
  1. //This file is automatically rebuilt by the Cesium build process.
  2. export default "/**\n\
  3. * Computes distance from an point in 2D to a line in 2D.\n\
  4. *\n\
  5. * @name czm_lineDistance\n\
  6. * @glslFunction\n\
  7. *\n\
  8. * param {vec2} point1 A point along the line.\n\
  9. * param {vec2} point2 A point along the line.\n\
  10. * param {vec2} point A point that may or may not be on the line.\n\
  11. * returns {float} The distance from the point to the line.\n\
  12. */\n\
  13. float czm_lineDistance(vec2 point1, vec2 point2, vec2 point) {\n\
  14. return abs((point2.y - point1.y) * point.x - (point2.x - point1.x) * point.y + point2.x * point1.y - point2.y * point1.x) / distance(point2, point1);\n\
  15. }\n\
  16. ";