1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-01-17 14:18:13 +01:00
dotSCAD/test/test_cross_sections.scad

37 lines
13 KiB
OpenSCAD
Raw Normal View History

2022-06-06 13:11:46 +08:00
use <unittest.scad>
use <cross_sections.scad>
use <archimedean_spiral.scad>
2020-01-26 16:26:19 +08:00
module test_cross_sections() {
echo("==== test_cross_sections ====");
2017-06-22 15:10:25 +08:00
shape_pts = [
[-2, -10],
[-2, 10],
[2, 10],
[2, -10]
];
2017-06-22 15:05:09 +08:00
pts_angles = archimedean_spiral(
arm_distance = 20,
init_angle = 180,
point_distance = 5,
num_of_points = 100
);
2017-06-22 15:05:09 +08:00
pts = [for(pt_angle = pts_angles) pt_angle[0]];
angles = [
for(i = [0:len(pts_angles) - 1]) [90, 0, pts_angles[i][1]]
];
2017-06-22 15:05:09 +08:00
2022-04-16 17:07:49 +08:00
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,
2017-06-22 15:05:09 +08:00
sects = cross_sections(shape_pts, pts, angles, twist = 180, scale = 0.1);
2017-06-22 15:05:09 +08:00
for(i = [0:len(expected) - 1]) {
assertEqualPoints(expected[i], sects[i]);
}
2017-06-22 15:05:09 +08:00
}
test_cross_sections();