Triangle math % Shows how ti.tn, ti.t_conn and ti.t_edge were calculated % Connectivity t = ti.t; for i=1:length(t) tn{i} = []; for j=1:size(t,2) [prow, pcol] = find(t==t(i,j)); tn{i} = [tn{i}, prow(find(prow ~= i))']; end tn{i} = unique(tn{i}); end ti.tn =tn; % Triangle connectivity matrix: t_conn=zeros(311,311) for i=1:length(tn), for j=1:length(tn{i}), t_conn(i,tn{i}(j)) = 1; t_conn(i,i) = 1; end;end ti.t_conn = t_conn; % Triangles on the outside of embryo: (i.e. find p on ellipse) p_max = round(max(p)); % Ellipse: x^2/a^2 + y^2/b^2 = 1 % -> p_calcy = abs(p(:,2)) - sqrt( (1 - p(:,1).^2/16) * 4); p_calcy = abs(p(:,2)) - sqrt( (1 - p(:,1).^2/p_max(1)^2) * p_max(2)^2); p_boundary = find(p_calcy < 0.001 & p_calcy > -0.001); for i=1:size(t,1), t_edge(i) = length(intersect(t(i,:), p_boundary)); end