Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clear all,close all;hold on;axis equal
- xA=0;yA=0;
- xB=-1;yB=-3;xC=5;yC=-4;
- %xB=-rand;yB=-rand;xC=rand;yC=-rand;
- Tr=[xA,xB,xC,xA;
- yA,yB,yC,yA];
- plot(Tr(1,:),Tr(2,:),'b');
- a=xB-xA;b=yB-yA;c=xC-xA;d=yC-yA;
- r=sqrt(3);
- for s=0:0.05:1
- N=2*(xC*yB-xB*yC) +(b*s+a*r*s)*(xB -xC)+(b*r*s-a*s)*(yB - yC);
- D=(c+d*r)*(yB-yC)+ (c*r-d)*(xB-xC) ;
- t=N/D;
- P=[(a*s + c*t - b*r*s + d*r*t)/2;(b*s + d*t + a*r*s - c*r*t)/2];
- Tequ=[P,s*[xB;yB],t*[xC;yC],P];
- if t>0 && t<1 && inpolygon(P(1),P(2),Tr(1,:),Tr(2,:))
- plot(Tequ(1,:),Tequ(2,:),'color',rand(1,3))
- end;
- end;
Add Comment
Please, Sign In to add comment