1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-01-17 22:28:16 +01:00
dotSCAD/test/test_torus_knot.scad

18 lines
4.2 KiB
OpenSCAD
Raw Normal View History

2020-01-27 16:28:12 +08:00
use <unittest.scad>;
use <torus_knot.scad>;
2019-06-14 13:44:38 +08:00
module test_torus_knot() {
echo("==== test_torus_knot ====");
p = 2;
q = 3;
phi_step = 0.05;
star_radius = 0.5;
expected = [[3, 0, 0], [2.97384, 0.298379, -0.149438], [2.89643, 0.587135, -0.29552], [2.7709, 0.857141, -0.434966], [2.60231, 1.10024, -0.564642], [2.39728, 1.30964, -0.681639], [2.16371, 1.48027, -0.783327], [1.91025, 1.60898, -0.867423], [1.64587, 1.69465, -0.932039], [1.37936, 1.73821, -0.975723], [1.11882, 1.74247, -0.997495], [0.871303, 1.7119, -0.996865], [0.642387, 1.65232, -0.973848], [0.435975, 1.57043, -0.92896], [0.254127, 1.4734, -0.863209], [0.0970392, 1.36839, -0.778073], [-0.0368675, 1.26207, -0.675463], [-0.150741, 1.16019, -0.557684], [-0.248997, 1.06727, -0.42738], [-0.336937, 0.986246, -0.287478], [-0.420311, 0.918397, -0.14112], [-0.504864, 0.86324, 0.00840725], [-0.595869, 0.818619, 0.157746], [-0.697712, 0.780889, 0.303542], [-0.813523, 0.745199, 0.44252], [-0.944901, 0.705862, 0.571561], [-1.09173, 0.656784, 0.687766], [-1.25214, 0.59192, 0.788525], [-1.42251, 0.505745, 0.871576], [-1.5977, 0.393683, 0.935053], [-1.7713, 0.252493, 0.97753], [-1.93598, 0.0805688, 0.998054], [-2.08394, -0.121856, 0.996165], [-2.20739, -0.352622, 0.971903], [-2.29902, -0.607671, 0.925815], [-2.35246, -0.881197, 0.858934], [-2.36268, -1.16591, 0.772764], [-2.32638, -1.45337, 0.66924], [-2.24217, -1.73444, 0.550686], [-2.11074, -1.99977, 0.419764], [-1.9349, -2.24026, 0.279415], [-1.71938, -2.44758, 0.132792], [-1.47071, -2.6146, -0.0168139], [-1.19683, -2.73578, -0.166042], [-0.906703, -2.80745, -0.311541], [-0.609834, -2.828, -0.450044], [-0.315791, -2.79796, -0.57844], [-0.0336987, -2.71992, -0.693845], [0.228228, -2.59835, -0.793668], [0.463095, -2.43935, -0.875667], [0.665652, -2.25025, -0.938], [0.832522, -2.03917, -0.979268], [0.962312, -1.81458, -0.998543], [1.0556, -1.58474, -0.995394], [1.11481, -1.35733, -0.96989], [1.14397, -1.13892, -0.922604], [1.14839, -0.934724, -0.854599], [1.13424, -0.74829, -0.767401], [1.1081, -0.581381, -0.662969], [1.07651, -0.433954, -0.543648], [1.0455, -0.304247, -0.412118], [1.02016, -0.188996, -0.271333], [1.00429, -0.0837354, -0.124454], [1.00018, 0.0168192, 0.0252194], [1.00839, 0.118334, 0.174327], [1.02778, 0.226397, 0.319519], [1.05553, 0.346063, 0.457536], [1.08735, 0.481434, 0.585277], [1.11781, 0.635299, 0.699875], [1.14066, 0.808857, 0.798754], [1.1493, 1.00155, 0.879696], [1.13721, 1.21101, 0.940881], [1.09848, 1.4331, 0.980936], [1.02819, 1.66213, 0.998962], [0.922807, 1.89109, 0.994553], [0.780515, 2.11208, 0.967808], [0.601388, 2.31671, 0.919329], [0.387492, 2.49656, 0.850203], [0.142852, 2.64374, 0.761984], [-0.126699, 2.75128, 0.656652], [-0.413781, 2.81359, 0.536573], [-0.709825, 2.8268, 0.404444], [-1.0055, 2.78901, 0.263232], [-1.29121, 2.70041, 0.116108], [-1.55757, 2.56331, -0.033623], [-1.79591, 2.38204, -0.182599], [-1.99874, 2.1627, -0.327474], [-2.16008, 1.91287, -0.464995], [-2.27583, 1.64121, -0.592074], [-2.34391, 1.35694, -0.705855], [-2.36431, 1.06941, -0.803784], [-2.33909, 0.787574, -0.883663], [-2.27218, 0.519515, -0.943696], [-2.16908, 0.272067, -0.982535], [-2.03653, 0.0504715, -0.999309], [-1.88207, -0.141841, -0.993641], [-1.71354, -0.30336, -0.965658], [-1.53862, -0.434489, -0.915988], [-1.36439, -0.537411, -0.845747], [-1.19687, -0.615853, -0.756512], [-1.04071, -0.674756, -0.650288], [-0.898953, -0.719872, -0.529459], [-0.772885, -0.757313, -0.396741], [-0.66203, -0.793087, -0.255112], [-0.564251, -0.832646, -0.107754], [-0.475957, -0.880473, 0.0420244], [-0.392422, -0.939738, 0.190859], [-0.308163, -1.01205, 0.335407], [-0.217383, -1.0973, 0.472422], [-0.114431, -1.19365, 0.598828], [0.0057428, -1.29759, 0.711785], [0.147166, -1.40417, 0.808758], [0.31249, -1.50727, 0.887567], [0.502712, -1.60001, 0.946444], [0.717015, -1.67519, 0.984065], [0.952712, -1.72573, 0.999586], [1.20531, -1.74517, 0.992659], [1.4687, -1.72812, 0.963439], [1.73544, -1.67063, 0.912582], [1.99715, -1.57049, 0.841231], [2.24492, -1.42745, 0.750987], [2.46983, -1.24333, 0.643878], [2.66343, -1.02194, 0.522309], [2.81821, -0.768962, 0.389009], [2.92803, -0.491682, 0.246974], [2.98845, -0.198637, 0.0993915]];
actual = torus_knot(p, q, phi_step);
assertEqualPoints(expected, actual);
}
test_torus_knot();