mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-01-16 13:50:05 +01:00
37 lines
13 KiB
OpenSCAD
37 lines
13 KiB
OpenSCAD
use <unittest.scad>
|
|
use <cross_sections.scad>
|
|
use <archimedean_spiral.scad>
|
|
|
|
module test_cross_sections() {
|
|
echo("==== test_cross_sections ====");
|
|
|
|
shape_pts = [
|
|
[-2, -10],
|
|
[-2, 10],
|
|
[2, 10],
|
|
[2, -10]
|
|
];
|
|
|
|
pts_angles = archimedean_spiral(
|
|
arm_distance = 20,
|
|
init_angle = 180,
|
|
point_distance = 5,
|
|
num_of_points = 100
|
|
);
|
|
|
|
pts = [for(pt_angle = pts_angles) pt_angle[0]];
|
|
angles = [
|
|
for(i = [0:len(pts_angles) - 1]) [90, 0, pts_angles[i][1]]
|
|
];
|
|
|
|
expected = [[[-8, -1.19053e-14, -10], [-8, -1.19053e-14, 10], [-12, -1.78579e-14, 10], [-12, -1.78579e-14, -10]], [[-8.69941, -4.81324, -9.96698], [-8.14922, -4.50883, 9.84122], [-11.6157, -6.42675, 9.96698], [-12.1658, -6.73116, -9.84122]], [[-6.87801, -9.40725, -9.92296], [-6.14295, -8.40189, 9.67387], [-8.4562, -11.5658, 9.92296], [-9.19126, -12.5712, -9.67387]], [[-3.19174, -12.82, -9.86815], [-2.74497, -11.0255, 9.4983], [-3.68072, -14.784, 9.86815], [-4.12749, -16.5785, -9.4983]], [[1.5997, -14.5687, -9.80282], [1.3334, -12.1435, 9.31486], [1.75073, -15.9442, 9.80282], [2.01703, -18.3694, -9.31486]], [[6.77114, -14.5107, -9.72719], [5.49564, -11.7773, 9.12391], [7.08991, -15.1939, 9.72719], [8.36541, -17.9273, -9.12391]], [[11.6998, -12.74, -9.64155], [9.27922, -10.1042, 8.92583], [11.791, -12.8393, 9.64155], [14.2115, -15.4751, -8.92583]], [[15.8948, -9.50601, -9.54615], [12.354, -7.38836, 8.72099], [15.4894, -9.26355, 9.54615], [19.0303, -11.3812, -8.72099]], [[19.0056, -5.15108, -9.44129], [14.5101, -3.93267, 8.50976], [17.9753, -4.87184, 9.44129], [22.4708, -6.09025, -8.50976]], [[20.8154, -0.0610109, -9.32725], [15.6418, -0.0458468, 8.29253], [19.1657, -0.0561756, 9.32725], [24.3394, -0.0713397, -8.29253]], [[21.2291, 5.3719, -9.20434], [15.7291, 3.98016, 8.06968], [19.0783, 4.82767, 9.20434], [24.5783, 6.21941, -8.06968]], [[20.2549, 10.7761, -9.07287], [14.8198, 7.88454, 7.8416], [17.8064, 9.47344, 9.07287], [23.2414, 12.365, -7.8416]], [[17.9859, 15.8199, -8.93315], [13.0134, 11.4462, 7.60868], [15.4975, 13.6312, 8.93315], [20.4701, 18.0049, -7.60868]], [[14.5804, 20.2234, -8.78551], [10.4452, 14.4878, 7.37132], [12.335, 17.1089, 8.78551], [16.4702, 22.8446, -7.37132]], [[10.2434, 23.7661, -8.63027], [7.27405, 16.8768, 7.1299], [8.52166, 19.7715, 8.63027], [11.491, 26.6607, -7.1299]], [[5.2093, 26.2883, -8.46779], [3.67081, 18.5244, 6.88482], [4.26766, 21.5364, 8.46779], [5.80616, 29.3002, -6.88482]], [[-0.272594, 27.6913, -8.29839], [-0.190798, 19.3821, 6.63649], [-0.220201, 22.369, 8.29839], [-0.301996, 30.6781, -6.63649]], [[-5.95165, 27.9333, -8.12244], [-4.14162, 19.4382, 6.38528], [-4.74627, 22.2761, 8.12244], [-6.5563, 30.7712, -6.38528]], [[-11.5864, 27.0247, -7.94028], [-8.02291, 18.713, 6.13159], [-9.1319, 21.2997, 7.94028], [-12.6954, 29.6114, -6.13159]], [[-16.9535, 25.0212, -7.75228], [-11.6907, 17.254, 5.87583], [-13.2196, 19.5104, 7.75228], [-18.4824, 27.2777, -5.87583]], [[-21.8539, 22.0169, -7.55879], [-15.019, 15.131, 5.61836], [-16.8756, 17.0014, 7.55879], [-23.7105, 23.8873, -5.61836]], [[-26.1179, 18.1366, -7.36018], [-17.9016, 12.4311, 5.35959], [-19.9912, 13.8821, 7.36018], [-28.2074, 19.5876, -5.35959]], [[-29.6081, 13.5284, -7.15682], [-20.2537, 9.25425, 5.0999], [-22.4833, 10.273, 7.15682], [-31.8377, 14.5472, -5.0999]], [[-32.2209, 8.35656, -6.94907], [-22.0116, 5.70875, 4.83966], [-24.2938, 6.30066, 6.94907], [-34.5031, 8.94846, -4.83966]], [[-33.8866, 2.79425, -6.73732], [-23.1328, 1.9075, 4.57925], [-25.3884, 2.0935, 6.73732], [-36.1423, 2.98025, -4.57925]], [[-34.5686, -2.98235, -6.52192], [-23.595, -2.03562, 4.31905], [-25.7552, -2.22199, 6.52192], [-36.7288, -3.16872, -4.31905]], [[-34.2616, -8.79979, -6.30327], [-23.395, -6.00882, 4.05942], [-25.4024, -6.5244, 6.30327], [-36.2689, -9.31537, -4.05942]], [[-32.9889, -14.4921, -6.08172], [-22.5471, -9.905, 3.80073], [-24.3567, -10.7, 6.08172], [-34.7985, -15.2871, -3.80073]], [[-30.7998, -19.9049, -5.85765], [-21.0811, -13.6241, 3.54332], [-22.6603, -14.6446, 5.85765], [-32.379, -20.9255, -3.54332]], [[-27.7659, -24.8988, -5.63143], [-19.0408, -17.0747, 3.28755], [-20.3688, -18.2656, 5.63143], [-29.0939, -26.0897, -3.28755]], [[-23.9772, -29.3516, -5.40343], [-16.4815, -20.1757, 3.03376], [-17.549, -21.4825, 5.40343], [-25.0448, -30.6584, -3.03376]], [[-19.5392, -33.1604, -5.17403], [-13.4682, -22.8573, 2.78228], [-14.276, -24.2282, 5.17403], [-20.347, -34.5314, -2.78228]], [[-14.5682, -36.2427, -4.94357], [-10.0738, -25.0615, 2.53344], [-10.6315, -26.4491, 4.94357], [-15.1259, -37.6302, -2.53344]], [[-9.18832, -38.5369, -4.71244], [-6.37634, -26.7431, 2.28756], [-6.70104, -28.105, 4.71244], [-9.51302, -39.8987, -2.28756]], [[-3.52789, -40.0022, -4.48097], [-2.45785, -27.8692, 2.04496], [-2.57252, -29.1693, 4.48097], [-3.64256, -41.3023, -2.04496]], [[2.28388, -40.6181, -4.24954], [1.59797, -28.4193, 1.80592], [1.66596, -29.6285, 4.24954], [2.35187, -41.8273, -1.80592]], [[8.11979, -40.3838, -4.01848], [5.7073, -28.3852, 1.57074], [5.92765, -29.4812, 4.01848], [8.34014, -41.4797, -1.57074]], [[13.8573, -39.3164, -3.78814], [9.78781, -27.7704, 1.33971], [10.1287, -28.7376, 3.78814], [14.1982, -40.2836, -1.33971]], [[19.3806, -37.4497, -3.55887], [13.7601, -26.589, 1.1131], [14.1895, -27.4188, 3.55887], [19.8101, -38.2795, -1.1131]], [[24.583, -34.8324, -3.33099], [17.5489, -24.8655, 0.891165], [18.0358, -25.5554, 3.33099], [25.0699, -35.5223, -0.891165]], [[29.3683, -31.5263, -3.10482], [21.0843, -22.6337, 0.674163], [21.5995, -23.1867, 3.10482], [29.8834, -32.0793, -0.674163]], [[33.6517, -27.6039, -2.8807], [24.3028, -19.9352, 0.462334], [24.8197, -20.3592, 2.8807], [34.1687, -28.028, -0.462334]], [[37.3614, -23.1468, -2.65893], [27.1476, -16.819, 0.255906], [27.6432, -17.126, 2.65893], [37.857, -23.4538, -0.255906]], [[40.4387, -18.2432, -2.43982], [29.5699, -13.34, 0.0550995], [30.0248, -13.5452, 2.43982], [40.8935, -18.4484, -0.0550995]], [[42.8384, -12.9864, -2.22366], [31.5289, -9.55796, -0.13988], [31.9278, -9.67886, 2.22366], [43.2372, -13.1073, 0.13988]], [[44.5289, -7.47224, -2.01074], [32.9924, -5.53633, -0.328838], [33.3241, -5.592, 2.01074], [44.8607, -7.52791, 0.328838]], [[45.4921, -1.79772, -1.80134], [33.9365, -1.34107, -0.51159], [34.1942, -1.35126, 1.80134], [45.7499, -1.8079, 0.51159]], [[45.7226, 3.94094, -1.59574], [34.3463, 2.96039, -0.687966], [34.5272, 2.97598, 1.59574], [45.9035, 3.95653, 0.687966]], [[45.2275, 9.64984, -1.39418], [34.2154, 7.30027, -0.857807], [34.3203, 7.32266, 1.39418], [45.3324, 9.67222, 0.857807]], [[44.0251, 15.2388, -1.19694], [33.5456, 11.6115, -1.02097], [33.5789, 11.623, 1.19694], [44.0583, 15.2503, 1.02097]], [[42.1446, 20.6227, -1.00423], [32.347, 15.8284, -1.17731], [32.3159, 15.8132, 1.00423], [42.1135, 20.6075, 1.17731]], [[39.6245, 25.7225, -0.8163], [30.637, 19.8882, -1.32672], [30.5514, 19.8326, 0.8163], [39.5389, 25.6669, 1.32672]], [[36.5119, 30.4661, -0.633365], [28.4404, 23.7312, -1.46909], [28.3121, 23.6241, 0.633365], [36.3836, 30.359, 1.46909]], [[32.8611, 34.7893, -0.455635], [25.7885, 27.3017, -1.60432], [25.6308, 27.1347, 0.455635], [32.7034, 34.6222, 1.60432]], [[28.7325, 38.6359, -0.283306], [22.7184, 30.5488, -1.73233], [22.5454, 30.3163, 0.283306], [28.5596, 38.4033, 1.73233]], [[24.1913, 41.9586, -0.116567], [19.2724, 33.427, -1.85305], [19.0989, 33.1261, 0.116567], [24.0179, 41.6578, 1.85305]], [[19.3066, 44.7192, 0.0444085], [15.4974, 35.8963, -1.96642], [15.338, 35.527, -0.0444085], [19.1471, 44.35, 1.96642]], [[14.1497, 46.8881, 0.199456], [11.4441, 37.9228, -2.0724], [11.3129, 37.4878, -0.199456], [14.0184, 46.4531, 2.0724]], [[8.7935, 48.4451, 0.348425], [7.16601, 39.4789, -2.17096], [7.07602, 38.9832, -0.348425], [8.70351, 47.9493, 2.17096]], [[3.31133, 49.3786, 0.491176], [2.71887, 40.5439, -2.26209], [2.68203, 39.9944, -0.491176], [3.27448, 48.8291, 2.26209]], [[-2.22432, 49.6854, 0.627581], [-1.84011, 41.1031, -2.34576], [-1.81351, 40.509, -0.627581], [-2.19773, 49.0914, 2.34576]], [[-7.74246, 49.3709, 0.757525], [-6.45308, 41.149, -2.42201], [-6.35456, 40.5207, -0.757525], [-7.64394, 48.7427, 2.42201]], [[-13.1746, 48.4478, 0.880906], [-11.0623, 40.6802, -2.49083], [-10.8853, 40.0295, -0.880906], [-12.9976, 47.7971, 2.49083]], [[-18.4552, 46.9361, 0.997633], [-15.6108, 39.702, -2.55228], [-15.351, 39.0413, -0.997633], [-18.1954, 46.2754, 2.55228]], [[-23.523, 44.8625, 1.10763], [-20.0431, 38.2258, -2.60638], [-19.6982, 37.5679, -1.10763], [-23.178, 44.2047, 2.60638]], [[-28.3207, 42.2595, 1.21083], [-24.3058, 36.2686, -2.65321], [-23.8756, 35.6266, -1.21083], [-27.8905, 41.6176, 2.65321]], [[-32.7962, 39.165, 1.30718], [-28.3482, 33.8532, -2.69282], [-27.8346, 33.2398, -1.30718], [-32.2826, 38.5516, 2.69282]], [[-36.9026, 35.6212, 1.39664], [-32.1228, 31.0074, -2.7253], [-31.5297, 30.4349, -1.39664], [-36.3094, 35.0487, 2.7253]], [[-40.5986, 31.6746, 1.47919], [-35.5859, 27.7638, -2.75075], [-34.9189, 27.2434, -1.47919], [-39.9316, 31.1542, 2.75075]], [[-43.8486, 27.3746, 1.5548], [-38.6977, 24.1589, -2.76926], [-37.9641, 23.7009, -1.5548], [-43.1151, 26.9166, 2.76926]], [[-46.6233, 22.7731, 1.62348], [-41.4232, 20.2331, -2.78095], [-40.6316, 19.8464, -1.62348], [-45.8318, 22.3865, 2.78095]], [[-48.8991, 17.9238, 1.68524], [-43.7317, 16.0297, -2.78595], [-42.8921, 15.722, -1.68524], [-48.0595, 17.6161, 2.78595]], [[-50.6585, 12.8816, 1.74009], [-45.598, 11.5948, -2.7844], [-44.721, 11.3718, -1.74009], [-49.7815, 12.6586, 2.7844]], [[-51.8898, 7.7019, 1.78808], [-47.0016, 6.97635, -2.77644], [-46.0986, 6.84231, -1.78808], [-50.9868, 7.56787, 2.77644]], [[-52.5875, 2.43982, 1.82925], [-47.9276, 2.22362, -2.76223], [-47.0103, 2.18106, -1.82925], [-51.6702, 2.39726, 2.76223]], [[-52.7511, -2.85006, 1.86365], [-48.3661, -2.61314, -2.74193], [-47.4463, -2.56345, -1.86365], [-51.8314, -2.80037, 2.74193]], [[-52.3861, -8.1144, 1.89136], [-48.3128, -7.48346, -2.71573], [-47.4022, -7.34242, -1.89136], [-51.4755, -7.97335, 2.71573]], [[-51.5025, -13.3015, 1.91246], [-47.7683, -12.3371, -2.68381], [-46.8783, -12.1072, -1.91246], [-50.6125, -13.0717, 2.68381]], [[-50.1156, -18.362, 1.92704], [-46.7386, -17.1246, -2.64636], [-45.8797, -16.81, -1.92704], [-49.2567, -18.0473, 2.64636]], [[-48.2447, -23.2486, 1.93521], [-45.2342, -21.7979, -2.60358], [-44.4164, -21.4038, -1.93521], [-47.4269, -22.8546, 2.60358]], [[-45.9134, -27.9174, 1.93709], [-43.2706, -26.3105, -2.5557], [-42.5028, -25.8436, -1.93709], [-45.1457, -27.4506, 2.5557]], [[-43.149, -32.3273, 1.93279], [-40.8676, -30.6181, -2.50292], [-40.1576, -30.0862, -1.93279], [-42.439, -31.7954, 2.50292]], [[-39.9819, -36.4407, 1.92245], [-38.0491, -34.6792, -2.44547], [-37.4035, -34.0907, -1.92245], [-39.3362, -35.8523, 2.44547]], [[-36.4455, -40.2237, 1.90622], [-34.8429, -38.455, -2.38358], [-34.2668, -37.8192, -1.90622], [-35.8694, -39.5879, 2.38358]], [[-32.5757, -43.646, 1.88427], [-31.28, -41.91, -2.3175], [-30.7774, -41.2366, -1.88427], [-32.0731, -42.9725, 2.3175]], [[-28.4104, -46.6813, 1.85674], [-27.3947, -45.0124, -2.24747], [-26.9679, -44.3113, -1.85674], [-27.9836, -45.9801, 2.24747]], [[-23.989, -49.3072, 1.82383], [-23.2236, -47.734, -2.17373], [-22.8739, -47.0151, -1.82383], [-23.6393, -48.5883, 2.17373]], [[-19.3526, -51.5055, 1.78571], [-18.8059, -50.0506, -2.09656], [-18.5328, -49.3238, -1.78571], [-19.0795, -50.7787, 2.09656]], [[-14.5426, -53.2618, 1.74258], [-14.1823, -51.942, -2.01619], [-13.9843, -51.2168, -1.74258], [-14.3446, -52.5366, 2.01619]], [[-9.60141, -54.5657, 1.69463], [-9.39495, -53.3924, -1.93291], [-9.26922, -52.6778, -1.69463], [-9.47569, -53.8512, 1.93291]], [[-4.57122, -55.4109, 1.64208], [-4.48699, -54.3899, -1.84698], [-4.42962, -53.6944, -1.64208], [-4.51385, -54.7155, 1.84698]], [[0.50583, -55.7947, 1.58515], [0.497965, -54.9272, -1.75867], [0.491902, -54.2584, -1.58515], [0.499767, -55.126, 1.75867]], [[5.58814, -55.7184, 1.52406], [5.51619, -55.001, -1.66826], [5.45248, -54.3657, -1.52406], [5.52443, -55.0831, 1.66826]], [[10.635, -55.1866, 1.45903], [10.5243, -54.6122, -1.57602], [10.4094, -54.0161, -1.45903], [10.5201, -54.5905, 1.57602]], [[15.6066, -54.2075, 1.39031], [15.4794, -53.7658, -1.48224], [15.3205, -53.2137, -1.39031], [15.4477, -53.6554, 1.48224]], [[20.4648, -52.7925, 1.31814], [20.34, -52.4706, -1.38719], [20.1445, -51.9661, -1.31814], [20.2693, -52.288, 1.38719]], [[25.1729, -50.9562, 1.24277], [25.0658, -50.7392, -1.29116], [24.8413, -50.2849, -1.24277], [24.9485, -50.5018, 1.29116]], [[29.696, -48.7158, 1.16445], [29.618, -48.5878, -1.19443], [29.3725, -48.185, -1.16445], [29.4505, -48.313, 1.19443]], [[34.0013, -46.0915, 1.08344], [33.9602, -46.0358, -1.09728], [33.7013, -45.6848, -1.08344], [33.7424, -45.7405, 1.09728]], [[38.0581, -43.1056, 1], [38.0581, -43.1056, -1], [37.7934, -42.8058, -1], [37.7934, -42.8058, 1]]];
|
|
|
|
|
|
sects = cross_sections(shape_pts, pts, angles, twist = 180, scale = 0.1);
|
|
|
|
for(i = [0:len(expected) - 1]) {
|
|
assertEqualPoints(expected[i], sects[i]);
|
|
}
|
|
}
|
|
|
|
test_cross_sections(); |