From f64e16298db5ed7ca6aa9594a72cbb5a907288b3 Mon Sep 17 00:00:00 2001 From: Revar Desmera Date: Sun, 25 Nov 2018 15:22:58 -0800 Subject: [PATCH] Changed lerp() formula to be less susceptible to FP rounding errors. --- math.scad | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/math.scad b/math.scad index 3724a01..24a27f8 100644 --- a/math.scad +++ b/math.scad @@ -52,7 +52,7 @@ function segs(r) = $fn>0?($fn>3?$fn:3):(ceil(max(min(360.0/$fa,abs(r)*2*PI/$fs), // Interpolate between two values or vectors. 0.0 <= u <= 1.0 -function lerp(a,b,u) = (b-a)*u + a; +function lerp(a,b,u) = (1-u)*a + u*b; // Calculate hypotenuse length of 2D triangle.