a2b69e4Initial commitJeremy Magland 1% mip package demo: installs the inpoly package (point-in-polygon test)
2% from the mip registry (https://mip.sh) on first run, then reuses the
3% cached install. See https://mip.sh for available packages.
4mip load --install inpoly
6% a star-shaped polygon
7k = (0:9)';
8r = 1 + 0.6 * (-1).^k;
9node = [r .* cos(pi/5 * k + pi/2), r .* sin(pi/5 * k + pi/2)];
11% classify random points
12rng(42);
13pts = 4 * rand(2000, 2) - 2;
14inside = inpoly2(pts, node);
15fprintf('points inside: %d / %d\n', sum(inside), length(inside));
17figure;
18plot(pts(inside, 1), pts(inside, 2), '.');
19hold on;
20plot(pts(~inside, 1), pts(~inside, 2), '.');
21plot([node(:, 1); node(1, 1)], [node(:, 2); node(1, 2)]);
22hold off;
23axis equal;
24title('inpoly2: points inside a star');
25legend('inside', 'outside', 'polygon');