📄 tri2adj.m
字号:
function A = tri2adj(T)
%TRI2ADJ Triangle indices to adjacency matrix representation.
% A = tri2adj(T)
% T = n x 3 matrix, where each row defines indices for one of n
% triangles
% A = (sparse) m x m adjacency matrix, m is the maximum index value
%
% Converts set of triangles defined by X and Y vector indices into A.
% Useful for ploting results from DELAUNAY triangulation using GPLOT.
%
% See also CONVHULL and DSEARCH
% Copyright (c) 1994-2006 by Michael G. Kay
% Matlog Version 9 13-Jan-2006 (http://www.ie.ncsu.edu/kay/matlog)
% Input Error Checking ****************************************************
if size(T,2) ~= 3
error('"T" must be an n x 3 matrix of triangle indices.')
end
% End (Input Error Checking) **********************************************
m = max(T(:));
A = sparse(m,m);
for i = 1:length(T(:,1))
A(T(i,1),T(i,2)) = 1;
A(T(i,2),T(i,3)) = 1;
A(T(i,3),T(i,1)) = 1;
end
A = A | triu(A)' | tril(A)';
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -