You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

31 lines
1.1 KiB

%--------------------------
% @Author: Jingqiao Hu
% @Date: 2021-12-29 17:39:18
% @LastEditTime: 2022-01-06 11:48:44
% get all the edges and cutted edges by the bounding box
%--------------------------
function saved_segs = voronoi_edges(seeds, boundarys, maxx, minx, maxy, miny)
[vx, vy] = voronoi(seeds(:,1), seeds(:,2));
vx = vx';
vy = vy';
segs = [vx(:,1), vy(:,1), vx(:,2), vy(:,2)];
edges = [segs; boundarys];
cutted = splitEdges(edges);
% cutted = uniquetol(cutted, 'ByRows', true );
[r1, ~] = find( (cutted(:, 1) > maxx) | (cutted(:, 1) < minx) | ...
(cutted(:, 2) > maxy) | (cutted(:, 2) < miny) | ...
(cutted(:, 3) > maxx) | (cutted(:, 3) < minx) | ...
(cutted(:, 4) > maxy) | (cutted(:, 4) < miny) );
[r2, ~] = find( abs(cutted(:, 1) - (cutted(:, 3))) < 1e-5 & ...
abs(cutted(:, 2) - (cutted(:, 4))) < 1e-5);
saved_idx = setdiff(1 : size(cutted, 1), [r1; r2]);
saved_segs = cutted(saved_idx, :);
% figure; drawEdge( saved_segs, 'linewidth', 3 ); axis equal;
end