Does anyone have a good reference/suggestions for how to find the point on lineseg ab closest to some query point p, for non-euclidian distance metrics? (Specifically I'd like to know L1 norm and max norm).
(Let me know if this is trivial, I just can't find anything about distance-to-segment queries that isn't L2-norm. tbh I don't super-understand the concept of distance metrics well enough to intuit anything.)
For reference, here's the normal Euclidian-distance aka L2-norm version of what I'm after (a closest-point-on-lineseg query), from: https://iquilezles.org/www/articles/distfunctions2d/distfunctions2d.htm )
vec2 cpSegment( in vec2 p, in vec2 a, in vec2 b )
{
vec2 pa = p-a, ba = b-a;
float h = clamp( dot(pa,ba)/dot(ba,ba), 0.0, 1.0 );
return (a + ba*h);
}
I've been having a really hard time finding anything about this online… please let me know what terms I should be googling! ?