mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-01-17 14:18:13 +01:00
26 lines
3.3 KiB
OpenSCAD
26 lines
3.3 KiB
OpenSCAD
|
use <unittest.scad>;
|
||
|
use <shape_taiwan.scad>;
|
||
|
use <in_shape.scad>;
|
||
|
|
||
|
module test_in_shape() {
|
||
|
echo("==== test_in_shape ====");
|
||
|
|
||
|
points = shape_taiwan(30);
|
||
|
|
||
|
n = 200;
|
||
|
xs = rands(-9, 9, n, seed = 1);
|
||
|
ys = rands(-16, 16, n, seed = 1);
|
||
|
|
||
|
pts = [
|
||
|
for(i = [0:n - 1])
|
||
|
let(p = [xs[i], ys[i]])
|
||
|
if(in_shape(points, p, true))
|
||
|
p
|
||
|
];
|
||
|
|
||
|
expected = [[-4.7504, -8.44515], [-1.86155, -3.30942], [-2.01761, -3.58686], [3.05543, 5.43187], [6.2336, 11.0819], [-3.36108, -5.97525], [0.441867, 0.785541], [-1.01785, -1.80951], [-4.86761, -8.65353], [0.61945, 1.10125], [-0.770313, -1.36945], [-1.24743, -2.21765], [5.01101, 8.90846], [3.88747, 6.91106], [5.44964, 9.68824], [0.326746, 0.580882], [6.57036, 11.6806], [5.92464, 10.5327], [5.93286, 10.5473], [-4.0851, -7.2624], [3.0695, 5.4569], [1.67518, 2.9781], [3.08977, 5.49293], [-1.58782, -2.82279], [-5.44408, -9.67837], [-3.78667, -6.73185], [5.09966, 9.06606], [-1.5743, -2.79876], [2.23254, 3.96896], [2.89144, 5.14034], [-3.62708, -6.44815], [-0.969579, -1.7237], [-5.00176, -8.89201], [-0.553707, -0.984367], [0.446389, 0.79358], [-3.61926, -6.43424], [1.519, 2.70045], [1.18642, 2.10918], [2.05089, 3.64603], [-4.30238, -7.64867], [-4.84172, -8.60751], [0.602073, 1.07035], [-0.124927, -0.222093], [0.730809, 1.29922], [4.77873, 8.49552], [5.26326, 9.35691], [6.89626, 12.26], [0.734187, 1.30522], [-0.936357, -1.66463], [7.05845, 12.5483], [-2.20348, -3.9173], [0.691645, 1.22959], [2.74138, 4.87356], [-2.4973, -4.43965], [1.27815, 2.27227], [2.48106, 4.41077], [3.42368, 6.08655], [2.65949, 4.72798], [-2.6291, -4.67395], [4.7382, 8.42346], [-2.58243, -4.59099], [4.55019, 8.08923], [6.86415, 12.2029], [-0.0340367, -0.0605098], [5.16513, 9.18245], [-2.60441, -4.63007], [-2.16354, -3.84629], [4.73256, 8.41344], [4.88871, 8.69104], [-3.57551, -6.35646], [4.9093, 8.72765], [1.41541, 2.51629], [3.76277, 6.68936], [-0.528466, -0.939494], [4.76267, 8.46696], [-0.586932, -1.04343], [-4.15798, -7.39197], [5.97047, 10.6142], [0.923849, 1.6424], [-0.495449, -0.880799], [4.36977, 7.76847], [-0.642393, -1.14203], [-4.85347, -8.62839], [0.148456, 0.263921], [-5.24577, -9.32581], [0.339514, 0.60358], [-1.86636, -3.31797], [0.176585, 0.313929], [-3.80308, -6.76103], [-4.82835, -8.58373], [-3.99026, -7.0938], [-4.79479, -8.52408], [1.2612, 2.24213], [-1.47732, -2.62635], [-2.37882, -4.22902], [5.63391, 10.0158], [-3.78432, -6.72768], [3.91305, 6.95653], [2.03307, 3.61434], [-1.31562, -2.33889], [4.53371, 8.05994], [-1.29937, -2.31], [-1.28912, -2.29176], [-2.48572, -4.41906], [5.07525, 9.02267], [2.09392, 3.72253], [2.77783, 4.93836], [-3.70153, -6.5805], [-2.50533, -4.45393], [-4.05639, -7.21136], [-2.31959, -4.12372], [4.3372, 7.71058], [-3.62376, -6.44223], [-5.32155, -9.46054], [7.07438, 12.5767], [4.66828, 8.29916], [2.72017, 4.83586], [5.64977, 10.044], [4.72632, 8.40234], [-0.804916, -1.43096], [0.572876, 1.01845], [0.158197, 0.28124], [-5.1183, -9.09919], [-0.681255, -1.21112], [4.75635, 8.45573], [-5.17079, -9.19252], [-2.58365, -4.59316], [1.37852, 2.45069], [6.11361, 10.8686], [2.21926, 3.94535], [-3.15868, -5.61544], [4.10421, 7.29637], [0.409259, 0.727572], [4.26261, 7.57797], [3.36705, 5.98587], [-1.3174, -2.34205], [4.11403, 7.31384], [4.61404, 8.20273], [-1.843, -3.27644]];
|
||
|
|
||
|
assertEqualPoints(expected, pts);
|
||
|
}
|
||
|
|
||
|
test_in_shape();
|