1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-01-17 14:18:13 +01:00
dotSCAD/test/test_sphere_spiral.scad
2020-01-27 16:23:39 +08:00

26 lines
7.5 KiB
OpenSCAD

use <unittest.scad>;
use <sphere_spiral.scad>;
module test_sphere_spiral() {
echo("==== test_sphere_spiral ====");
expected_points = [[0, 6.2574, 39.5075], [-1.2061, 6.8404, 39.3923], [-2.6104, 7.1721, 39.2651], [-4.1582, 7.2023, 39.1259], [-5.7838, 6.8929, 38.9748], [-7.4129, 6.2202, 38.8118], [-8.9658, 5.1764, 38.637], [-10.3606, 3.7709, 38.4505], [-11.5172, 2.0308, 38.2522], [-12.3607, 0, 38.0423], [-12.8249, -2.2614, 37.8207], [-12.8558, -4.6791, 37.5877], [-12.4142, -7.1674, 37.3432], [-11.4786, -9.6317, 37.0874], [-10.0463, -11.9727, 36.8202], [-8.1347, -14.0898, 36.5418], [-5.7818, -15.8853, 36.2523], [-3.0449, -17.2685, 35.9518], [0, -18.1596, 35.6403], [3.2609, -18.4936, 35.3179], [6.6326, -18.2229, 34.9848], [10, -17.3205, 34.641], [13.2424, -15.7817, 34.2867], [16.2377, -13.625, 33.9219], [18.8668, -10.8928, 33.5468], [21.0188, -7.6502, 33.1615], [22.5945, -3.984, 32.7661], [23.5114, 0, 32.3607], [23.7069, 4.1802, 31.9454], [23.1413, 8.4227, 31.5204], [21.8003, 12.5864, 31.0858], [19.6962, 16.527, 30.6418], [16.8683, 20.1028, 30.1884], [13.3826, 23.1794, 29.7258], [9.3303, 25.6348, 29.2541], [4.825, 27.3642, 28.7736], [0, 28.2843, 28.2843], [-4.9965, 28.3365, 27.7863], [-10.0055, 27.4899, 27.2799], [-14.8629, 25.7433, 26.7652], [-19.4047, 23.1256, 26.2424], [-23.473, 19.6962, 25.7115], [-26.9211, 15.5429, 25.1728], [-29.6195, 10.7806, 24.6265], [-31.4601, 5.5473, 24.0726], [-32.3607, 0, 23.5114], [-32.2683, -5.6898, 22.9431], [-31.1616, -11.3419, 22.3677], [-29.0524, -16.7734, 21.7856], [-25.9857, -21.8046, 21.1968], [-22.0391, -26.2651, 20.6015], [-17.3205, -30, 20], [-11.9655, -32.8749, 19.3924], [-6.1329, -34.7813, 18.7789], [0, -35.6403, 18.1596], [6.243, -35.4056, 17.5348], [12.399, -34.066, 16.9047], [18.2709, -31.6461, 16.2695], [23.6676, -28.2059, 15.6292], [28.4106, -23.8393, 14.9843], [32.3402, -18.6716, 14.3347], [35.3209, -12.8558, 13.6808], [37.2462, -6.5675, 13.0227], [38.0423, 0, 12.3607], [37.6711, 6.6424, 11.6949], [36.1316, 13.1508, 11.0255], [33.4607, 19.3185, 10.3528], [29.7316, 24.9478, 9.6769], [25.0525, 29.8564, 8.998], [19.563, 33.884, 8.3165], [13.4295, 36.8971, 7.6324], [6.8404, 38.7939, 6.9459], [0, 39.5075, 6.2574], [-6.8783, 39.0089, 5.5669], [-13.5788, 37.3075, 4.8748], [-19.8904, 34.4512, 4.1811], [-25.6137, 30.5252, 3.4862], [-30.5671, 25.6489, 2.7903], [-34.5935, 19.9726, 2.0934], [-37.5648, 13.6725, 1.396], [-39.3863, 6.9449, 0.6981], [-40, 0, 0], [-39.3863, -6.9449, -0.6981], [-37.5648, -13.6725, -1.396], [-34.5935, -19.9726, -2.0934], [-30.5671, -25.6489, -2.7903], [-25.6137, -30.5252, -3.4862], [-19.8904, -34.4512, -4.1811], [-13.5788, -37.3075, -4.8748], [-6.8783, -39.0089, -5.5669], [0, -39.5075, -6.2574], [6.8404, -38.7939, -6.9459], [13.4295, -36.8971, -7.6324], [19.563, -33.884, -8.3165], [25.0525, -29.8564, -8.998], [29.7316, -24.9478, -9.6769], [33.4607, -19.3185, -10.3528], [36.1316, -13.1508, -11.0255], [37.6711, -6.6424, -11.6949], [38.0423, 0, -12.3607], [37.2462, 6.5675, -13.0227], [35.3209, 12.8558, -13.6808], [32.3402, 18.6716, -14.3347], [28.4106, 23.8393, -14.9843], [23.6676, 28.2059, -15.6292], [18.2709, 31.6461, -16.2695], [12.399, 34.066, -16.9047], [6.243, 35.4056, -17.5348], [0, 35.6403, -18.1596], [-6.1329, 34.7813, -18.7789], [-11.9655, 32.8749, -19.3924], [-17.3205, 30, -20], [-22.0391, 26.2651, -20.6015], [-25.9857, 21.8046, -21.1968], [-29.0524, 16.7734, -21.7856], [-31.1616, 11.3419, -22.3677], [-32.2683, 5.6898, -22.9431], [-32.3607, 0, -23.5114], [-31.4601, -5.5473, -24.0726], [-29.6195, -10.7806, -24.6265], [-26.9211, -15.5429, -25.1728], [-23.473, -19.6962, -25.7115], [-19.4047, -23.1256, -26.2424], [-14.8629, -25.7433, -26.7652], [-10.0055, -27.4899, -27.2799], [-4.9965, -28.3365, -27.7863], [0, -28.2843, -28.2843], [4.825, -27.3642, -28.7736], [9.3303, -25.6348, -29.2541], [13.3826, -23.1794, -29.7258], [16.8683, -20.1028, -30.1884], [19.6962, -16.527, -30.6418], [21.8003, -12.5864, -31.0858], [23.1413, -8.4227, -31.5204], [23.7069, -4.1802, -31.9454], [23.5114, 0, -32.3607], [22.5945, 3.984, -32.7661], [21.0188, 7.6502, -33.1615], [18.8668, 10.8928, -33.5468], [16.2377, 13.625, -33.9219], [13.2424, 15.7817, -34.2867], [10, 17.3205, -34.641], [6.6326, 18.2229, -34.9848], [3.2609, 18.4936, -35.3179], [0, 18.1596, -35.6403], [-3.0449, 17.2685, -35.9518], [-5.7818, 15.8853, -36.2523], [-8.1347, 14.0898, -36.5418], [-10.0463, 11.9727, -36.8202], [-11.4786, 9.6317, -37.0874], [-12.4142, 7.1674, -37.3432], [-12.8558, 4.6791, -37.5877], [-12.8249, 2.2614, -37.8207], [-12.3607, 0, -38.0423], [-11.5172, -2.0308, -38.2522], [-10.3606, -3.7709, -38.4505], [-8.9658, -5.1764, -38.637], [-7.4129, -6.2202, -38.8118], [-5.7838, -6.8929, -38.9748], [-4.1582, -7.2023, -39.1259], [-2.6104, -7.1721, -39.2651], [-1.2061, -6.8404, -39.3923], [0, -6.2574, -39.5075]];
expected_angles = [[0, -81, 90], [0, -80, 100], [0, -79, 110], [0, -78, 120], [0, -77, 130], [0, -76, 140], [0, -75, 150], [0, -74, 160], [0, -73, 170], [0, -72, 180], [0, -71, 190], [0, -70, 200], [0, -69, 210], [0, -68, 220], [0, -67, 230], [0, -66, 240], [0, -65, 250], [0, -64, 260], [0, -63, 270], [0, -62, 280], [0, -61, 290], [0, -60, 300], [0, -59, 310], [0, -58, 320], [0, -57, 330], [0, -56, 340], [0, -55, 350], [0, -54, 360], [0, -53, 370], [0, -52, 380], [0, -51, 390], [0, -50, 400], [0, -49, 410], [0, -48, 420], [0, -47, 430], [0, -46, 440], [0, -45, 450], [0, -44, 460], [0, -43, 470], [0, -42, 480], [0, -41, 490], [0, -40, 500], [0, -39, 510], [0, -38, 520], [0, -37, 530], [0, -36, 540], [0, -35, 550], [0, -34, 560], [0, -33, 570], [0, -32, 580], [0, -31, 590], [0, -30, 600], [0, -29, 610], [0, -28, 620], [0, -27, 630], [0, -26, 640], [0, -25, 650], [0, -24, 660], [0, -23, 670], [0, -22, 680], [0, -21, 690], [0, -20, 700], [0, -19, 710], [0, -18, 720], [0, -17, 730], [0, -16, 740], [0, -15, 750], [0, -14, 760], [0, -13, 770], [0, -12, 780], [0, -11, 790], [0, -10, 800], [0, -9, 810], [0, -8, 820], [0, -7, 830], [0, -6, 840], [0, -5, 850], [0, -4, 860], [0, -3, 870], [0, -2, 880], [0, -1, 890], [0, 0, 900], [0, 1, 910], [0, 2, 920], [0, 3, 930], [0, 4, 940], [0, 5, 950], [0, 6, 960], [0, 7, 970], [0, 8, 980], [0, 9, 990], [0, 10, 1000], [0, 11, 1010], [0, 12, 1020], [0, 13, 1030], [0, 14, 1040], [0, 15, 1050], [0, 16, 1060], [0, 17, 1070], [0, 18, 1080], [0, 19, 1090], [0, 20, 1100], [0, 21, 1110], [0, 22, 1120], [0, 23, 1130], [0, 24, 1140], [0, 25, 1150], [0, 26, 1160], [0, 27, 1170], [0, 28, 1180], [0, 29, 1190], [0, 30, 1200], [0, 31, 1210], [0, 32, 1220], [0, 33, 1230], [0, 34, 1240], [0, 35, 1250], [0, 36, 1260], [0, 37, 1270], [0, 38, 1280], [0, 39, 1290], [0, 40, 1300], [0, 41, 1310], [0, 42, 1320], [0, 43, 1330], [0, 44, 1340], [0, 45, 1350], [0, 46, 1360], [0, 47, 1370], [0, 48, 1380], [0, 49, 1390], [0, 50, 1400], [0, 51, 1410], [0, 52, 1420], [0, 53, 1430], [0, 54, 1440], [0, 55, 1450], [0, 56, 1460], [0, 57, 1470], [0, 58, 1480], [0, 59, 1490], [0, 60, 1500], [0, 61, 1510], [0, 62, 1520], [0, 63, 1530], [0, 64, 1540], [0, 65, 1550], [0, 66, 1560], [0, 67, 1570], [0, 68, 1580], [0, 69, 1590], [0, 70, 1600], [0, 71, 1610], [0, 72, 1620], [0, 73, 1630], [0, 74, 1640], [0, 75, 1650], [0, 76, 1660], [0, 77, 1670], [0, 78, 1680], [0, 79, 1690], [0, 80, 1700], [0, 81, 1710]];
points_angles = sphere_spiral(
radius = 40,
za_step = 10,
z_circles = 20,
begin_angle = 90,
end_angle = 90
);
actual_points = [for(pa = points_angles) pa[0]];
actual_angles = [for(pa = points_angles) pa[1]];
assertEqualPoints(expected_points, actual_points);
assertEqualPoints(expected_angles, actual_angles);
}
test_sphere_spiral();