1
0
Fork 0

Maik JUSTUS: "small update to the tilt-rotor feature"

This commit is contained in:
mfranz 2007-06-16 07:22:47 +00:00
parent 6fc1a51e1d
commit 28da7c0a90
2 changed files with 23 additions and 5 deletions

View file

@ -141,6 +141,9 @@ Rotor::Rotor()
_tilt_yaw=0; _tilt_yaw=0;
_tilt_roll=0; _tilt_roll=0;
_tilt_pitch=0; _tilt_pitch=0;
_old_tilt_roll=0;
_old_tilt_pitch=0;
_old_tilt_yaw=0;
_min_tilt_yaw=0; _min_tilt_yaw=0;
_min_tilt_pitch=0; _min_tilt_pitch=0;
_min_tilt_roll=0; _min_tilt_roll=0;
@ -174,14 +177,16 @@ void Rotor::inititeration(float dt,float omegarel,float ddt_omegarel,float *rot)
_omega=_omegan*_omegarel; _omega=_omegan*_omegarel;
_ddt_omega=_omegan*ddt_omegarel; _ddt_omega=_omegan*ddt_omegarel;
int i; int i;
updateDirectionsAndPositions(); float drot[3];
updateDirectionsAndPositions(drot);
Math::add3(rot,drot,drot);
for(i=0; i<_rotorparts.size(); i++) { for(i=0; i<_rotorparts.size(); i++) {
float s = Math::sin(float(2*pi*i/_number_of_parts+(_phi-pi/2.)*(_ccw?1:-1))); float s = Math::sin(float(2*pi*i/_number_of_parts+(_phi-pi/2.)*(_ccw?1:-1)));
float c = Math::cos(float(2*pi*i/_number_of_parts+(_phi-pi/2.)*(_ccw?1:-1))); float c = Math::cos(float(2*pi*i/_number_of_parts+(_phi-pi/2.)*(_ccw?1:-1)));
Rotorpart* r = (Rotorpart*)_rotorparts.get(i); Rotorpart* r = (Rotorpart*)_rotorparts.get(i);
r->setOmega(_omega); r->setOmega(_omega);
r->setDdtOmega(_ddt_omega); r->setDdtOmega(_ddt_omega);
r->inititeration(dt,rot); r->inititeration(dt,drot);
r->setCyclic(_cyclicail*c+_cyclicele*s); r->setCyclic(_cyclicail*c+_cyclicele*s);
} }
@ -1029,10 +1034,19 @@ void Rotor::euler2orient(float roll, float pitch, float hdg, float* out)
} }
void Rotor::updateDirectionsAndPositions() void Rotor::updateDirectionsAndPositions(float *rot)
{ {
if (!_directions_and_postions_dirty) if (!_directions_and_postions_dirty)
{
rot[0]=rot[1]=rot[2]=0;
return; return;
}
rot[0]=_old_tilt_roll-_tilt_roll;
rot[1]=_old_tilt_pitch-_tilt_pitch;
rot[2]=_old_tilt_yaw-_tilt_yaw;
_old_tilt_roll=_tilt_roll;
_old_tilt_pitch=_tilt_pitch;
_old_tilt_yaw=_tilt_yaw;
float orient[9]; float orient[9];
euler2orient(_tilt_roll, _tilt_pitch, _tilt_yaw, orient); euler2orient(_tilt_roll, _tilt_pitch, _tilt_yaw, orient);
float forward[3]; float forward[3];
@ -1213,7 +1227,8 @@ void Rotor::compile()
rps[(i-_number_of_parts/4+_number_of_parts)%_number_of_parts], rps[(i-_number_of_parts/4+_number_of_parts)%_number_of_parts],
rps[(i+_number_of_parts/4)%_number_of_parts]); rps[(i+_number_of_parts/4)%_number_of_parts]);
} }
updateDirectionsAndPositions(); float drot[3];
updateDirectionsAndPositions(drot);
for (i=0;i<_number_of_parts;i++) for (i=0;i<_number_of_parts;i++)
{ {
rps[i]->setCompiled(); rps[i]->setCompiled();

View file

@ -36,6 +36,9 @@ private:
float _tilt_yaw; float _tilt_yaw;
float _tilt_roll; float _tilt_roll;
float _tilt_pitch; float _tilt_pitch;
float _old_tilt_roll;
float _old_tilt_pitch;
float _old_tilt_yaw;
public: public:
Rotor(); Rotor();
@ -99,7 +102,7 @@ public:
void setName(const char *text); void setName(const char *text);
void inititeration(float dt,float omegarel,float ddt_omegarel,float *rot); void inititeration(float dt,float omegarel,float ddt_omegarel,float *rot);
void compile(); void compile();
void updateDirectionsAndPositions(); void updateDirectionsAndPositions(float *rot);
void getTip(float* tip); void getTip(float* tip);
void calcLiftFactor(float* v, float rho, State *s); void calcLiftFactor(float* v, float rho, State *s);
void getDownWash(float *pos, float * v_heli, float *downwash); void getDownWash(float *pos, float * v_heli, float *downwash);