Add files

This commit is contained in:
2023-03-14 20:24:33 +00:00
parent ed0da4bf1d
commit b7d7bc2346
3 changed files with 32 additions and 0 deletions
+11
View File
@@ -0,0 +1,11 @@
float closestPointOnLineParam (vec2 a, vec2 b, vec2 p) {
return dot(p - a,b-a) / dot(b-a,b-a);
}
vec2 closestPointOnSeg (vec2 a,vec2 b, vec2 p) {
float x = closestPointOnLineParam(a,b,p);
if (x < 0) {
return a;
} else{ if (x > 1) { return b; }
{ return a + (x * (b- a));}
}
}