From 30f83865f1d2cf1352c097ea52171575e0aefd82 Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Thu, 26 Aug 2021 21:13:12 +0800 Subject: [PATCH] add tri_arc_path --- src/experimental/tri_arc_path.scad | 41 ++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/experimental/tri_arc_path.scad diff --git a/src/experimental/tri_arc_path.scad b/src/experimental/tri_arc_path.scad new file mode 100644 index 00000000..1627fd0f --- /dev/null +++ b/src/experimental/tri_arc_path.scad @@ -0,0 +1,41 @@ +use <__comm__/__frags.scad>; +use ; +use ; +use ; +use ; +use ; + +function _tri_arc_ct_clk(shape_pts) = + let( + c = tri_circumcenter(shape_pts), + v0 = shape_pts[0] - c, + v2 = shape_pts[2] - c, + r = norm(v0), + v0_a = atan2(v0[1], v0[0]), + a = angle_between(v0, v2, ccw = true), + a_step = a / __frags(r) + ) + [for(a = [0:a_step:a]) c + ptf_rotate([r * cos(a), r * sin(a)], v0_a)]; + +function tri_arc_path(shape_pts) = + tri_is_ccw(shape_pts) ? + _tri_arc_ct_clk(shape_pts) : + reverse(_tri_arc_ct_clk(reverse(shape_pts))); + +/* +use ; + +use ; +use ; + +$fn = 24; +pts = zip([rands(0, 20, 3), rands(0, 20, 3)]); + +hull_polyline2d(tri_arc_path(pts)); +#for(i = [0:len(pts) - 1]) { + translate(pts[i]) + sphere(1); + translate(pts[i]) + text(str(i), 2); +} +*/ \ No newline at end of file