mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-01-17 14:18:13 +01:00
30 lines
3.2 KiB
OpenSCAD
30 lines
3.2 KiB
OpenSCAD
include <unittest.scad>;
|
|
include <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, 0], [-3.3333, -5.7735], [1.9153, -7.6542], [6.9287, -5.6121], [9.7591, -1.1017], [9.7906, 4.1666], [7.2895, 8.7588], [3.0136, 11.7181], [-2.0901, 12.5895], [-7.0994, 11.3524], [-11.25, 8.3116], [-14.0047, 3.9802], [-15.0734, -1.03], [-14.3991, -6.0996], [-12.1214, -10.6703], [-8.5301, -14.2915], [-4.013, -16.6466], [0.9931, -17.5619], [6.0464, -17.0006], [10.7367, -15.0488], [14.7127, -11.8925], [17.7005, -7.7927], [19.5144, -3.0584], [20.0591, 1.9792], [19.327, 6.9904], [17.3894, 11.6667], [14.385, 15.7377], [10.5054, 18.9824], [5.9805, 21.2371], [1.0622, 22.3994], [-3.9897, 22.4281], [-8.9216, 21.3404], [-13.4974, 19.2066], [-17.5086, 16.1426], [-20.7812, 12.3017], [-23.1817, 7.8645], [-24.6193, 3.0301], [-25.0472, -1.9943], [-24.4614, -7.0016], [-22.8983, -11.7935], [-20.4309, -16.1876], [-17.1632, -20.0228], [-13.2255, -23.1648], [-8.7672, -25.5085], [-3.9513, -26.9808], [1.0527, -27.5407], [6.0742, -27.1795], [10.9476, -25.9189], [15.5171, -23.8091], [19.6415, -20.9256], [23.1974, -17.3655], [26.0825, -13.2437], [28.2172, -8.6885], [29.5463, -3.8373], [30.0392, 1.168], [29.6895, 6.1848], [28.5147, 11.0741], [26.5539, 15.704], [23.8664, 19.9529], [20.5291, 23.7124], [16.6337, 26.8894], [12.2839, 29.4078], [7.5924, 31.21], [2.6774, 32.2573], [-2.3402, 32.5302], [-7.3397, 32.0283], [-12.2036, 30.7692], [-16.8203, 28.7878], [-21.0862, 26.1347], [-24.9077, 22.8745], [-28.2033, 19.084], [-30.9046, 14.8497], [-32.9575, 10.2661], [-34.3228, 5.4333], [-34.9764, 0.4543], [-34.9096, -4.5667], [-34.1286, -9.5267], [-32.6536, -14.326], [-30.5187, -18.8701], [-27.77, -23.0711], [-24.4648, -26.8496], [-20.67, -30.1356], [-16.4604, -32.8699], [-11.9176, -35.0046], [-7.1276, -36.5038], [-2.1794, -37.3437], [2.8365, -37.513], [7.83, -37.0127], [12.713, -35.8552], [17.4007, -34.0647], [21.8134, -31.6755], [25.8769, -28.7318], [29.5245, -25.2864], [32.6974, -21.3997], [35.3456, -17.1384], [37.4285, -12.5742], [38.9152, -7.7828], [39.7851, -2.8422], [40.0275, 2.1685], [39.6416, 7.1699]];
|
|
|
|
expected_angles = [180, 240, 285, 321, 354, 384, 411, 436, 460, 483, 504, 525, 544, 563, 582, 600, 617, 634, 650, 666, 682, 697, 712, 726, 740, 754, 768, 782, 795, 808, 821, 833, 846, 858, 870, 882, 893, 905, 916, 928, 939, 950, 961, 972, 982, 993, 1003, 1013, 1024, 1034, 1044, 1054, 1063, 1073, 1083, 1092, 1102, 1111, 1120, 1130, 1139, 1148, 1157, 1166, 1175, 1183, 1192, 1201, 1209, 1218, 1226, 1235, 1243, 1252, 1260, 1268, 1276, 1284, 1292, 1300, 1308, 1316, 1324, 1332, 1339, 1347, 1355, 1362, 1370, 1378, 1385, 1393, 1400, 1407, 1415, 1422, 1429, 1436, 1444, 1451];
|
|
|
|
actual_points = [for(pa = points_angles) pa[0]];
|
|
// ceil for annoying float errors when echoing...XD
|
|
actual_angles = [for(pa = points_angles) ceil(pa[1])];
|
|
|
|
assertEqualPoints(expected_points, actual_points);
|
|
|
|
for(i = [0:0]) {
|
|
assertEqual(expected_angles[i], actual_angles[i]);
|
|
}
|
|
}
|
|
|
|
test_archimedean_spiral(); |