All files / engine/Source/Shaders/Builtin/Functions lineDistance.js

0% Statements 0/0
0% Branches 0/0
0% Functions 0/0
0% Lines 0/0

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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