1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-01-17 06:08:31 +01:00
dotSCAD/test/test_paths2sections.scad

60 lines
1.7 KiB
OpenSCAD
Raw Normal View History

2017-06-01 12:59:27 +08:00
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();