Advertisement
Guest User

Untitled

a guest
Nov 16th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. function [status, newSpacecraft] = fuelCheck(spacecraft, newOrbitalHeight)
  2.  
  3. F = spacecraft.engine;
  4. m = spacecraft.mass;
  5. a = F/m;
  6.  
  7. [changeVelocity1,changeVelocity2] = hohmann(spacecraft.orbit, newOrbitalHeight);
  8. time = (abs(changeVelocity1) + abs(changeVelocity2))/(a);
  9.  
  10. energy = F*m*time;
  11.  
  12. if energy > spacecraft.fuel
  13. status = 0;
  14. else
  15. status = 1;
  16. end
  17.  
  18. if status == 1
  19. newSpacecraft.fuel = spacecraft.fuel - energy;
  20. newSpacecraft.orbit = newOrbitalHeight;
  21. newSpacecraft.mass = spacecraft.mass;
  22. newSpacecraft.engine = spacecraft.engine;
  23. else
  24. newSpacecraft = spacecraft;
  25. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement