-
Notifications
You must be signed in to change notification settings - Fork 2
/
sphbary_setup.m
71 lines (59 loc) · 1.43 KB
/
sphbary_setup.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
function [c,intfacetIDs] = sphbary_setup(pts,facetPtIDs,data,tol)
% SPHBARY_SETUP sphbary coords and intersections for points
%--------------------------------------------------------------------------
% Author: Sterling Baird
%
% Date:
%
% Description:
%
% Inputs:
%
% Outputs:
%
% Dependencies:
%
%--------------------------------------------------------------------------
%initialize
nfacets = size(facetPtIDs,1);
posQ = false(nfacets,1);
c = zeros(nfacets,size(data,2));
%disable warnings
warnID1 = 'MATLAB:nearlySingularMatrix';
warnID2 = 'MATLAB:singularMatrix';
warnID3 = 'symbolic:mldivide:InconsistentSystem';
warning('off',warnID1)
warning('off',warnID2)
warning('off',warnID3)
%loop through facets
for i = 1:nfacets
idtemp = facetPtIDs(i,:);
vertices = pts(idtemp,:);
[c(i,:),Pnew] = sphbary(data,vertices);
%check if spherical barycentric coordinate reqs are met
posbaryQ = (sum(c(i,:)) >= 1-tol) && all(c(i,:) >= -tol);
if posbaryQ
%enable warnings
warning('on',warnID1)
warning('on',warnID2)
warning('on',warnID3)
sphbary(data,vertices,Pnew);
lstwarn = warning('query','last');
if ~strcmp(lstwarn,{warnID1,warnID2,warnID3})
posQ(i) = true; %position Q, true == intersecting facet
end
end
end
%enable warnings
warning('on',warnID1)
warning('on',warnID2)
warning('on',warnID3)
%find intersecting facet IDs
if sum(posQ) > 0
intfacetIDs = find(posQ);
c = c(posQ,:);
else
intfacetIDs = [];
c = [];
end
end