| pt | a | b | d | p | h1 | h | l | result |
| (0,0) | (0,0) | (0,0) | (0,0) | (0,0) | 0 | 0 | 0 | 0 |
- pt - test point - drag with the mouse or touch
- a - origin of lines
- b - end of line that we're checking
- d - line from origin to test point
- p - line from origin to end of check line
- h1 - project d onto p
- h - clamp h1 to between a and b
- l - distance from test point to line p
- result - 0, not between line p and thickness from line. >0, value between p and thickness
Notice that if you are close to the line, the value of result is between 0 and 1. Beyond the line in any direction the value will be 0. Drag in the graph to see the values change.