1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-02-22 16:50:36 +01:00
dotSCAD/test/test_path_extrude.scad

74 lines
81 KiB
OpenSCAD
Raw Normal View History

2019-06-16 10:33:55 +08:00
include <unittest.scad>;
include <shape_pentagram.scad>;
include <rotate_p.scad>;
include <polysections.scad>;
include <torus_knot.scad>;
module test_path_extrude_euler_angle() {
echo("==== test_path_extrude_euler_angle ====");
include <path_extrude.scad>;
module test_path_extrude(sections) {
expected = [[[2.95434, 0.520746, 0.297969], [2.85599, 0.35729, -0.0111818], [2.4941, 0.325562, -0.0111818], [2.7952, 0.256268, -0.202247], [2.69684, 0.0928122, -0.511398], [2.98129, 0.213443, -0.320332], [3.28238, 0.144149, -0.511398], [3.15708, 0.287996, -0.202247], [3.44153, 0.408627, -0.0111818], [3.07964, 0.376899, -0.0111818]], [[2.83958, 0.799164, 0.153715], [2.77043, 0.623587, -0.156699], [2.41955, 0.529518, -0.156699], [2.7277, 0.515074, -0.348545], [2.65855, 0.339496, -0.658959], [2.91814, 0.506147, -0.467113], [3.22628, 0.491702, -0.658959], [3.07858, 0.609142, -0.348545], [3.33817, 0.775793, -0.156699], [2.98729, 0.681724, -0.156699]], [[2.68151, 1.04943, 0.0178389], [2.64148, 0.869239, -0.295041], [2.31207, 0.716097, -0.295041], [2.61675, 0.757873, -0.488412], [2.57672, 0.577678, -0.801292], [2.80505, 0.783691, -0.607921], [3.10973, 0.825467, -0.801292], [2.94616, 0.911014, -0.488412], [3.17449, 1.11703, -0.295041], [2.84507, 0.963886, -0.295041]], [[2.48791, 1.26518, -0.106704], [2.47471, 1.08723, -0.423132], [2.17621, 0.880208, -0.423132], [2.46656, 0.977256, -0.618695], [2.45336, 0.799308, -0.935122], [2.646, 1.03723, -0.739559], [2.93635, 1.13428, -0.935122], [2.76506, 1.18428, -0.618695], [2.95771, 1.42221, -0.423132], [2.6592, 1.21518, -0.423132]], [[2.26759, 1.44211, -0.217276], [2.27699, 1.27204, -0.538143], [2.01742, 1.0179, -0.538143], [2.2828, 1.16693, -0.736449], [2.29221, 0.99687, -1.05732], [2.44682, 1.25904, -0.85901], [2.7122, 1.40808, -1.05732], [2.54238, 1.42108, -0.736449], [2.69699, 1.68325, -0.538143], [2.43742, 1.42911, -0.538143]], [[2.02981, 1.57809, -0.311625], [2.05611, 1.41985, -0.637563], [1.84182, 1.12652, -0.637563], [2.07237, 1.32206, -0.839004], [2.09867, 1.16382, -1.16494], [2.21485, 1.44291, -0.963501], [2.4454, 1.63845, -1.16494], [2.28666, 1.61539, -0.839004], [2.40284, 1.89448, -0.637563], [2.18855, 1.60115, -0.637563]], [[1.78378, 1.6732, -0.387964], [1.82034, 1.52873, -0.719262], [1.65586, 1.20483, -0.719262], [1.84294, 1.43945, -0.924016], [1.8795, 1.29498, -1.25531], [1.95855, 1.58445, -1.05056], [2.14563, 1.81907, -1.25531], [2.00741, 1.76335, -0.924016], [2.08647, 2.05282, -0.719262], [1.92199, 1.72892, -0.719262]], [[1.53815, 1.72956, -0.445029], [1.57798, 1.59865, -0.781545], [1.46599, 1.25307, -0.781545], [1.60259, 1.51774, -0.989523], [1.64242, 1.38683, -1.32604], [1.68701, 1.68132, -1.11806], [1.82361, 1.94599, -1.32604], [1.71458, 1.86332, -0.989523], [1.75918, 2.15781, -0.781545], [1.64719, 1.81223, -0.781545]], [[1.30056, 1.75109, -0.48214], [1.3369, 1.6314, -0.823198], [1.27831, 1.27288, -0.823198], [1.35936, 1.55743, -1.03398], [1.3957, 1.43774, -1.37504], [1.40946, 1.73329, -1.16426], [1.49051, 2.01783, -1.37504], [1.41795, 1.91595, -1.03398], [1.4317, 2.21149, -0.823198], [1.37311, 1.85297, -0.823198]], [[1.0772, 1.74315, -0.499231], [1.10413, 1.63043, -0.843523], [1.09819, 1.26721, -0.843523], [1.12077, 1.56077, -1.05631], [1.1477, 1.44806, -1.4006], [1.13472, 1.74221, -1.18781], [1.1573, 2.03577, -1.4006], [1.12671, 1.924, -1.05631], [1.11373, 2.21814, -0.843523], [1.10779, 1.85492, -0.843523]], [[0.872557, 1.71206, -0.496867], [0.885448, 1.60054, -0.842357], [0.929966, 1.24001, -0.842357], [0.893415, 1.53162, -1.05588], [0.906305, 1.4201, -1.40137], [0.870825, 1.71184, -1.18785], [0.834273, 2.00345, -1.40137], [0.848896, 1.89215, -1.05588], [0.813415, 2.18389, -0.842357], [0.857934, 1.82336, -0.842357]], [[0.68925, 1.66452, -0.476198], [0.685146, 1.54745, -0.820065], [0.776653, 1.19589, -0.820065], [0.682609, 1.4751, -1.03259], [0.678504, 1.35803, -1.37645], [0.624487, 1.64766, -1.16393], [0.530443, 1.92686, -1.37645], [0.591102, 1.82666, -1.03259], [0.537084, 2.11628, -0.820065], [0.628591, 1.76472, -0.820065]], [[0.528059, 1.60696, -0.438872], [0.505828, 1.47737, -0.777514], [0.639793, 1.1397, -0.777514], [0.492088, 1.39728, -0.986807], [0.469857, 1.26769, -1.32545], [0.400802, 1.55647, -1.11616], [0.253097, 1.81405, -1.32545], [0.358123, 1.73495, -0.986807], [0.289068, 2.02373, -0.777514], [0.423033, 1.68606, -0.777514]], [[0.388193, 1.5449
for(i = [0:len(expected) - 1]) {
assertEqualPoints(expected[i], sections[i]);
}
}
p = 2;
q = 3;
phi_step = 0.05;
star_radius = 0.5;
pts = torus_knot(p, q, phi_step);
shape_pentagram_pts = shape_pentagram(star_radius);
path_extrude(
shape_pentagram_pts,
concat(pts, [pts[0]]),
closed = true,
method = "EULER_ANGLE"
);
}
module test_path_extrude_axis_angle() {
echo("==== test_path_extrude_axis_angle ====");
include <path_extrude.scad>;
module test_path_extrude(sections) {
expected = [[[2.9805, 0.222367, 0.447407], [2.88215, 0.0589106, 0.138256], [2.52026, 0.0271826, 0.138256], [2.82136, -0.0421108, -0.0528092], [2.723, -0.205567, -0.36196], [3.00745, -0.0849366, -0.170894], [3.30854, -0.15423, -0.36196], [3.18324, -0.0103828, -0.0528092], [3.46769, 0.110248, 0.138256], [3.1058, 0.0785196, 0.138256]], [[2.95434, 0.520746, 0.297969], [2.85599, 0.35729, -0.0111818], [2.4941, 0.325562, -0.0111818], [2.7952, 0.256268, -0.202247], [2.69684, 0.0928122, -0.511398], [2.98129, 0.213443, -0.320332], [3.28238, 0.144149, -0.511398], [3.15708, 0.287996, -0.202247], [3.44153, 0.408627, -0.0111818], [3.07964, 0.376899, -0.0111818]], [[2.86455, 0.805557, 0.153118], [2.77764, 0.628055, -0.151684], [2.42509, 0.542053, -0.134859], [2.72392, 0.518352, -0.340062], [2.637, 0.34085, -0.644864], [2.9086, 0.503705, -0.466885], [3.20742, 0.480005, -0.672088], [3.07646, 0.604355, -0.356887], [3.34806, 0.767209, -0.178908], [2.99552, 0.681207, -0.162083]], [[2.72752, 1.06964, 0.015547], [2.6542, 0.880061, -0.285534], [2.31993, 0.741734, -0.252475], [2.60889, 0.762895, -0.471612], [2.53557, 0.573315, -0.772693], [2.78747, 0.775973, -0.607046], [3.07643, 0.797134, -0.826183], [2.94316, 0.901222, -0.504671], [3.19507, 1.10388, -0.339024], [2.86079, 0.965553, -0.305965]], [[2.54875, 1.30479, -0.111553], [2.49076, 1.10553, -0.409708], [2.18335, 0.918084, -0.361421], [2.45492, 0.982373, -0.593979], [2.39693, 0.783108, -0.892134], [2.62276, 1.02211, -0.737707], [2.89433, 1.08639, -0.970265], [2.76233, 1.16981, -0.642266], [2.98816, 1.40881, -0.487839], [2.68075, 1.22137, -0.439552]], [[2.33552, 1.50419, -0.2252], [2.294, 1.29804, -0.521414], [2.02152, 1.06593, -0.459353], [2.26833, 1.17063, -0.704484], [2.22681, 0.964474, -1.0007], [2.42087, 1.23533, -0.855983], [2.66769, 1.34002, -1.10111], [2.54081, 1.40273, -0.766544], [2.73487, 1.67359, -0.62183], [2.4624, 1.44148, -0.559769]], [[2.09654, 1.66282, -0.322716], [2.07181, 1.4529, -0.618161], [1.84159, 1.18178, -0.544283], [2.05653, 1.32317, -0.800756], [2.0318, 1.11324, -1.0962], [2.18937, 1.41054, -0.959265], [2.4043, 1.55193, -1.21574], [2.28675, 1.59428, -0.874634], [2.44432, 1.89158, -0.737698], [2.21409, 1.62046, -0.66382]], [[1.84149, 1.7778, -0.401834], [1.83287, 1.56739, -0.697844], [1.6512, 1.264, -0.614663], [1.82753, 1.43736, -0.880788], [1.8189, 1.22695, -1.1768], [1.93651, 1.5445, -1.04526], [2.11284, 1.71785, -1.31139], [2.00919, 1.74075, -0.963969], [2.1268, 2.05829, -0.832433], [1.94514, 1.7549, -0.749252]], [[1.58057, 1.84855, -0.460816], [1.5861, 1.64086, -0.75881], [1.45798, 1.31289, -0.669451], [1.58952, 1.5125, -0.94298], [1.59505, 1.30481, -1.24097], [1.67081, 1.63587, -1.11203], [1.80235, 1.83548, -1.38556], [1.71764, 1.84047, -1.03234], [1.7934, 2.17153, -0.903395], [1.66528, 1.84356, -0.814036]], [[1.32382, 1.87694, -0.498575], [1.34016, 1.67472, -0.799918], [1.26887, 1.33054, -0.708146], [1.35027, 1.54974, -0.986157], [1.36661, 1.34752, -1.2875], [1.40057, 1.68522, -1.15798], [1.48196, 1.90442, -1.43599], [1.42156, 1.89392, -1.07793], [1.45552, 2.23162, -0.948407], [1.38422, 1.88744, -0.856635]], [[1.08053, 1.86715, -0.514808], [1.10289, 1.6723, -0.820584], [1.08964, 1.32055, -0.730775], [1.11672, 1.55188, -1.00956], [1.13909, 1.35703, -1.31534], [1.13345, 1.69484, -1.18187], [1.16053, 1.92616, -1.46065], [1.12997, 1.90362, -1.09937], [1.12434, 2.24144, -0.965898], [1.11108, 1.88969, -0.876089]], [[0.858524, 1.82543, -0.510091], [0.880812, 1.63853, -0.820796], [0.924361, 1.28755, -0.737801], [0.894586, 1.52302, -1.01282], [0.916874, 1.33612, -1.32353], [0.876184, 1.66854, -1.1828], [0.84641, 1.904, -1.45782], [0.851037, 1.87399, -1.09582], [0.810348, 2.20641, -0.955086], [0.853897, 1.85544, -0.872091]], [[0.663547, 1.7595, -0.485931], [0.678721, 1.57947, -0.801084], [0.775139, 1.23653, -0.729928], [0.688099, 1.4682, -0.99586], [0.703272, 1.28816, -1.31101], [0.634305, 1.61137, -1.16022], [0.547265, 1.84304, -1.42615], [0.59168, 1.81113, -1.06702], [0.522713, 2.13435, -0.916218], [0.619131, 1.79141, -0.845062]], [[0.498677, 1.67784, -0.444
for(i = [0:len(expected) - 1]) {
assertEqualPoints(expected[i], sections[i]);
}
}
p = 2;
q = 3;
phi_step = 0.05;
star_radius = 0.5;
pts = torus_knot(p, q, phi_step);
shape_pentagram_pts = shape_pentagram(star_radius);
// adjust it
path_extrude(
shape_pentagram_pts,
concat(pts, [pts[0]]),
closed = true,
twist = 188,
method = "AXIS_ANGLE"
);
}
test_path_extrude_euler_angle();
test_path_extrude_axis_angle();