floatline(vec2p,vec2a,vec2b){// --- distance to segment with caps
p-=a,b-=a;floath=clamp(dot(p,b)/dot(b,b),0.,1.);// proj coord on line
returnlength(p-b*h);// dist to segment
// We might directly return smoothstep( 3./R.y, 0., dist),
// but its more efficient to factor all lines.
// We can even return dot(,) and take sqrt at the end of polyline:
// p -= b*h; return dot(p,p);
}