Change curvature calc from max to average

This commit is contained in:
Pyro Nicampt committed 2024-12-23 03:57:23 -06:00
1 parent e843ac2004
commit 67aef402e3
1 file changed
+3 -3
+3 -3
View File
@@ -62,11 +62,11 @@ export function estimateCurvature(p1, h1, h2, p2, iterationCount = 50){
for(let i=0; i<iterationCount; i++){ for(let i=0; i<iterationCount; i++){
t = i/iterationCount; t = i/iterationCount;
vel = evaluateVelocity(p1, h1, h2, p2, t); vel = evaluateVelocity(p1, h1, h2, p2, t);
curvature = Math.max(curvature, curvature +=
Vector.length(Vector.cross(vel, evaluateAcceleration(p1, h1, h2, p2, t))) Vector.length(Vector.cross(vel, evaluateAcceleration(p1, h1, h2, p2, t)))
/Math.pow(Vector.length(vel),3)); /Math.pow(Vector.length(vel),3);
} }
return curvature; return curvature/iterationCount;
} }
/** Evaluate the bezier at `t`, getting position. /** Evaluate the bezier at `t`, getting position.