mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-01-16 13:50:05 +01:00
59 lines
2.2 KiB
OpenSCAD
59 lines
2.2 KiB
OpenSCAD
use <unittest.scad>
|
|
use <bezier_smooth.scad>
|
|
|
|
module test_bezier_smooth_no_closed() {
|
|
echo("==== test_bezier_smooth_no_closed ====");
|
|
|
|
round_d = 15;
|
|
|
|
path_pts = [
|
|
[0, 0, 0],
|
|
[40, 60, 10],
|
|
[-50, 90, 30],
|
|
[-10, -10, 50]
|
|
];
|
|
|
|
expected = [[0, 0, 0], [31.7584, 47.6375, 7.9396], [33.185, 50.0328, 8.362], [34.1684, 52.2737, 8.8051], [34.7084, 54.3601, 9.2689], [34.8051, 56.2921, 9.7533], [34.4585, 58.0697, 10.2585], [33.6686, 59.6929, 10.7843], [32.4354, 61.1617, 11.3308], [30.7589, 62.476, 11.8979], [28.639, 63.6359, 12.4857], [26.0758, 64.6414, 13.0943], [-36.0758, 85.3586, 26.9057], [-38.6666, 86.1035, 27.521], [-40.8694, 86.4818, 28.1292], [-42.6842, 86.4933, 28.7303], [-44.1109, 86.1382, 29.3242], [-45.1496, 85.4164, 29.9111], [-45.8003, 84.3279, 30.4908], [-46.063, 82.8727, 31.0634], [-45.9376, 81.0508, 31.6289], [-45.4242, 78.8622, 32.1873], [-44.5228, 76.3069, 32.7386], [-10, -10, 50]];
|
|
|
|
actual = bezier_smooth(path_pts, round_d);
|
|
|
|
assertEqualPoints(expected, actual);
|
|
|
|
}
|
|
|
|
module test_bezier_smooth_closed() {
|
|
echo("==== test_bezier_smooth_closed ====");
|
|
|
|
round_d = 10;
|
|
|
|
path_pts = [
|
|
[0, 0],
|
|
[40, 0],
|
|
[0, 60]
|
|
];
|
|
|
|
expected = [[0, 10], [0.1, 8.1], [0.4, 6.4], [0.9, 4.9], [1.6, 3.6], [2.5, 2.5], [3.6, 1.6], [4.9, 0.9], [6.4, 0.4], [8.1, 0.1], [10, 0], [30, 0], [31.8445, 0.0832], [33.3781, 0.3328], [34.6008, 0.7488], [35.5125, 1.3313], [36.1132, 2.0801], [36.4031, 2.9954], [36.382, 4.077], [36.0499, 5.3251], [35.4069, 6.7396], [34.453, 8.3205], [5.547, 51.6795], [4.4931, 53.1604], [3.5501, 54.2749], [2.718, 55.023], [1.9969, 55.4046], [1.3868, 55.4199], [0.8875, 55.0687], [0.4992, 54.3512], [0.2219, 53.2672], [0.0555, 51.8168], [0, 50]];
|
|
|
|
actual = bezier_smooth(path_pts, round_d, closed = true);
|
|
|
|
assertEqualPoints(expected, actual);
|
|
}
|
|
|
|
module test_bezier_smooth_angle_threshold() {
|
|
echo("==== test_bezier_smooth_angle_threshold ====");
|
|
|
|
round_d = 15;
|
|
|
|
path_pts = [
|
|
[0, 0, 0],
|
|
[0, 40, 0],
|
|
[0, 60, 0],
|
|
[0, 70, 1]
|
|
];
|
|
|
|
assert(path_pts == bezier_smooth(path_pts, round_d, angle_threshold = 15));
|
|
}
|
|
|
|
test_bezier_smooth_no_closed();
|
|
test_bezier_smooth_closed();
|
|
test_bezier_smooth_angle_threshold(); |