forked from JustinSDK/dotSCAD
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_rails2sections.scad
64 lines (50 loc) · 1.84 KB
/
test_rails2sections.scad
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
use <unittest.scad>
use <bezier_curve.scad>
use <rails2sections.scad>
module test_rails2sections() {
module test_simple_path() {
echo("==== test_rails2sections_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 = rails2sections(paths);
for(i = [0:len(paths[0]) - 1]) {
assertEqualPoints(expected[i], actual[i]);
}
}
module test_bezier_path() {
echo("==== test_rails2sections_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 = rails2sections(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_rails2sections();