1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-01-18 06:38:14 +01:00
dotSCAD/test/test_archimedean_spiral_extrude.scad

37 lines
23 KiB
OpenSCAD
Raw Normal View History

2020-01-27 09:53:06 +08:00
use <unittest.scad>;
2020-01-28 09:44:36 +08:00
include <archimedean_spiral_extrude.scad>;
2020-01-27 09:53:06 +08:00
module test_archimedean_spiral_extrude(sections) {
expected = [[[-12.5, -0.0000140415, 0], [-12.5, -0.0000140415, 4], [-11.5, -0.0000129182, 4], [-11.5, -0.0000129182, 2], [-3.5, -3.93162e-6, 2], [-3.5, -3.93162e-6, 4], [-2.5, -2.8083e-6, 4], [-2.5, -2.8083e-6, 0]], [[-10.9842, -8.87663, 0], [-10.9842, -8.87663, 4.16162], [-10.2065, -8.24809, 4.16162], [-10.2065, -8.24809, 2.08081], [-3.98424, -3.21976, 2.08081], [-3.98424, -3.21976, 4.16162], [-3.20646, -2.59122, 4.16162], [-3.20646, -2.59122, 0]], [[-5.09238, -14.5846, 0], [-5.09238, -14.5846, 4.32323], [-4.76273, -13.6404, 4.32323], [-4.76273, -13.6404, 2.16162], [-2.12557, -6.08761, 2.16162], [-2.12557, -6.08761, 4.32323], [-1.79592, -5.14351, 4.32323], [-1.79592, -5.14351, 0]], [[2.43691, -16.4219, 0], [2.43691, -16.4219, 4.48485], [2.29013, -15.4327, 4.48485], [2.29013, -15.4327, 2.24242], [1.11583, -7.51935, 2.24242], [1.11583, -7.51935, 4.48485], [0.969043, -6.53019, 4.48485], [0.969043, -6.53019, 0]], [[9.69147, -14.7377, 0], [9.69147, -14.7377, 4.64646], [9.14202, -13.9021, 4.64646], [9.14202, -13.9021, 2.32323], [4.74648, -7.2179, 2.32323], [4.74648, -7.2179, 4.64646], [4.19703, -6.38237, 4.64646], [4.19703, -6.38237, 0]], [[15.4378, -10.3557, 0], [15.4378, -10.3557, 4.80808], [14.6073, -9.79865, 4.80808], [14.6073, -9.79865, 2.40404], [7.96364, -5.34204, 2.40404], [7.96364, -5.34204, 4.80808], [7.13318, -4.78496, 4.80808], [7.13318, -4.78496, 0]], [[19, -4.26514, 0], [19, -4.26514, 4.9697], [18.0243, -4.04611, 4.9697], [18.0243, -4.04611, 2.48485], [10.2185, -2.29386, 2.48485], [10.2185, -2.29386, 4.9697], [9.24281, -2.07483, 4.9697], [9.24281, -2.07483, 0]], [[20.1398, 2.55924, 0], [20.1398, 2.55924, 5.13131], [19.1478, 2.43318, 5.13131], [19.1478, 2.43318, 2.56566], [11.2116, 1.4247, 2.56566], [11.2116, 1.4247, 5.13131], [10.2196, 1.29864, 5.13131], [10.2196, 1.29864, 0]], [[18.9436, 9.25917, 0], [18.9436, 9.25917, 5.29293], [18.0452, 8.82004, 5.29293], [18.0452, 8.82004, 2.64646], [10.8578, 5.30701, 2.64646], [10.8578, 5.30701, 5.29293], [9.95934, 4.86789, 5.29293], [9.95934, 4.86789, 0]], [[15.7218, 15.1457, 0], [15.7218, 15.1457, 5.45455], [15.0017, 14.4519, 5.45455], [15.0017, 14.4519, 2.72727], [9.24022, 8.9016, 2.72727], [9.24022, 8.9016, 5.45455], [8.52004, 8.20782, 5.45455], [8.52004, 8.20782, 0]], [[10.9234, 19.7189, 0], [10.9234, 19.7189, 5.61616], [10.4388, 18.8441, 5.61616], [10.4388, 18.8441, 2.80808], [6.56225, 11.8461, 2.80808], [6.56225, 11.8461, 5.61616], [6.07768, 10.9714, 5.61616], [6.07768, 10.9714, 0]], [[5.06562, 22.6659, 0], [5.06562, 22.6659, 5.77778], [4.84751, 21.69, 5.77778], [4.84751, 21.69, 2.88889], [3.10263, 13.8826, 2.88889], [3.10263, 13.8826, 5.77778], [2.88452, 12.9067, 5.77778], [2.88452, 12.9067, 0]], [[-1.32091, 23.8455, 0], [-1.32091, 23.8455, 5.93939], [-1.2656, 22.8471, 5.93939], [-1.2656, 22.8471, 2.9697], [-0.823122, 14.8593, 2.9697], [-0.823122, 14.8593, 5.93939], [-0.767813, 13.8609, 5.93939], [-0.767813, 13.8609, 0]], [[-7.73333, 23.2645, 0], [-7.73333, 23.2645, 6.10101], [-7.41789, 22.3155, 6.10101], [-7.41789, 22.3155, 3.05051], [-4.89439, 14.724, 3.05051], [-4.89439, 14.724, 6.10101], [-4.57895, 13.775, 6.10101], [-4.57895, 13.775, 0]], [[-13.7257, 21.0498, 0], [-13.7257, 21.0498, 6.26263], [-13.1795, 20.2121, 6.26263], [-13.1795, 20.2121, 3.13131], [-8.80993, 13.5109, 3.13131], [-8.80993, 13.5109, 6.26263], [-8.26373, 12.6732, 6.26263], [-8.26373, 12.6732, 0]], [[-18.9279, 17.42, 0], [-18.9279, 17.42, 6.42424], [-18.1921, 16.7428, 6.42424], [-18.1921, 16.7428, 3.21212], [-12.3056, 11.3253, 3.21212], [-12.3056, 11.3253, 6.42424], [-11.5698, 10.6481, 6.42424], [-11.5698, 10.6481, 0]], [[-23.0553, 12.6576, 0], [-23.0553, 12.6576, 6.58586], [-22.1787, 12.1763, 6.58586], [-22.1787, 12.1763, 3.29293], [-15.1661, 8.32631, 3.29293], [-15.1661, 8.32631, 6.58586], [-14.2895, 7.84506, 6.58586], [-14.2895, 7.84506, 0]], [[-25.9125, 7.08267, 0], [-25.9125, 7.08267, 6.74747], [-24.9479, 6.81901, 6.74747], [-24.9479, 6.81901, 3.37374], [-17.231, 4.70974, 3.37374], [-17.231, 4.70974, 6.74747], [-16.2663, 4.44608, 6.74747], [-16.2663, 4.44608, 0]], [[-27.3908, 1.03079,
2020-01-27 09:53:06 +08:00
for(i = [0:len(expected) - 1]) {
assertEqualPoints(expected[i], sections[i]);
}
}
2020-01-27 09:53:06 +08:00
module test_archimedean_spiral_extrude_slide() {
echo("==== test_archimedean_spiral_extrude_slide ====");
shape_pts = [
[5, 0],
[5, 4],
[4, 4],
[4, 2],
[-4, 2],
[-4, 4],
[-5, 4],
[-5, 0]
];
archimedean_spiral_extrude(
shape_pts,
arm_distance = 15,
init_angle = 180,
point_distance = 5,
num_of_points = 100,
scale = [1, 5]
);
}
test_archimedean_spiral_extrude_slide();