From 154436382c7626dec9df942e8a82006ccadfe04d Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Mon, 29 Nov 2021 09:49:45 +0800 Subject: [PATCH] add lemniscate_curve --- src/lemniscate_curve.scad | 45 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/lemniscate_curve.scad diff --git a/src/lemniscate_curve.scad b/src/lemniscate_curve.scad new file mode 100644 index 00000000..cd072499 --- /dev/null +++ b/src/lemniscate_curve.scad @@ -0,0 +1,45 @@ +/* +use ; +use ; +use ; + +shape_pts = [ + [3, -1.5], + [3, 1.5], + [2, 1.5], + [2, 0.5], + [-2, 0.5], + [-2, 1.5], + [-3, 1.5], + [-3, -1.5], + [-2, -1.5], + [-2, -0.5], + [2, -0.5], + [2, -1.5] +]; + +path_pts = lemniscate_curve(2, 1, .75, .075) * 20; +path_extrude( + shape_pts, + concat(path_pts, [path_pts[0]]), + method = "EULER_ANGLE" +); + +path_pts2 = lemniscate_curve(2, 1, .75, .2) * 20; +translate([0, 30, 0]) + path_extrude(shape_star() * 3, + concat(path_pts2, [path_pts2[0]]), + method = "EULER_ANGLE" +); + + +*/ +function lemniscate_curve(t_step, a = 1, b = 1, c = 1) = + [ + for(t = [0:t_step:360 - t_step]) + let( + sint = sin(t), + cost = cos(t) + ) + [a * sint, b * sint * cost, c * cost] + ]; \ No newline at end of file