3D crap

2015-04-24 23.09.21cI got a 3D printer (a PrintrBot Simple Metal model 1403), and it’s been great.  I don’t have time to write much, so I’ll share highlights:

  • I’m on Thingiverse here. I’ve already put up a bunch of crap, including a customizable omni wheel design.
  • I’ve been learning OpenSCAD, a free tool that lets you write code to generate 3D solids.
  • There’s no arc function in OpenSCAD, and the solutions I found online were inefficient or only worked for certain inputs, so I wrote a new one.  See below:
module arc(r,a1,a2,ir=0) {
    // normalize to 0..360 (even for negatives)
    a1n = (a1 % 360 + 360) % 360; 
    a2n = (a2 % 360 + 360) % 360;
    difference() {
        circle(r);
        if (ir != 0) circle(ir); // if inner radius given, subtract it away
            
        // get the a1 to interpolate to, adding a revolution if going the long way
        a1next = a2n>a1n ? a1n + 360 : a1n; 
        
        polygon([
            [0,0],
            [cos(1.00*a2n + 0.00*a1next)*2*r,sin(1.00*a2n + 0.00*a1next)*2*r],
            [cos(0.66*a2n + 0.33*a1next)*2*r,sin(0.66*a2n + 0.33*a1next)*2*r],
            [cos(0.33*a2n + 0.66*a1next)*2*r,sin(0.33*a2n + 0.66*a1next)*2*r],
            [cos(0.00*a2n + 1.00*a1next)*2*r,sin(0.00*a2n + 1.00*a1next)*2*r],
        ]);
    }
}

// test array
for (a = [-360:60:360], b = [-360:60:360]) {
    translate([a,b,0])  linear_extrude(height=10) arc(25,a,b);
}

2015-04-25 15_41_57-arc.scad_ - OpenSCAD

Leave a Reply

Your email address will not be published. Required fields are marked *

*