Andy Ross wrote: > Vivian Meazza wrote: > > I used the power form because it is easier to read, but if the other > > form produces a performance advantage, then of course we must use > > it. > > It's actually not so much about performance, really. Readability can > mean different things. The problem is that when I see a trancendental > function in code, I immediately start thinking that it much be some > complicated formula typed in from a book, as these things don't occur > in typical programmer's brains all that often. Basically, even though > in isolation it's easier to read "pow(foo, 3)" than "foo*foo*foo", > when you look at the whole expression, your original one is > "complicated" to me: > > (-0.25 * math::pow(rpm_norm,3)) + (-0.15 * math::pow(rpm_norm,2)) > + (1.11 * rpm_norm); > > Whereas this one is just really obviously a polynomial, and I > understand polynomials, they're simple and not scary at all: > > rpm_norm * (1.11 - rpm_norm * (0.15 * rpm_norm + 0.25)) > > I'll work up a version of the new one with the sign bug fixed, and try > to get that checked in tonight. >
Personally, I do find nested forms of programming scary, too easy to make mistakes. To reiterate, the correct equation is: y = -0.25x^3 + 0.15x^2 + 1.11x or y = ((-0.25x + 0.15)x + 1.11)x Thinking about the over-speed situation overnight, the Merlin was allowed to go to 3600 rpm for brief periods, and even then damage to the engine was possible. This is a normalised value of 1.2. The K Series will go to 9000 (don't try this on yours - it requires special valve lifters and crankshaft) or 1.28 normalised. The curve shown here: http://myweb.tiscali.co.uk/vmeazza/FlightGear/supercharge.pdf fits those numbers very nicely. I think we're there now with a nice model for a geared supercharger. I'm less happy with the rather crude model of the throttle, and will do some more work in due course. Thanks to everyone who has contributed to the maths and programming issues Regards, Vivian _______________________________________________ Flightgear-devel mailing list Flightgear-devel@flightgear.org http://mail.flightgear.org/mailman/listinfo/flightgear-devel 2f585eeea02e2c79d7b1d8c4963bae2d