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.
47 lines
1.2 KiB
47 lines
1.2 KiB
3 years ago
|
%--------------------------
|
||
|
% @Author: Jingqiao Hu
|
||
|
% @Date: 2021-12-29 20:23:06
|
||
|
% @LastEditTime: 2022-01-29 11:34:31
|
||
|
|
||
|
% for each voronoi edge
|
||
|
% update the MMC variables based on voronoi-edges
|
||
|
% [t, x1, y1, z1, x2, y2, z2];
|
||
|
%--------------------------
|
||
|
function MMC = update_MMCs(vedges, T, c_nnbSeedIDX)
|
||
|
|
||
|
%% MMC properties
|
||
|
nedge = size(vedges, 1);
|
||
|
Tedge = T_edge2seed(T, c_nnbSeedIDX, nedge);
|
||
|
MMC = [Tedge, vedges]; % [t, x1, y1, z1, x2, y2, z2];
|
||
|
|
||
|
%% the polytope of each MMC
|
||
|
% for i = 1:size(vedges, 1)
|
||
|
% p1 = vedges(i, 1:3);
|
||
|
% p2 = vedges(i, 4:6);
|
||
|
|
||
|
% %# a plane is a*x+b*y+c*z+d=0
|
||
|
% %# [a,b,c] is the normal. Thus, we have to calculate
|
||
|
% %# d and we're set
|
||
|
% n1 = p2 - p1;
|
||
|
% d1 = -p1 * n1'; %'# dot product for less typing
|
||
|
|
||
|
|
||
|
|
||
|
% n2 = p1 - p2;
|
||
|
% d2 = -p2 * n2'; %'# dot product for less typing
|
||
|
% end
|
||
|
end
|
||
|
|
||
|
% projection to width for each edge based on the distance to two neighbor seed
|
||
|
function Tedge = T_edge2seed(Tseed, c_nnbSeedIDX, nedge)
|
||
|
|
||
|
Tedge = zeros(nedge, 1);
|
||
|
|
||
|
parfor i = 1 : nedge
|
||
|
|
||
|
sid = c_nnbSeedIDX{i};
|
||
|
t = Tseed(sid); % 2*1
|
||
|
|
||
|
Tedge(i) = mean(t);
|
||
|
end
|
||
|
end
|