I’m moving through the atmosphere with Microsoft Virtual Earth 3D and I can descend smoothly, but I don’t know the math to ascend smoothly.
I’m descending like this:
for(int curAlt = startAlt; curAlt < endAlt; curAlt--){ //do something curAlt -= curAlt/150 }
This works by decreasing the size of the jump the closer I get to the earth (lower altitude). I need a solution that would do similar, just in reverse, while still keeping the smaller jumps at the lower altitude.
How can I do this? Or is what I am doing unacceptable and should be done differently (say with logarithms)?
An even better solution might be to use a function like the Logistic function.
Because the current altitude is explicitly calculated you do not have to rely on a iterative calculation introducing all sorts of precision releated errors.
See the sample code for how to tune the function shape.
Here is a sample console application that displays the function. You can play a bit with the parameters to get a feeling for the behavior.