[OpenSCAD] bend a pipe/tube

biskero biskero at gmail.com
Wed Apr 29 10:50:34 EDT 2015


Ciao,


here is code I found to create a ellipse tube based on torus, but it's
pretty slow when I compile it into my design, OpenSCAD starts thinking!!! :)
Any suggestion how to speed this code?


module torusSlice(r1, r2, start_angle, end_angle, convexity=10, r3=0,
$fn=64) {
	rx = r1 + r2;
    ry = rx;
    trx = rx* sqrt(2) + 1;
    try = ry* sqrt(2) + 1;
    a0 = (4 * start_angle + 0 * end_angle) / 4;
    a1 = (3 * start_angle + 1 * end_angle) / 4;
    a2 = (2 * start_angle + 2 * end_angle) / 4;
    a3 = (1 * start_angle + 3 * end_angle) / 4;
    a4 = (0 * start_angle + 4 * end_angle) / 4;
    if(end_angle > start_angle)
        intersection() {
			rotate_extrude(convexity=convexity) translate([50,0,0]) difference() {
				//circle(r2, $fn=$fn/4);
				//circle(r3, $fn=$fn/4);
                ellipse(r2,1.44*r2);
                ellipse(r3,1.44*r3);
			}

			translate([0,0,-r2-1])
			linear_extrude(height=2*r2+2)
        		polygon([
		            [0,0],
		            [trx * cos(a0), try * sin(a0)],
		            [trx * cos(a1), try * sin(a1)],
		            [trx * cos(a2), try * sin(a2)],
		            [trx * cos(a3), try * sin(a3)],
		            [trx * cos(a4), try * sin(a4)],
		            [0,0]
		       ]);
    }
}
//ellipse(50,75);

module ellipse(width, height) {
  scale([1, height/width, 1]) circle(r=width/2);
}

torusSlice(r1=10, r2=72, r3=67, start_angle=0, end_angle=25, $fn=60);


Thanks
Alessandro



--
View this message in context: http://forum.openscad.org/bend-a-pipe-tube-tp12503p12513.html
Sent from the OpenSCAD mailing list archive at Nabble.com.




More information about the Discuss mailing list