// Last edited on 2020-04-05 21:49:45 by jstolfi #macro curved_tube( orad, th, brad, ang0, ang1, eps ) // A piece of tube bent into a circle. // {orad} Outer radius of tube. // {th} Thickness of walls. // {brad} Bending radius of tube axis. // {ang0} Start angle. // {ang1} End angle. // {eps} Fudge radial displacement of walls. // The tube axis is part of a circle of radius {brad} // on the X-Z plane cenetered at the origin. The walls are // displaced inwards by {eps}. The tube extends // from angle {ang0} to angle {ang1}, // in degrees, clockwise from the X axis as seen from the +Y axis. #local obj_full = difference{ torus{ brad, orad - eps } torus{ brad, orad - th + eps } } #if (ang1 - ang0 >= 360) #local obj = object{ obj_full } #else #local cut_box_0 = // Box with bottom face on Z=0 plane. box{ < - brad - orad - eps, - orad - eps, 0 >, < + brad + orad + eps, + orad + eps, + brad + orad + eps > } #local cut_box_1 = // Box with top face on Z=0 plane. object{ cut_box_0 scale < +1, +1, -1 > } #if (ang1 - ang0 < 180) #local obj = difference{ object{ obj_full } object{ cut_box_0 rotate ang0*y } object{ cut_box_1 rotate ang1*y } } #else #local obj = difference{ object{ obj_full } intersection{ object{ cut_box_0 rotate ang0*y } object{ cut_box_1 rotate ang1*y } } } #end #end obj #end