This was pointed out in another thread in which I provided simple pseudocode that, in a more advanced form, could possibly be used to solve this and similar problems. If I could ever find my physics notes I will post a version of the code I have that also takes into account air pressures.