mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-01-17 14:18:13 +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.0946668], [-8.40532, -3.99889], [-12.4989, -0.0946859], [-12.3642, -5.78176], [-8.52426, -12.4798], [-2.25652, -16.2117], [4.73389, -16.8348], [11.2186, -14.7228], [16.3807, -10.5002], [19.7496, -4.88353], [21.1345, 1.41768], [20.5616, 7.76153], [18.2155, 13.6082], [14.3889, 18.5363], [9.43865, 22.2465], [3.75054, 24.5569], [-2.2895, 25.3921], [-8.31717, 24.7692], [-14.0057, 22.7824], [-19.0769, 19.586], [-23.3069, 15.3792], [-26.5298, 10.3901], [-28.6367, 4.86291], [-29.5736, -0.954708], [-29.3372, -6.82151], [-27.969, -12.5112], [-25.5492, -17.8192], [-22.1901, -22.5673], [-18.0289, -26.6075], [-13.2208, -29.8236], [-7.93264, -32.132], [-2.33684, -33.4815], [3.39434, -33.8521], [9.09361, -33.2527], [14.6029, -31.7188], [19.7769, -29.3091], [24.4858, -26.103], [28.6176, -22.1962], [32.0795, -17.6975], [34.799, -12.7256], [36.7238, -7.40514], [37.8222, -1.86377], [38.0821, 3.77099], [37.5102, 9.37453], [36.1307, 14.8276], [33.9838, 20.0184], [31.1237, 24.8447], [27.6173, 29.2148], [23.5413, 33.0494], [18.9812, 36.2819], [14.0284, 38.8591], [8.7787, 40.7419], [3.33025, 41.9044], [-2.21838, 42.3346], [-7.76988, 42.0335], [-13.2298, 41.0143], [-18.5078, 39.302], [-23.5194, 36.9322], [-28.1866, 33.9499], [-32.4391, 30.4088], [-36.2148, 26.3697], [-39.4606, 21.8995], [-42.133, 17.0697], [-44.1978, 11.9554], [-45.6306, 6.63376], [-46.4169, 1.18325], [-46.5513, -4.31793], [-46.038, -9.79273], [-44.8896, -15.1663], [-43.1273, -20.3669], [-40.7798, -25.3268], [-37.8829, -29.9828], [-34.4786, -34.2773], [-30.6145, -38.1583], [-26.3431, -41.5805], [-21.7206, -44.5048], [-16.8064, -46.8994], [-11.6623, -48.7395], [-6.35131, -50.0073], [-0.937338, -50.6921], [4.51586, -50.7903], [9.94533, -50.3052], [15.2896, -49.2463], [20.4895, -47.6298], [25.4883, -45.4773], [30.2327, -42.8162], [34.6733, -39.6788], [35.6098, -34.1], [30.031, -33.1634], [30.031, -33.1634], [26.2913, -35.8546], [22.2946, -38.1424], [18.0832, -40.0002], [13.7023, -41.4054], [9.19983, -42.34], [4.62594, -42.7911], [0.032421, -42.7511], [-4.52778, -42.2179], [-9.00115, -41.1951], [-13.3342, -39.6922], [-17.4742, -37.7248], [-21.3698, -35.3142], [-24.9715, -32.4876], [-28.2329, -29.2781], [-31.1106, -25.7242], [-33.5655, -21.8694], [-35.5632, -17.7623], [-37.0747, -13.4555], [-38.0768, -9.0057], [-38.5528, -4.47244], [-38.493, 0.082213], [-37.8949, 4.59457], [-36.7636, 9.00019], [-35.1121, 13.2347], [-32.9613, 17.2349], [-30.34, 20.9395], [-27.2849, 24.2905], [-23.8401, 27.2337], [-20.057, 29.7203], [-15.9936, 31.7074], [-11.7138, 33.1593], [-7.28699, 34.0481], [-2.78643, 34.3548], [1.71125, 34.0699], [6.12748, 33.1939], [10.383, 31.7379], [14.3994, 29.7239], [18.1003, 27.1847], [21.4132, 24.1641], [24.2711, 20.7165], [26.6139, 16.9062], [28.3901, 12.8071], [29.558, 8.50082], [30.0879, 4.07644], [29.9625, -0.3718], [29.1787, -4.74591], [27.748, -8.94627], [25.6973, -12.8738], [23.0695, -16.4325], [19.923, -19.5318], [16.3314, -22.0891], [12.3826, -24.033], [8.17771, -25.3053], [3.82872, -25.8639], [-0.543495, -25.6851], [-4.81221, -24.7656], [-8.84815, -23.1243], [-12.5234, -20.8033], [-15.7154, -17.8686], [-18.312, -14.41], [-20.2157, -10.5399], [-21.3488, -6.3915], [-21.6583, -2.11558], [-21.1204, 2.12341], [-19.7441, 6.15281], [-17.5752, 9.79825], [-14.6974, 12.8912], [-11.2339, 15.2779], [-7.34541, 16.8284], [-3.22705, 17.4472], [0.897907, 17.0828], [4.78711, 15.7378], [8.19166, 13.4772], [10.8721, 10.4343], [12.618, 6.81346], [13.2708, 2.8876], [12.749, -1.01163], [11.0749, -4.51283], [8.39894, -7.23614], [5.01789, -8.83984], [1.37862, -9.08532], [-1.9491, -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();
|