+#include <ostream>
+
#include <simgear/debug/logstream.hxx>
#include "Math.hpp"
#include <stdio.h>
#include <string.h>
namespace yasim {
+using std::endl;
+
const float pi=3.14159;
float _help = 0;
Rotorpart::Rotorpart()
_rotor=rotor;
}
-void Rotorpart::setParameter(char *parametername, float value)
+void Rotorpart::setParameter(const char *parametername, float value)
{
#define p(a) if (strcmp(parametername,#a)==0) _##a = value; else
//angle between blade movement caused by rotor-rotation and the
//total movement of the blade
- /* the next shold look like this, but this is the inner loop of
- the rotor simulation. For small angles (and we hav only small
- angles) the first order approximation works well
lift_moment += r*(lift * Math::cos(angle)
- drag * Math::sin(angle));
*torque += r*(drag * Math::cos(angle)
+ lift * Math::sin(angle));
- */
- lift_moment += r*(lift * (1-angle*angle)
- - drag * angle);
- *torque += r*(drag * (1-angle*angle)
- + lift * angle);
-
if (returnlift!=NULL) *returnlift+=lift;
}
- //as above, use 1st order approximation
+ //use 1st order approximation for alpha
//float alpha=Math::atan2(lift_moment,_centripetalforce * _len);
float alpha;
if (_shared_flap_hinge)
if (Math::abs(_alphaalt) >1e-6)
div=(_centripetalforce * _len - _mass * _len * 9.81 * relgrav /_alpha0*(_alphaalt+_oppositerp->getAlphaAlt())/(2.0*_alphaalt));
if (Math::abs(div)>1e-6)
+ {
alpha=lift_moment/div;
+ }
else if(Math::abs(_alphaalt+_oppositerp->getAlphaAlt())>1e-6)
{
float div=(_centripetalforce * _len - _mass * _len * 9.81 *0.5 * relgrav)*(_alphaalt+_oppositerp->getAlphaAlt());
if (Math::abs(div)>1e-6)
+ {
alpha=_oppositerp->getAlphaAlt()+lift_moment/div*_alphaalt;
+ }
+ else
+ alpha=_alphaalt;
}
else
alpha=_alphaalt;
+ if (_omega/_omegan<0.2)
+ {
+ float frac = 0.001+_omega/_omegan*4.995;
+ alpha=Math::clamp(alpha,_alphamin,_alphamax);
+ alpha=_alphaalt*(1-frac)+frac*alpha;
+ }
}
else
{