function s=calsegstr3da(MU, NU, b, r1, r2, r, a)
% s(3,3)=calsegstr3d2a(MU, NU, b(3), r1(3), r2(3), r(3), a)
% calls function calsegstrhor3da

r21=r2-r1;
rt=r-r1;

%make sure r21, rt, b are column vector
s1=size(r21); if(s1(1)==1) r21=r21'; end
s2=size(rt); if(s2(1)==1) rt=rt'; end
s3=size(b); if(s3(1)==1) b=b'; end

norm21=norm(r21);
if(norm(r21)<1e-20)
  s=zeros(3,3);
  return;
end

e1=r21/norm21;
e2=schmidt(rt,e1);

e3=cross(e1,e2);

e3=e3/norm(e3);

M=[e2,e3,e1];

Mt=M';

rr21=Mt*r21;
rr=Mt*rt;
br=Mt*b;

%br,rr
sr=calsegstrhor3da(MU,NU,br(1),br(2),br(3),0,rr21(3),rr(1),rr(3),a);
%sr=calsegstrhor3daold(MU,NU,br(1),br(2),br(3),0,rr21(3),rr(1),rr(3),a);

s=M*sr*Mt;
