function [c,fr]=plotsp(phid,thd,s,sflag,str,str1,varargin);
%sflag =0, no hidden lines =1 dashed hidden lines, =2 solid hidden lines 
%G. Vinnicombe. original version 1993, updated for Matlab 5 Oct 1998

if nargin<4;sflag=1;end
if nargin<5;str='k-';end
if nargin<6 & strcmp(str,'k--');str1='k:';else;str1='k--';end
r=.5;th=thd/180*pi;phi=phid/180*pi;
x=s(:,1);y=s(:,2);z=s(:,3);
xh=cos(phi)*x+sin(phi)*y;
y=cos(phi)*y-sin(phi)*x;
x=xh;
h=z*cos(th)+y*sin(th)+r*(1-cos(th));
fr=(y-(z-r)*sin(th))<0 | abs(x+j*h-.5*j)>.5; fr=2*fr-1;
l=find(abs(diff(fr))>0);
l=[0;l;length(fr)];

if sflag==2
  plot(x+j*h, str, varargin{:});
else
  for i=1:length(l)-1;
	k=l(i)+1:l(i+1);	
	if fr(k(1))<0 & sflag==1;
	  plot(x(k)+j*h(k),str1, varargin{:});
    end
	if fr(k(1))>0
	  plot(x(k)+j*h(k),str, varargin{:});
	end
  end
end
c=x+j*h;






