image thumbnail
[t]=findt(x,y,yplane)
function [t]=findt(x,y,yplane)
%
% [t]=findt(x,y,yplane)
% ~~~~~~~~~~~~~~~~~~~~~
% This function calculates the thickness
% at a plane previously used to clip a
% polygon. 
%
% x      - vector of area x coordinates
% y      - vector of area y coordinates 
% yplane - the y coordinate which defines
%          the elevation where the thickness
%          is found.  This should the plane
%          previously used by the clipping
%          algorithm for clipping.
%
% t      - thickness
% 
% User m functions called:  none
%----------------------------------------------

Epsilon=1.0e-8; % Value for determining zero
t=0; Npts=length(x); 
for i=1:Npts
  j=i+1;
  if i == Npts, j=1; end;
  testi=abs(y(i)-yplane);
  testj=abs(y(j)-yplane);
  if (testi < Epsilon) & (testj < Epsilon)
    t=t+(x(j)-x(i));
  end
end

Contact us at files@mathworks.com