From 9401aeb5105874f9ba03dcc110f5ca30b8ab73fb Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Thu, 21 Apr 2022 08:25:32 +0800 Subject: [PATCH] refactor: vt operation --- src/path_scaling_sections.scad | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/src/path_scaling_sections.scad b/src/path_scaling_sections.scad index dc3bf717..13364610 100644 --- a/src/path_scaling_sections.scad +++ b/src/path_scaling_sections.scad @@ -8,25 +8,13 @@ * **/ -use ; -use ; - function path_scaling_sections(shape_pts, edge_path) = - let( - start_point = edge_path[0], - base_leng = norm(start_point), - scaling_matrice = [ - for(p = edge_path) - let(s = norm([p.x, p.y, 0]) / base_leng) - m_scaling([s, s, 1]) - ], - leng_edge_path = len(edge_path) - ) - reverse([ - for(i = 0; i < leng_edge_path; i = i + 1) + let(base_leng = norm(edge_path[0])) + [ + for(i = [len(edge_path) - 1:-1:0]) + let(edge_p = edge_path[i], s = norm([edge_p.x, edge_p.y] / base_leng)) [ - for(p = shape_pts) - let(scaled_p = scaling_matrice[i] * [p.x, p.y, edge_path[i].z, 1]) - [scaled_p.x, scaled_p.y, scaled_p.z] + for(p = shape_pts * s) + [p.x, p.y, edge_p.z] ] - ]); \ No newline at end of file + ]; \ No newline at end of file