Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function [status, newSpacecraft] = fuelCheck(spacecraft, newOrbitalHeight)
- F = spacecraft.engine;
- m = spacecraft.mass;
- a = F/m;
- [changeVelocity1,changeVelocity2] = hohmann(spacecraft.orbit, newOrbitalHeight);
- time = (abs(changeVelocity1) + abs(changeVelocity2))/(a);
- energy = F*m*time;
- if energy > spacecraft.fuel
- status = 0;
- else
- status = 1;
- end
- if status == 1
- newSpacecraft.fuel = spacecraft.fuel - energy;
- newSpacecraft.orbit = newOrbitalHeight;
- newSpacecraft.mass = spacecraft.mass;
- newSpacecraft.engine = spacecraft.engine;
- else
- newSpacecraft = spacecraft;
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement