function ptLineDistance(p, line1, line2) {
    let dx = (line2.x - line1.x);
    let dy = (line2.y - line1.y);
    let res = dy * p.x - dx * p.y + line2.x * line1.y - line2.y * line1.x;

    return Math.abs(res) / Math.sqrt(dy*dy + dx*dx);
}
// Returns the distance from point p to line defined by two points (line1, line2)
Returns the distance from point p to line defined by two points (line1, line2)
Returns the distance from point p to line defined by two points ( line1 line2 )
function ptLineDistance(p, line1, line2) {
    let dx = (line2.x - line1.x);
    let dy = (line2.y - line1.y);
    let res = dy * p.x - dx * p.y + line2.x * line1.y - line2.y * line1.x;
    return Math.abs(res) / Math.sqrt(dy*dy + dx*dx);
}
function ptLineDistance ( p , line1 , line2 ) { let dx = ( line2 . x - line1 . x ) ; let dy = ( line2 . y - line1 . y ) ; let res = dy * p . x - dx * p . y + line2 . x * line1 . y - line2 . y * line1 . x ; return Math . abs ( res ) / Math . sqrt ( dy * dy + dx * dx ) ; }
Returns the distance from point p to line defined by two points (line1, line2)
Returns the distance from point p to line defined by two points ( line1 line2 )