Lunar Lander bug?
|
06-10-2014, 09:02 PM
Post: #1
|
|||
|
|||
Lunar Lander bug?
I was playing with the lunar lander game on my 29C and took a look at the source code. I can't figure out the terminal velocity calculation and I was wondering if someone could walk me through it. The program is here.
Lines 46-50 indicate that a burn b accelerates the craft by a=2b-5. This indicates that gravity is -5. It's also easy to deduce that each burn lasts 1 second. So when you burn the last of the fuel, what is the crash velocity? To figure this out, recognize that you get a 1 second burn consisting of the all the fuel (a=2b-5), followed by a free fall that ends in a crash landing (a=-5). Using the equations provided: \begin{equation}a_0=2b-5\\ v_1 = v_0+a_0t = v_0+2b-5\\ x_1 = x_0+v_0t+\frac{1}{2}a_0t^2 = x_0+v_0+b-2.5\\ v_f^2 = v_1^2 + 2a_1(x_f-x_1) = v_1^2 + 2a_1(0-x_1) = v_1^2+2*(-5)*(-x_1)\\ v_f = -\sqrt{v_1^2+10x_1}\end{equation} Lines 41-44 compare the burn amount to the remaining fuel. If you're burning the last of the fuel it goes to label 6 at line 68. Lines 69-74 add b-2.5 to x Lines 75-77 add 2b-5 to v Lines 78-86 compute vf from x I don't understand lines 69-74. It seems to me that it should subtract v from x also. Am I missing something or is this a bug? Thanks, Dave |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
Lunar Lander bug? - David Hayden - 06-10-2014 09:02 PM
RE: Lunar Lander bug? - Thomas Klemm - 06-11-2014, 07:28 AM
|
User(s) browsing this thread: 1 Guest(s)