Simplify Cubic_Array() in array.scad by parameterizing 'center'.
This commit is contained in:
parent
ea5f62b3f5
commit
488b1ee54e
13
array.scad
13
array.scad
|
@ -92,20 +92,13 @@ module Cubic_and_Radial_Array_Test()
|
||||||
|
|
||||||
// main lib modules
|
// main lib modules
|
||||||
module Cubic_Array(sx,sy,sz,nx,ny,nz,center) {
|
module Cubic_Array(sx,sy,sz,nx,ny,nz,center) {
|
||||||
if (center==true)
|
offset = center ? [-(((nx+1)*sx)/2),-(((ny+1)*sy)/2),-(((nz+1)*sz)/2)] : [0,0,0];
|
||||||
translate([-(((nx+1)*sx)/2),-(((ny+1)*sy)/2),-(((nz+1)*sz)/2)])
|
translate(offset)
|
||||||
for(x=[1:nx])
|
for(x=[1:nx])
|
||||||
for(y=[1:ny])
|
for(y=[1:ny])
|
||||||
for(z=[1:nz])
|
for(z=[1:nz])
|
||||||
translate([x*sx,y*sy,z*sz])
|
translate([x*sx,y*sy,z*sz])
|
||||||
children([0:$children-1],center=true);
|
children([0:$children-1],center);
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in a new issue