Sign in to follow this  
Guest Patrick_Waugh

Damping - Warning heavy math.

Recommended Posts

Well, I figured out what my problem was with earlier code. Turns out it was a variable not getting set like it should.So, now with a new object all programed, I have reduced my callback function to this:FLOAT64 FSAPI Attitude_Bank_cb(PELEMENT_SPRITE pelement){ return gyroAttitude.getBank();}which is handy. The Gyro takes care of all the gritty details:class Gyro{public: Gyro(string gyroName, GAUGE_TOKEN pitchToken, double pitchLimit, double pitchDamper, GAUGE_TOKEN bankToken, double bankLimit, double bankDamper, GAUGE_TOKEN yawToken, double yawLimit, double yawDamper); string getGyroName(); bool isGyroPowerOn(); void toggleGyroPower(); FLOAT64 getPitch(); FLOAT64 getBank(); FLOAT64 getYaw();private: FLOAT64 Gyro::dampened(double &axis, double goal, double damp_factor); bool gyroPowerOn; string name; double pitch; double bank; double yaw; MODULE_VAR goal_pitch; MODULE_VAR goal_bank; MODULE_VAR goal_yaw; double limit_pitch; double limit_bank; double limit_yaw; double damp_pitch; double damp_bank; double damp_yaw;};Now, after looking more closely at the dampening formula, we get a graph like the blue below. What I really need is something more like the red with a gradual falloff to asomptote.http://forums.avsim.net/user_files/152469.jpgI am, however, not the math guru. Any ideas? Maybe I could do a web search on logrythmic functions or something.Patrick

Share this post


Link to post
Share on other sites
Help AVSIM continue to serve you!
Please donate today!

Looks like you're trying to simulate an object with mass that is undergoing constant acceleration. Try something like this:bank=28speed=0in each time step: speed=speed+0.05 bank=bank-speedYou'll almost certainly have to tweak the 0.05 -- it's just a wild guess. The other question is what you want to do when you hit zero... but maybe you can come up with suitable logic for that yourself...HTHMartin

Share this post


Link to post
Share on other sites

Hi,In this case I think you could try a 2nd/3rd order polinomial, use Excel to find the formula.Tom

Share this post


Link to post
Share on other sites

Tom,Yes, I too think I'm probably looking for a such a polynomial. I'll keep experimenting in Excel.Thanks for the thoughts.Patrick

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this