Guest User

Untitled

a guest
Jan 23rd, 2018
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. clear all,close all;hold on;axis equal
  2. xA=0;yA=0;
  3. xB=-1;yB=-3;xC=5;yC=-4;
  4. %xB=-rand;yB=-rand;xC=rand;yC=-rand;
  5. Tr=[xA,xB,xC,xA;
  6. yA,yB,yC,yA];
  7. plot(Tr(1,:),Tr(2,:),'b');
  8. a=xB-xA;b=yB-yA;c=xC-xA;d=yC-yA;
  9. r=sqrt(3);
  10. for s=0:0.05:1
  11. N=2*(xC*yB-xB*yC) +(b*s+a*r*s)*(xB -xC)+(b*r*s-a*s)*(yB - yC);
  12. D=(c+d*r)*(yB-yC)+ (c*r-d)*(xB-xC) ;
  13. t=N/D;
  14. P=[(a*s + c*t - b*r*s + d*r*t)/2;(b*s + d*t + a*r*s - c*r*t)/2];
  15. Tequ=[P,s*[xB;yB],t*[xC;yC],P];
  16. if t>0 && t<1 && inpolygon(P(1),P(2),Tr(1,:),Tr(2,:))
  17. plot(Tequ(1,:),Tequ(2,:),'color',rand(1,3))
  18. end;
  19. end;
Add Comment
Please, Sign In to add comment