Cleaned up and documented modules, so they all work as I think they should. Also made modules work on all childen, rather than only the first. Check spin() particulary, as I changed it the most.

This commit is contained in:
Doug Hawkins 2020-03-25 14:27:48 -06:00
parent 87d5815003
commit 87cf713d25

View file

@ -9,20 +9,22 @@ include <units.scad>
use <utilities.scad> use <utilities.scad>
// TODO check that the axis parameter works as intended // Copy everything $no of times around an $axis, spread over $angle
// Duplicate everything $no of times around an $axis, for $angle/360 rounds // If $strict==true or $angle==360, then spacing will leave an empty at $angle,
module spin(no, angle=360, axis=Z){ // otherwise, $no will be distributed so first is at 0deg, last copy at $angle degrees
for (i = [1:no]){ // NOTE: $axis works (rotates around that axis), but pass parameter as lower case string
rotate(normalized_axis(axis)*angle*no/i) // eg: "x", "y", or "z". Alternatively, use units.scad vector definitions: X, Y, Z
union() children([0 : $children-1]); module spin(no, angle=360, axis=Z, strict=false){
} divisor = (strict || angle==360) ? no : no-1;
for (i = [0:no-1])
rotate(normalized_axis(axis)*angle*i/divisor)
children();
} }
//Doesn't work currently // Make a copy of children by rotating around $axis by 180 degrees
module duplicate(axis=Z) spin(no=2, axis=axis) children(0); module duplicate(axis=Z) spin(no=2, axis=axis) children();
module linear_multiply(no, separation, axis=Z){ // Make $no copies along the $axis, separated by $separation
for (i = [0:no-1]){ module linear_multiply(no, separation, axis=Z)
translate(i*separation*axis) children(0); for (i = [0:no-1])
} translate(i*separation*normalized_axis(axis)) children();
}