1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-01-17 06:08:31 +01:00
dotSCAD/test/test_archimedean_spiral.scad
2020-01-27 10:24:24 +08:00

28 lines
3.5 KiB
OpenSCAD

use <unittest.scad>;
use <archimedean_spiral.scad>;
module test_archimedean_spiral() {
echo("==== test_archimedean_spiral ====");
points_angles = archimedean_spiral(
arm_distance = 10,
init_angle = 180,
point_distance = 5,
num_of_points = 100
);
expected_points = [[-5, -5.6166e-6], [-3.33332, -5.77351], [1.91533, -7.65424], [6.92877, -5.61211], [9.7591, -1.1017], [9.79062, 4.16668], [7.28945, 8.75883], [3.01356, 11.7181], [-2.09019, 12.5895], [-7.09946, 11.3523], [-11.25, 8.31153], [-14.0047, 3.9801], [-15.0734, -1.03017], [-14.399, -6.09976], [-12.1214, -10.6704], [-8.52998, -14.2915], [-4.01284, -16.6467], [0.993248, -17.5618], [6.04659, -17.0006], [10.7369, -15.0487], [14.7128, -11.8923], [17.7006, -7.79251], [19.5144, -3.05819], [20.0591, 1.97944], [19.327, 6.99059], [17.3893, 11.6669], [14.3848, 15.7379], [10.5052, 18.9825], [5.98025, 21.2372], [1.06198, 22.3994], [-3.98996, 22.4281], [-8.92185, 21.3403], [-13.4977, 19.2064], [-17.5088, 16.1424], [-20.7814, 12.3014], [-23.1818, 7.86423], [-24.6194, 3.02975], [-25.0472, -1.9946], [-24.4613, -7.0019], [-22.8982, -11.7938], [-20.4306, -16.1878], [-17.163, -20.0231], [-13.2252, -23.165], [-8.76686, -25.5087], [-3.95086, -26.9808], [1.05313, -27.5407], [6.07462, -27.1794], [10.948, -25.9187], [15.5175, -23.8089], [19.6418, -20.9253], [23.1977, -17.3652], [26.0827, -13.2433], [28.2174, -8.68809], [29.5464, -3.8368], [30.0391, 1.16851], [29.6894, 6.18531], [28.5145, 11.0746], [26.5536, 15.7045], [23.866, 19.9533], [20.5287, 23.7128], [16.6332, 26.8897], [12.2835, 29.408], [7.59187, 31.2101], [2.6768, 32.2573], [-2.34079, 32.5302], [-7.34027, 32.0282], [-12.2042, 30.769], [-16.8208, 28.7875], [-21.0866, 26.1344], [-24.9081, 22.8741], [-28.2036, 19.0834], [-30.9049, 14.8491], [-32.9577, 10.2655], [-34.3229, 5.43264], [-34.9764, 0.453654], [-34.9095, -4.56731], [-34.1284, -9.52732], [-32.6534, -14.3266], [-30.5184, -18.8707], [-27.7696, -23.0716], [-24.4643, -26.8501], [-20.6694, -30.136], [-16.4598, -32.8703], [-11.9169, -35.0049], [-7.12684, -36.5039], [-2.17866, -37.3437], [2.83721, -37.513], [7.83071, -37.0125], [12.7137, -35.855], [17.4014, -34.0643], [21.814, -31.675], [25.8775, -28.7313], [29.525, -25.2858], [32.6978, -21.399], [35.3459, -17.1377], [37.4287, -12.5734], [38.9154, -7.78198], [39.7852, -2.84131], [40.0274, 2.16931], [39.6415, 7.17075]];
expected_angles = [180, 240, 284.049, 320.993, 353.559, 383.054, 410.231, 435.578, 459.427, 482.021, 503.543, 524.135, 543.91, 562.959, 581.357, 599.169, 616.447, 633.237, 649.579, 665.507, 681.051, 696.239, 711.093, 725.636, 739.885, 753.859, 767.572, 781.039, 794.273, 807.286, 820.087, 832.689, 845.098, 857.325, 869.377, 881.261, 892.984, 904.553, 915.973, 927.251, 938.391, 949.398, 960.277, 971.033, 981.669, 992.19, 1002.6, 1012.9, 1023.09, 1033.19, 1043.18, 1053.08, 1062.89, 1072.6, 1082.23, 1091.77, 1101.23, 1110.6, 1119.9, 1129.12, 1138.26, 1147.33, 1156.33, 1165.26, 1174.12, 1182.91, 1191.64, 1200.3, 1208.9, 1217.44, 1225.92, 1234.34, 1242.7, 1251.01, 1259.26, 1267.45, 1275.6, 1283.69, 1291.73, 1299.72, 1307.66, 1315.55, 1323.4, 1331.2, 1338.95, 1346.66, 1354.33, 1361.95, 1369.52, 1377.06, 1384.55, 1392.01, 1399.42, 1406.8, 1414.13, 1421.43, 1428.69, 1435.92, 1443.1, 1450.25];
actual_points = [for(pa = points_angles) pa[0]];
actual_angles = [for(pa = points_angles) pa[1]];
assertEqualPoints(expected_points, actual_points);
for(i = [0:0]) {
assertEqualNum(expected_angles[i], actual_angles[i]);
}
}
test_archimedean_spiral();