From 749b6c054b39413a79dd5761af30954b0eff869f Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Thu, 1 Jun 2017 12:59:27 +0800 Subject: [PATCH] added test_paths2sections --- test/test_all.scad | 3 ++ test/test_paths2sections.scad | 60 +++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 test/test_paths2sections.scad diff --git a/test/test_all.scad b/test/test_all.scad index 39635094..74d1f1f7 100644 --- a/test/test_all.scad +++ b/test/test_all.scad @@ -9,6 +9,9 @@ include ; include ; include ; +// Function +include ; + // 2D Shape include ; include ; diff --git a/test/test_paths2sections.scad b/test/test_paths2sections.scad new file mode 100644 index 00000000..82855cea --- /dev/null +++ b/test/test_paths2sections.scad @@ -0,0 +1,60 @@ +include ; +include ; +include ; + +module test_paths2sections() { + module test_simple_path() { + + paths = [ + [[5, 0, 5], [15, 10, 10], [25, 20, 5]], + [[-5, 0, 5], [-15, 10, 10], [-25, 20, 5]], + [[-5, 0, -5], [-15, 10, -10], [-25, 20, -5]], + [[5, 0, -5], [15, 10, -10], [25, 20, -5]] + ]; + + expected = [ + [[5, 0, 5], [-5, 0, 5], [-5, 0, -5], [5, 0, -5]], + [[15, 10, 10], [-15, 10, 10], [-15, 10, -10], [15, 10, -10]], + [[25, 20, 5], [-25, 20, 5], [-25, 20, -5], [25, 20, -5]] + ]; + + actual = paths2sections(paths); + + for(i = [0:len(paths[0]) - 1]) { + assertEqualPoints(expected[i], actual[i]); + } + } + + module test_bezier_path() { + t_step = 0.05; + + paths = [ + bezier_curve(t_step, + [[1.25, 0, 5], [5, 20, 5], [16, 20, -2], [18, 20, 10], [30, 15, 8]] + ), + bezier_curve(t_step, + [[-1.25, 0, 5], [0, 20, 5], [16, 22, -2], [18, 20, 10], [30, 25, 8]] + ), + bezier_curve(t_step, + [[-1.25, 0, -5], [0, 20, -5], [16, 20, 1], [18, 27, -3], [20, 27, -5]] + ), + bezier_curve(t_step, + [[1.25, 0, -5], [5, 20, -5], [16, 20, 1], [18, 17.5, -3], [20, 17.5, -5]] + ) + ]; + + + sections = paths2sections(paths); + + for(i = [0:len(sections) - 1]) { + for(j = [0:len(sections[i]) - 1]) { + assertEqualPoint(paths[j][i], sections[i][j]); + } + } + } + + test_simple_path(); + test_bezier_path(); +} + +test_paths2sections(); \ No newline at end of file