From d7320b7c0ad138c639e64b18e5047ccb6786f0c0 Mon Sep 17 00:00:00 2001 From: Revar Desmera Date: Sun, 31 Mar 2019 00:03:02 -0700 Subject: [PATCH] More select and posmod optimizations. --- math.scad | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/math.scad b/math.scad index 8da658b..28f365a 100644 --- a/math.scad +++ b/math.scad @@ -96,7 +96,7 @@ function constrain(v, minval, maxval) = min(maxval, max(minval, v)); // Arguments: // x = The value to constrain. // m = Modulo value. -function posmod(x,m) = (x % m + m) % m; +function posmod(x,m) = (x%m) + (x<0)? m : 0; // Function: modrange() @@ -119,7 +119,7 @@ function modrange(x, y, m, step=1) = a = posmod(x, m), b = posmod(y, m), c = step>0? (a>b? b+m : b) : (a