Advertisement
Guest User

Untitled

a guest
Jan 18th, 2020
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. function [Distance2target1, Distance2target2,Distance2target3 ] = Distance2target3(Position,Target1Location,Target2Location,Target3Location)
  2.  
  3. if nargin == 0
  4. Position = [1, 4, 7];
  5. Target1Location = [12, 55, 29];
  6. Target2Location = [55, 42, 75];
  7. Target3Location = [55, 42, 75];
  8. end
  9.  
  10. p = Position;
  11. At1 = Target1Location; % arrival to target
  12. t1 = Target2Location; % target
  13. Dt1 = Target3Location; % departure from target
  14. Distance2target1 = sqrt((At1(1)-p(1))^2+(At1(2)-p(2))^2+(At1(3)-p(3))^2);
  15. Distance2target2 = sqrt((t1(1)-p(1))^2+(t1(2)-p(2))^2+(t1(3)-p(3))^2);
  16. Distance2target3 = sqrt((Dt1(1)-p(1))^2+(Dt1(2)-p(2))^2+(Dt1(3)-p(3))^2);
  17. % Distance2target1 = D1;
  18. % Distance2target2 = D2;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement