// Button shape based on superelliptic balls and cylinders // // The button shape is a cylindroidical "stem", topped by // hemispheroidical "caps". The whole thing is centered on the origin, // with the front capped end towards +Y. The whole thing fits inside the box // // [-HX .. +HX] x [-HY .. +HY] x [-HZ .. +HZ] // // where HX = button_shape_HX, HY = button_shape_HY // and HZ = button_shape_HZ // // Assumes defined: // // button_cyl = the "stem" shape, // an infinite cylinder to use as stem, centered on the Y axis, // with max |X| = max |Z| = 1 and convex cross-section. // // button_ball = the "cap" shape, // a bounded blob with same XZ section as button_cyl and max |Y| = 1 // // button_shape_HX // button_shape_HY // button_shape_HZ // // button_shape_cap_HY = Y extent of cap ( <= button_shape_HY ) // // Defines // // button_shape = the thing // #declare button_shape_stem_HY = button_shape_HY - button_shape_cap_HY #declare button_shape = merge{ object{ button_ball scale < 1, button_shape_cap_HY, 1 > translate < 0, +button_shape_stem_HY, 0 > } object{ button_ball scale < 1, button_shape_cap_HY, 1 > translate < 0, -button_shape_stem_HY, 0 > } intersection{ object{ button_cyl } plane{ < 0, 1, 0 >, button_shape_stem_HY } plane{ < 0, -1, 0 >, button_shape_stem_HY } } bounded_by{ box{ 1.001 * < -1,-button_shape_HY,-1 >, 1.001 * < +1,+button_shape_HY,+1 > } } scale < button_shape_HX, 1, button_shape_HZ > }