base_length = 230; base_width = 110; base_height = 10; floor_depth = 2; wall_width = 2; glass_down = 5; glass_recess = 2; leg_offset = 2; leg = 5; module pit() { translate([0,0,floor_depth]) cube([base_length, base_width, base_height],true); } function base_offset() = (leg+leg_offset+glass_recess+wall_width)*2; module base_platform() { cube([ base_length+base_offset(), base_width+base_offset(), base_height+floor_depth], true); } module base() { difference(){ base_platform(); translate([0,0,(base_height+floor_depth)/2-glass_down/2]) cube([ base_length+(wall_width+glass_recess)*2, base_width+(wall_width+glass_recess)*2, glass_down],true); } cube([base_length+(wall_width*2), base_width+(wall_width*2), base_height+floor_depth],true); } module carve_cave() { difference() { base(); pit(); } } module triangle_braces() { translate([base_length/2+leg_offset+glass_recess+wall_width, 0, -base_height/2 -floor_depth/2]) rotate([90,0,0]) linear_extrude(height = base_width+(leg+leg_offset+glass_recess+wall_width)*2, center = true) polygon(points=[[leg,0],[leg,base_height + floor_depth],[0,base_height + floor_depth]]); translate([-(base_length/2+leg_offset+glass_recess+wall_width)-leg, 0, -base_height/2 -floor_depth/2]) rotate([90,0,0]) linear_extrude(height = base_width+(leg+leg_offset+glass_recess+wall_width)*2, center = true) polygon(points=[[0,0],[leg,base_height + floor_depth],[0,base_height + floor_depth]]); translate([0, -(base_width/2+leg+leg_offset+glass_recess+wall_width), -base_height/2 -floor_depth/2]) rotate([90,0,90]) linear_extrude(height = base_length+(leg+leg_offset+glass_recess+wall_width)*2, center = true) polygon(points=[[0,0],[leg,base_height + floor_depth],[0,base_height + floor_depth]]); translate([0, (base_width/2+leg_offset+glass_recess+wall_width), -base_height/2 -floor_depth/2]) rotate([90,0,90]) linear_extrude(height = base_length+(leg+leg_offset+glass_recess+wall_width)*2, center = true) polygon(points=[[leg,0],[leg,base_height + floor_depth],[0,base_height + floor_depth]]); } module curved_braces() { translate([base_length/2+leg_offset+glass_recess+wall_width, 0, -base_height/2 -floor_depth/2]) rotate([90,0,0]) linear_extrude(height = base_width+(leg+leg_offset+glass_recess+wall_width)*2, center = true) polygon(points=curvedRightTriangle([leg,base_height + floor_depth],[leg,0],[0,base_height + floor_depth], 10, 0.2)[1]); translate([-(base_length/2+leg_offset+glass_recess+wall_width)-leg, 0, -base_height/2 -floor_depth/2]) rotate([90,0,0]) linear_extrude(height = base_width+(leg+leg_offset+glass_recess+wall_width)*2, center = true) polygon(points=curvedRightTriangle([0,base_height + floor_depth],[0,0],[leg,base_height + floor_depth], 10, 0.2)[1]); translate([0, -(base_width/2+leg+leg_offset+glass_recess+wall_width), -base_height/2 -floor_depth/2]) rotate([90,0,90]) linear_extrude(height = base_length+(leg+leg_offset+glass_recess+wall_width)*2, center = true) polygon(points=curvedRightTriangle([0,base_height + floor_depth],[leg,base_height + floor_depth],[0,0], 10, 0.2)[1]); translate([0, (base_width/2+leg_offset+glass_recess+wall_width), -base_height/2 -floor_depth/2]) rotate([90,0,90]) linear_extrude(height = base_length+(leg+leg_offset+glass_recess+wall_width)*2, center = true) polygon(points=curvedRightTriangle([leg,base_height + floor_depth],[leg,0],[0,base_height + floor_depth], 10, 0.2)[1]); } difference() { carve_cave(); //triangle_braces(); curved_braces(); } // --- Vector helpers --- function v_add(a, b) = [a[0] + b[0], a[1] + b[1]]; function v_sub(a, b) = [a[0] - b[0], a[1] - b[1]]; function v_mul(v, s) = [v[0] * s, v[1] * s]; // Linear interpolation function lerp(a, b, t) = [ a[0] + (b[0] - a[0]) * t, a[1] + (b[1] - a[1]) * t ]; // Single curved point on hypotenuse function curved_point(A, O, H, t, scale) = let( P = lerp(O, H, t), curveFactor = -4 * t * (1 - t), toA = v_sub(A, P), offset = v_mul(toA, scale * curveFactor) ) v_add(P, offset); // Main function function curvedRightTriangle(A, O, H, count=20, scale=0.3) = let( hypotenuse = concat( [O], [ for (i = [1 : count-1]) let(t = i / count) curved_point(A, O, H, t, scale) ], [H] ), triangle = concat([A, O], hypotenuse, [A]) ) [hypotenuse, triangle];