src/FDM/YASim/: added optional quadratic term spring2
to gear spring equation.
In YASim XML <gear>, `spring2` is a new dimensionless term. Default value zero is backwards compatible. The new spring force equation is: force = _spring * compression * (_frac + spring2 * _frac**2) This is intended to help with https://sourceforge.net/p/flightgear/codetickets/1509.
This commit is contained in:
parent
4fbea9871d
commit
87029295c1
3 changed files with 9 additions and 1 deletions
|
@ -1090,6 +1090,7 @@ void FGFDM::parseGear(const XMLAttributes* a)
|
|||
g->setStaticFriction(attrf(a, "sfric", 0.8));
|
||||
g->setDynamicFriction(attrf(a, "dfric", 0.7));
|
||||
g->setSpring(attrf(a, "spring", 1));
|
||||
g->setSpring2(attrf(a, "spring2", 0));
|
||||
g->setDamping(attrf(a, "damp", 1));
|
||||
if(a->hasAttribute("on-water")) g->setOnWater(attrb(a,"on-water"));
|
||||
if(a->hasAttribute("on-solid")) g->setOnSolid(attrb(a,"on-solid"));
|
||||
|
|
|
@ -53,6 +53,7 @@ Gear::Gear()
|
|||
for(i=0; i<3; i++)
|
||||
_pos[i] = _stuck[i] = 0;
|
||||
_spring = 1;
|
||||
_spring2 = 0;
|
||||
_damp = 0;
|
||||
_sfric = 0.8f;
|
||||
_dfric = 0.7f;
|
||||
|
@ -501,7 +502,11 @@ void Gear::calcForce(Ground *g_cb, RigidBody* body, State *s, float* v, float* r
|
|||
frac_with_initial_load = (_frac+_initialLoad)
|
||||
*_frac*_frac*3*25-_frac*_frac*_frac*2*125;
|
||||
|
||||
float fmag = frac_with_initial_load*clen*_spring;
|
||||
float fmag = clen * _spring *
|
||||
(
|
||||
frac_with_initial_load
|
||||
+ _spring2 * pow( frac_with_initial_load, 2)
|
||||
);
|
||||
if (_speed_planing>0)
|
||||
{
|
||||
float v = Math::mag3(cv);
|
||||
|
|
|
@ -67,6 +67,7 @@ public:
|
|||
|
||||
void setSpring(float spring) { _spring = spring; }
|
||||
float getSpring() { return _spring; }
|
||||
void setSpring2(float spring2) { _spring2 = spring2; }
|
||||
void setDamping(float damping) { _damp = damping; }
|
||||
float getDamping() {return _damp; }
|
||||
void setStaticFriction(float sfric) { _sfric = sfric; }
|
||||
|
@ -142,6 +143,7 @@ private:
|
|||
double _stuck[3] = {0};
|
||||
GearVector _cmpr;
|
||||
float _spring = 0;
|
||||
float _spring2 = 0;
|
||||
float _damp = 0;
|
||||
float _sfric = 0;
|
||||
float _dfric = 0;
|
||||
|
|
Loading…
Reference in a new issue