mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-12 09:44:16 +02:00
added test_paths2sections
This commit is contained in:
@@ -9,6 +9,9 @@ include <test_hexagons.scad>;
|
||||
include <test_rounded_cube.scad>;
|
||||
include <test_rounded_cylinder.scad>;
|
||||
|
||||
// Function
|
||||
include <test_paths2sections.scad>;
|
||||
|
||||
// 2D Shape
|
||||
include <test_shape_arc.scad>;
|
||||
include <test_shape_cyclicpolygon.scad>;
|
||||
|
60
test/test_paths2sections.scad
Normal file
60
test/test_paths2sections.scad
Normal file
@@ -0,0 +1,60 @@
|
||||
include <unittest.scad>;
|
||||
include <bezier_curve.scad>;
|
||||
include <paths2sections.scad>;
|
||||
|
||||
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();
|
Reference in New Issue
Block a user