(line1, line2, pnt)
| 13 | |
| 14 | //Returns float, the shortest distance to the (infinite) line. |
| 15 | static calcDistancePointToLine(line1, line2, pnt) { |
| 16 | const L2 = ( ((line2.x - line1.x) * (line2.x - line1.x)) + ((line2.y - line1.y) * (line2.y - line1.y)) ); |
| 17 | if(L2 == 0) return false; |
| 18 | const s = (((line1.y - pnt.y) * (line2.x - line1.x)) - ((line1.x - pnt.x) * (line2.y - line1.y))) / L2; |
| 19 | return Math.abs(s) * Math.sqrt(L2); |
| 20 | } |
| 21 | |
| 22 | //Returns bool, whether the projected point is actually inside the (finite) line segment. |
| 23 | static calcIsInsideLineSegment(line1, line2, pnt) { |
nothing calls this directly
no outgoing calls
no test coverage detected