66 error(
" Incorrect number of inputs ")
69 error(
" Incorrect number of outputs ")
73 if (size(p,2)~=2) || (size(t,2)~=3) || (size(Hn,2)~=1)
74 error(
" Incorrect input dimensions ")
76 if size(p,1)~=size(Hn,1)
77 error(
" F and p must be the same length ")
79 if (max(
t(:))>size(p,1)) || (min(
t(:))<=0)
80 error(
" t is not a valid triangulation of p ")
82 if (size(N,1)>1) && (size(N,2)>1)
83 error(
" N cannot be a matrix ")
87 [e,eINt,e2t] = mkcon(p,t);
101 t1 =
t(:,1); t2 =
t(:,2); t3 =
t(:,3);
105 x23 = p(t2,1)-p(t3,1); y23 = p(t2,2)-p(t3,2);
106 x21 = p(t2,1)-p(t1,1); y21 = p(t2,2)-p(t1,2);
109 Htx = (y23.*Hn(t1) + (y21-y23).*Hn(t2) - y21.*Hn(t3)) ./ (x23.*y21-x21.*y23);
110 Hty = (x23.*Hn(t1) + (x21-x23).*Hn(t2) - x21.*Hn(t3)) ./ (y23.*x21-y21.*x23);
114 Hnx = 0*Hn; Hny = Hnx; count = Hnx;
117 n1 = t1(
k); n2 = t2(
k); n3 = t3(
k);
119 Hx = Htx(
k); Hy = Hty(
k);
121 Hnx(n1) = Hnx(n1)+Hx;
122 Hny(n1) = Hny(n1)+Hy;
123 count(n1) = count(n1)+1;
125 Hnx(n2) = Hnx(n2)+Hx;
126 Hny(n2) = Hny(n2)+Hy;
127 count(n2) = count(n2)+1;
129 Hnx(n3) = Hnx(n3)+Hx;
130 Hny(n3) = Hny(n3)+Hy;
131 count(n3) = count(n3)+1;
137 pt = (p(t1,:)+p(t2,:)+p(t3,:))/3;
140 Ht = ( Hn(t1) + (pt(:,1)-p(t1,1)).*Hnx(t1) + (pt(:,2)-p(t1,2)).*Hny(t1) + ...
141 Hn(t2) + (pt(:,1)-p(t2,1)).*Hnx(t2) + (pt(:,2)-p(t2,2)).*Hny(t2) + ...
142 Hn(t3) + (pt(:,1)-p(t3,1)).*Hnx(t3) + (pt(:,2)-p(t3,2)).*Hny(t3) )/3;
148 lev = linspace(max(Ht),min(Ht),N+1);
151 if (length(N)==2) && (N(1)==N(2))
186 if ~in(e2t(ce,1)) || ((e2t(ce,2)>0)&&~in(e2t(ce,2)))
201 numb = next-1; bnd(next:end) = [];
221 p1 = ( p(
t(t1,1),:)+p(
t(t1,2),:)+p(
t(t1,3),:) )/3;
231 H2(~ok) = ( Hn(e(i2,1))+Hn(e(i2,2)) )/2;
234 p2(ok,:) = ( p(
t(i1,1),:)+p(
t(i1,2),:)+p(
t(i1,3),:) )/3;
236 p2(~ok,:) = ( p(e(i2,1),:)+p(e(i2,2),:) )/2;
240 r = (lev(v)-H1)./(H2-H1);
241 penew = p1 + [r,r].*(p2-p1);
256 [c1,i] = sort(c1); c2 = c2(i);
281 if nargout > 0 &&
false
285 ndx = repmat(1,nume,1);
289 n1 = c1(
k); n2 = c2(
k);
291 n2e(n1,ndx(n1)) =
k; ndx(n1) = ndx(n1)+1;
292 n2e(n2,ndx(n2)) =
k; ndx(n2) = ndx(n2)+1;
296 bnde = bndn(c1)|bndn(c2);
300 tmpv = repmat(0,1,ncc);
311 x = tmpv; x(1) = penew(c1(ce),1);
312 y = tmpv; y(1) = penew(c1(ce),2);
319 x(next) = penew(cn,1);
320 y(next) = penew(cn,2);
331 if (ce==0)||(ce==start)||(flag(ce))
336 z = repmat(lev(v),1,next);
337 h = [h; patch(
" Xdata ",[x,NaN],
" Ydata ",[y,NaN],
" Zdata ",z, ...
338 " Cdata ",z,
" facecolor ",
" none ",
" edgecolor ",
" flat ")]; hold on
342 c = horzcat(c,[lev(v), x; next-1, y]);
355 for i = 1:length(edges)
367 x = tmpv; x(1) = penew(c2(ce),1);
368 y = tmpv; y(1) = penew(c2(ce),2);
372 x = tmpv; x(1) = penew(c1(ce),1);
373 y = tmpv; y(1) = penew(c1(ce),2);
392 z = repmat(lev(v),2,ncc)+.01*abs(lev(v));
394 h = [h; patch(
" Xdata ",[penew(c1,1),penew(c2,1)]^t, ...
395 " Ydata ",[penew(c1,2),penew(c2,2)]^t, ...
396 " Zdata ",z,
" Cdata ",z,
" Parent ",ax,varargin[:])];
423 e = [
t(:,[1,2]);
t(:,[2,3]);
t(:,[3,1])];
425 vec = (1:size(e,1))^t;
427 [e,j,j] = unique(sort(e,2),
" rows ");
431 eINt = [vec(vect), vec(vect+numt), vec(vect+2*numt)];
439 e2t = repmat(0,nume,2);
440 ndx = repmat(1,nume,1);
443 e1 = eINt(
k,1); e2 = eINt(
k,2); e3 = eINt(
k,3);
445 e2t(e1,ndx(e1)) =
k; ndx(e1) = ndx(e1)+1;
447 e2t(e2,ndx(e2)) =
k; ndx(e2) = ndx(e2)+1;
449 e2t(e3,ndx(e3)) =
k; ndx(e3) = ndx(e3)+1;
function [ cout , hout ] = tricontour(ax,double t, p, Hn, N, varargin)
function [ e , eINt , e2t ] = tricontour>mkcon(p,double t)
A variable number of input arguments.