(line1, line2, pnt)
| 21 | |
| 22 | //Returns bool, whether the projected point is actually inside the (finite) line segment. |
| 23 | static calcIsInsideLineSegment(line1, line2, pnt) { |
| 24 | const L2 = ( ((line2.x - line1.x) * (line2.x - line1.x)) + ((line2.y - line1.y) * (line2.y - line1.y)) ); |
| 25 | if(L2 == 0) return false; |
| 26 | const r = ( ((pnt.x - line1.x) * (line2.x - line1.x)) + ((pnt.y - line1.y) * (line2.y - line1.y)) ) / L2; |
| 27 | |
| 28 | return (0 <= r) && (r <= 1); |
| 29 | } |
| 30 | |
| 31 | //The most useful function. Returns bool true, if the mouse point is actually inside the (finite) line, given a line thickness from the theoretical line away. It also assumes that the line end points are circular, not square. |
| 32 | static calcIsInsideThickLineSegment(line1, line2, pnt, lineThickness) { |
nothing calls this directly
no outgoing calls
no test coverage detected