mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-01-16 13:50:05 +01:00
46 lines
7.0 KiB
OpenSCAD
46 lines
7.0 KiB
OpenSCAD
use <unittest.scad>
|
|
|
|
use <shape_path_extend.scad>
|
|
use <shape_circle.scad>
|
|
use <archimedean_spiral.scad>
|
|
|
|
module test_shape_path_extend_stroke1() {
|
|
echo("==== test_shape_path_extend_stroke1 ====");
|
|
|
|
$fn = 96;
|
|
stroke1 = [[-5, 2.5], [-2.5, 0], [0, 2.5], [2.5, 0], [5, 2.5]];
|
|
path_pts1 = shape_circle(50, 60);
|
|
|
|
expected = [[44.9209, 2.3351], [47.5013, -0.0818], [49.9182, 2.4987], [52.4987, 0.0818], [54.9155, 2.6623], [54.8085, 5.9324], [54.3031, 9.5044], [53.5652, 13.0356], [52.598, 16.511], [51.4055, 19.9157], [49.9929, 23.2352], [48.3662, 26.4551], [46.5324, 29.5618], [44.4993, 32.5419], [42.2757, 35.3826], [39.8711, 38.0718], [37.2957, 40.598], [34.5606, 42.9503], [31.6775, 45.1187], [28.6588, 47.0939], [25.5173, 48.8675], [22.2666, 50.4317], [18.9205, 51.7801], [15.4935, 52.9067], [12, 53.8067], [8.4552, 54.4763], [4.8742, 54.9127], [1.2723, 55.1139], [-2.3351, 55.0791], [-5.9324, 54.8085], [-9.5044, 54.3031], [-13.0356, 53.5652], [-16.511, 52.598], [-19.9157, 51.4055], [-23.2352, 49.9929], [-26.4551, 48.3662], [-29.5618, 46.5324], [-32.5419, 44.4993], [-35.3826, 42.2757], [-38.0718, 39.8711], [-40.598, 37.2957], [-42.9503, 34.5606], [-45.1187, 31.6775], [-47.0939, 28.6588], [-48.8675, 25.5173], [-50.4317, 22.2666], [-51.7801, 18.9205], [-52.9067, 15.4935], [-53.8067, 12], [-54.4763, 8.4552], [-54.9127, 4.8742], [-55.1139, 1.2723], [-55.0791, -2.3351], [-54.8085, -5.9324], [-54.3031, -9.5044], [-53.5652, -13.0356], [-52.598, -16.511], [-51.4055, -19.9157], [-49.9929, -23.2352], [-48.3662, -26.4551], [-46.5324, -29.5618], [-44.4993, -32.5419], [-42.2757, -35.3826], [-39.8711, -38.0718], [-39.5245, -34.5533], [-36.006, -34.8998], [-35.6595, -31.3813], [-32.141, -31.7279], [-32.141, -31.7279], [-34.1472, -29.5578], [-36.0073, -27.2612], [-37.7132, -24.8478], [-39.2576, -22.3281], [-40.6338, -19.7127], [-41.8361, -17.0129], [-42.8592, -14.2403], [-43.6988, -11.4066], [-44.3513, -8.5242], [-44.8138, -5.6052], [-45.0845, -2.6623], [-45.1621, 0.2921], [-45.0463, 3.2452], [-44.7376, 6.1844], [-44.2373, 9.0972], [-43.5476, 11.971], [-42.6714, 14.7935], [-41.6125, 17.5526], [-40.3754, 20.2367], [-38.9654, 22.834], [-37.3886, 25.3336], [-35.6517, 27.7247], [-33.762, 29.997], [-31.7279, 32.141], [-29.5578, 34.1472], [-27.2612, 36.0073], [-24.8478, 37.7132], [-22.3281, 39.2576], [-19.7127, 40.6338], [-17.0129, 41.8361], [-14.2403, 42.8592], [-11.4066, 43.6988], [-8.5242, 44.3513], [-5.6052, 44.8138], [-2.6623, 45.0845], [0.2921, 45.1621], [3.2452, 45.0463], [6.1844, 44.7376], [9.0972, 44.2373], [11.971, 43.5476], [14.7935, 42.6714], [17.5526, 41.6125], [20.2367, 40.3754], [22.834, 38.9654], [25.3336, 37.3886], [27.7247, 35.6517], [29.997, 33.762], [32.141, 31.7279], [34.1472, 29.5578], [36.0073, 27.2612], [37.7132, 24.8478], [39.2576, 22.3281], [40.6338, 19.7127], [41.8361, 17.0129], [42.8592, 14.2403], [43.6988, 11.4066], [44.3513, 8.5242]];
|
|
|
|
actual = shape_path_extend(stroke1, path_pts1);
|
|
|
|
assertEqualPoints(expected, actual);
|
|
}
|
|
|
|
module test_shape_path_extend_stroke2() {
|
|
echo("==== test_shape_path_extend_stroke2 ====");
|
|
|
|
$fn = 96;
|
|
stroke2 = [[-4, 0], [0, 4], [4, 0]];
|
|
pts_angles = archimedean_spiral(
|
|
arm_distance = 17,
|
|
init_angle = 180,
|
|
point_distance = 5,
|
|
num_of_points = 85
|
|
);
|
|
|
|
expected = [[-4.50112, 0.094671], [-8.40533, -3.99888], [-12.4989, -0.094671], [-12.3642, -5.78174], [-8.52427, -12.4798], [-2.25654, -16.2117], [4.73386, -16.8348], [11.2186, -14.7228], [16.3807, -10.5002], [19.7496, -4.88358], [21.1346, 1.41763], [20.5616, 7.76149], [18.2156, 13.6082], [14.3889, 18.5362], [9.43871, 22.2465], [3.75061, 24.5569], [-2.28942, 25.3921], [-8.31709, 24.7692], [-14.0057, 22.7824], [-19.0768, 19.5861], [-23.3069, 15.3793], [-26.5297, 10.3902], [-28.6367, 4.86301], [-29.5737, -0.954608], [-29.3372, -6.82141], [-27.969, -12.5111], [-25.5493, -17.8191], [-22.1902, -22.5673], [-18.029, -26.6075], [-13.2209, -29.8235], [-7.93276, -32.132], [-2.33697, -33.4815], [3.3942, -33.8522], [9.09348, -33.2528], [14.6028, -31.7188], [19.7767, -29.3092], [24.4857, -26.1031], [28.6175, -22.1963], [32.0794, -17.6976], [34.7989, -12.7257], [36.7238, -7.4053], [37.8222, -1.86394], [38.0821, 3.77082], [37.5102, 9.37436], [36.1308, 14.8274], [33.9839, 20.0183], [31.1239, 24.8445], [27.6174, 29.2147], [23.5415, 33.0493], [18.9814, 36.2818], [14.0286, 38.8591], [8.7789, 40.7418], [3.33046, 41.9044], [-2.21817, 42.3347], [-7.76966, 42.0336], [-13.2295, 41.0144], [-18.5076, 39.3021], [-23.5192, 36.9323], [-28.1865, 33.9501], [-32.4389, 30.409], [-36.2146, 26.3699], [-39.4605, 21.8997], [-42.1329, 17.0699], [-44.1977, 11.9556], [-45.6306, 6.63401], [-46.4169, 1.18351], [-46.5514, -4.31766], [-46.038, -9.79247], [-44.8897, -15.166], [-43.1274, -20.3667], [-40.7799, -25.3265], [-37.883, -29.9826], [-34.4788, -34.2771], [-30.6148, -38.1581], [-26.3434, -41.5803], [-21.7209, -44.5047], [-16.8067, -46.8993], [-11.6626, -48.7394], [-6.35161, -50.0072], [-0.937651, -50.6921], [4.51554, -50.7904], [9.94502, -50.3052], [15.2893, -49.2464], [20.4892, -47.6299], [25.488, -45.4775], [30.2325, -42.8164], [34.673, -39.679], [35.6096, -34.1002], [30.0308, -33.1636], [30.0308, -33.1636], [26.291, -35.8547], [22.2943, -38.1426], [18.0829, -40.0004], [13.702, -41.4055], [9.19957, -42.3401], [4.62568, -42.7911], [0.032157, -42.7511], [-4.52804, -42.2178], [-9.0014, -41.195], [-13.3345, -39.6922], [-17.4745, -37.7247], [-21.37, -35.3141], [-24.9717, -32.4875], [-28.233, -29.278], [-31.1107, -25.724], [-33.5656, -21.8692], [-35.5633, -17.7621], [-37.0748, -13.4553], [-38.0768, -9.00548], [-38.5528, -4.47222], [-38.493, 0.082429], [-37.8949, 4.59478], [-36.7636, 9.00039], [-35.112, 13.2349], [-32.9612, 17.2351], [-30.3399, 20.9397], [-27.2847, 24.2906], [-23.8399, 27.2338], [-20.0568, 29.7204], [-15.9934, 31.7075], [-11.7137, 33.1593], [-7.28682, 34.0481], [-2.78626, 34.3549], [1.71143, 34.0699], [6.12765, 33.1939], [10.3832, 31.7379], [14.3995, 29.7238], [18.1004, 27.1846], [21.4133, 24.164], [24.2712, 20.7164], [26.614, 16.9061], [28.3901, 12.8069], [29.5581, 8.50069], [30.0879, 4.0763], [29.9625, -0.371934], [29.1787, -4.74604], [27.7479, -8.94639], [25.6973, -12.874], [23.0695, -16.4326], [19.9229, -19.5319], [16.3313, -22.0892], [12.3825, -24.0331], [8.1776, -25.3054], [3.82862, -25.864], [-0.543596, -25.6851], [-4.8123, -24.7656], [-8.84824, -23.1243], [-12.5234, -20.8032], [-15.7155, -17.8686], [-18.312, -14.41], [-20.2157, -10.5399], [-21.3488, -6.39142], [-21.6583, -2.11551], [-21.1204, 2.12348], [-19.7441, 6.15287], [-17.5751, 9.7983], [-14.6974, 12.8913], [-11.2339, 15.2779], [-7.34536, 16.8285], [-3.227, 17.4472], [0.897954, 17.0828], [4.78715, 15.7378], [8.19169, 13.4772], [10.8721, 10.4343], [12.618, 6.81343], [13.2708, 2.88757], [12.749, -1.01165], [11.0749, -4.51285], [8.39893, -7.23616], [5.01787, -8.83985], [1.37861, -9.08532], [-1.94911, -7.92267]];
|
|
|
|
actual = shape_path_extend(
|
|
stroke2,
|
|
[for(pa = pts_angles) pa[0]]
|
|
);
|
|
|
|
assertEqualPoints(expected, actual);
|
|
}
|
|
|
|
|
|
test_shape_path_extend_stroke1();
|
|
test_shape_path_extend_stroke2();
|