mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-09 00:06:42 +02:00
added test_bezier_smooth
This commit is contained in:
@@ -31,6 +31,7 @@ include <test_paths2sections.scad>;
|
||||
include <test_circle_path.scad>;
|
||||
include <test_bezier_curve.scad>;
|
||||
include <test_bezier_surface.scad>;
|
||||
include <test_bezier_smooth.scad>;
|
||||
|
||||
// 2D Shape
|
||||
include <test_shape_arc.scad>;
|
||||
|
44
test/test_bezier_smooth.scad
Normal file
44
test/test_bezier_smooth.scad
Normal file
@@ -0,0 +1,44 @@
|
||||
include <unittest.scad>;
|
||||
include <bezier_curve.scad>;
|
||||
include <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], [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], [-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], [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], [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], [0, 50]];
|
||||
|
||||
actual = bezier_smooth(path_pts, round_d, closed = true);
|
||||
|
||||
assertEqualPoints(expected, actual);
|
||||
}
|
||||
|
||||
test_bezier_smooth_no_closed();
|
||||
test_bezier_smooth_closed();
|
Reference in New Issue
Block a user