3 ms·
I got bad news. The question was to find the distance between a point and a line SEGMENT. Luckily, since you know some math, and you understand what a dot prod
by lbrandy 18y ago
I got bad news. The question was to find the distance between a point and a line SEGMENT.
Luckily, since you know some math, and you understand what a dot product is, and how it relates to a projection, you can trivially extend your solution by checking to make sure Q is on AB, and then adjusting your answer if its not.
:)
- palish 18y agoAhh, yes. Good catch. In the algorithm, simply clamp AQ_len to be >= 0.0 and <= AB_len. (Notice that you compute AB_len as a side effect of normalizing AB.)