On Mon, 2007-02-12 at 11:33 -0500, John Denker wrote: > Overnight I thought of a non-disgusting way to optimize > the code. A new, muuuch better patch is now at: > http://www.av8n.com/fly/fgfs/altimeter.diff > > The new patch gets the right answer without calling any > transcendental functions.
This looks really slick, taking advantage of the identical form for the pressure altitude term and the C(S) term in equation (15) so you can interpolate both terms with only one table. Slick! > > Also its range of validity has been extended to >100,000 feet. This confuses me?? The approximation did not change from your last patch, only the fact that you use interpolation to replace the two calls of pow(). Last night you posted a total rejection of this when I suggested using PA which is correctly available from the encoder and an interpolation of C(S). > > > Have you thought of just using the C > > term in equation (15) and PA = pressure altitude which is already > being > > computed. That would only require one call to pow(). Or since > > > > C = ( hi offset from PA) > > > > only varies with S, compute a replacement table for delta h in terms > of > > S and interpolate that table. Then current hi = PA + interp(S). > > I considered that, but: > > 1) It's only a factor-of-two improvement, and > > 2) This code ought not exist at all. > > It's hard for me to get excited about optimizing something that > needs to be thrown out and redesigned. > > It does not make sense for altimeter.cxx to be implementing its > own model of the atmosphere; > Do you agree that you are still computing current hi = PA - C(S) except that you use interpolation in a very slick way for both terms? Or am I misreading the new patch? If my interpretation is correct, then what changed your mind so this code should exist, etc.? Also, why is this patch good above the troposphere (> 100,000 ft.)? It should give the same answer as the last patch, only much more efficiently. As was pointed out, once you are above the "transition zone", S = 29.92 and C(S) = 0. How about an "if" to avoid the second interpolation in this case? I am glad you changed your mind! When will you put this in cvs? Regards, Dave -- Dave Perry <[EMAIL PROTECTED]> ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier. Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Flightgear-devel mailing list Flightgear-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/flightgear-devel