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.

41 lines
1.2 KiB

3 years ago
%--------------------------
% @Author: Jingqiao Hu
% @Date: 2021-12-27 20:26:33
% @LastEditTime: 2021-12-30 18:12:48
%--------------------------
function conn_list = dt_connection(seeds)
DT = delaunayTriangulation(seeds);
tri_mesh = DT.ConnectivityList;
npnts = size(seeds, 1);
conn_list = cell(npnts, 1);
% figure; triplot(DT); hold on;
parfor i = 1 : npnts
[r, ~] = find(tri_mesh == i);
idx1 = tri_mesh(r, :);
idx2 = unique(idx1(:));
% remove i
conn_list{i} = idx2(idx2 ~= i);
% figure(1); clf; triplot(DT); hold on;
% voronoi(seeds(:,1), seeds(:,2)); hold on;
% scatter(seeds(i,1), seeds(i,2), 'filled'); hold on;
% scatter(seeds(conn_list{i},1), seeds(conn_list{i},2)); hold on;
% bp = [];
% poly_local = c_polys([conn_list{i}; i]);
% for testi = 1:size(poly_local, 1)
% bp = [bp; polyshape(poly_local{testi})];
% end
% hold on; plot(bp);
end
end
function [area] = tri_area(x, y)
area = 0.5 * ((x(:,1).* y(:,2) - x(:,2).*y(:,1)) + ...
(x(:,2).* y(:,3) - x(:,3).*y(:,2)) + ...
(x(:,3).* y(:,1) - x(:,1).*y(:,3)));
area = abs(area); % important!
end