From 49e13d920a935a4fbc467c5d59ec622be786ffe1 Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Sun, 14 Jul 2019 10:58:31 +0800 Subject: [PATCH] add superformula_vase --- examples/superformula_vase.scad | 72 +++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 examples/superformula_vase.scad diff --git a/examples/superformula_vase.scad b/examples/superformula_vase.scad new file mode 100644 index 00000000..bd97032c --- /dev/null +++ b/examples/superformula_vase.scad @@ -0,0 +1,72 @@ +include ; +include ; +include ; +include ; +include ; +include ; +include ; + +/* [Superformula] */ +phi_step = 0.025; +m = 8; +n = 5; +n3 = 8; + +/* [Offset] */ +d = 0.1; + +/* [Curve] */ +r1 = 1; +r2 = 2; +h1 = 5; +h2 = 8; +t_step = 0.025; +twist = 90; + +module superformula_vase(phi_step, m, n, n3, d, r1, r2, h1, h2, t_step, twist) { + + function cal_sections(shapt_pts, edge_path, twist) = + let( + sects = path_scaling_sections(shapt_pts, edge_path), + leng = len(sects), + twist_step = twist / leng + ) + [ + for(i = [0:leng - 1]) + [ + for(p = sects[i]) + rotate_p(p, twist_step * i) + ] + ]; + + superformula = shape_superformula(phi_step, m, m, n, n, n3); + + edge_path = bezier_curve(t_step, [ + [1, 0, 0], + [4, 0, 3], + [2, 0, 4], + [r1, 0, h1], + [1, 0, 6], + [r2, 0, h2], + ]); + + offseted = bijection_offset(superformula, d); + + edge_path2 = [for(p = edge_path) p + [d, 0, 0]]; + superformula2 = trim_shape(offseted, 3, len(offseted) - 1, epsilon = 0.0001); + + sections = cal_sections(superformula, edge_path, twist); + outer_sections = cal_sections(superformula2, edge_path2, twist); + + difference() { + polysections(outer_sections); + polysections(sections); + } + + linear_extrude(d) + rotate(twist - twist / len(sections)) + polygon(superformula2); +} + +superformula_vase(phi_step, m, n, n3, d, r1, r2, h1, h2, t_step, twist); + \ No newline at end of file