From 488b1ee54e2cea479b2b9f0603680ecc28eaacff Mon Sep 17 00:00:00 2001 From: Doug Hawkins Date: Thu, 26 Mar 2020 14:04:49 -0600 Subject: [PATCH] Simplify Cubic_Array() in array.scad by parameterizing 'center'. --- array.scad | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/array.scad b/array.scad index 5945c2c..a8cf672 100644 --- a/array.scad +++ b/array.scad @@ -92,20 +92,13 @@ module Cubic_and_Radial_Array_Test() // main lib modules module Cubic_Array(sx,sy,sz,nx,ny,nz,center) { - if (center==true) - translate([-(((nx+1)*sx)/2),-(((ny+1)*sy)/2),-(((nz+1)*sz)/2)]) + offset = center ? [-(((nx+1)*sx)/2),-(((ny+1)*sy)/2),-(((nz+1)*sz)/2)] : [0,0,0]; + translate(offset) for(x=[1:nx]) - for(y=[1:ny]) - for(z=[1:nz]) - translate([x*sx,y*sy,z*sz]) - children([0:$children-1],center=true); - else - translate([0,0,0]) - for(x=[1:nx]) - for(y=[1:ny]) - for(z=[1:nz]) - translate([x*sx,y*sy,z*sz]) - children(); + for(y=[1:ny]) + for(z=[1:nz]) + translate([x*sx,y*sy,z*sz]) + children([0:$children-1],center); } //