From 28da7c0a904cba0ecb69d93882e7e62d01e315c3 Mon Sep 17 00:00:00 2001 From: mfranz Date: Sat, 16 Jun 2007 07:22:47 +0000 Subject: [PATCH] Maik JUSTUS: "small update to the tilt-rotor feature" --- src/FDM/YASim/Rotor.cpp | 23 +++++++++++++++++++---- src/FDM/YASim/Rotor.hpp | 5 ++++- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/FDM/YASim/Rotor.cpp b/src/FDM/YASim/Rotor.cpp index bdc3aa62c..ebda4875e 100644 --- a/src/FDM/YASim/Rotor.cpp +++ b/src/FDM/YASim/Rotor.cpp @@ -141,6 +141,9 @@ Rotor::Rotor() _tilt_yaw=0; _tilt_roll=0; _tilt_pitch=0; + _old_tilt_roll=0; + _old_tilt_pitch=0; + _old_tilt_yaw=0; _min_tilt_yaw=0; _min_tilt_pitch=0; _min_tilt_roll=0; @@ -174,14 +177,16 @@ void Rotor::inititeration(float dt,float omegarel,float ddt_omegarel,float *rot) _omega=_omegan*_omegarel; _ddt_omega=_omegan*ddt_omegarel; int i; - updateDirectionsAndPositions(); + float drot[3]; + updateDirectionsAndPositions(drot); + Math::add3(rot,drot,drot); 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 c = Math::cos(float(2*pi*i/_number_of_parts+(_phi-pi/2.)*(_ccw?1:-1))); Rotorpart* r = (Rotorpart*)_rotorparts.get(i); r->setOmega(_omega); r->setDdtOmega(_ddt_omega); - r->inititeration(dt,rot); + r->inititeration(dt,drot); 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) + { + rot[0]=rot[1]=rot[2]=0; 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]; euler2orient(_tilt_roll, _tilt_pitch, _tilt_yaw, orient); 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]); } - updateDirectionsAndPositions(); + float drot[3]; + updateDirectionsAndPositions(drot); for (i=0;i<_number_of_parts;i++) { rps[i]->setCompiled(); diff --git a/src/FDM/YASim/Rotor.hpp b/src/FDM/YASim/Rotor.hpp index 8a27a465c..817367f78 100644 --- a/src/FDM/YASim/Rotor.hpp +++ b/src/FDM/YASim/Rotor.hpp @@ -36,6 +36,9 @@ private: float _tilt_yaw; float _tilt_roll; float _tilt_pitch; + float _old_tilt_roll; + float _old_tilt_pitch; + float _old_tilt_yaw; public: Rotor(); @@ -99,7 +102,7 @@ public: void setName(const char *text); void inititeration(float dt,float omegarel,float ddt_omegarel,float *rot); void compile(); - void updateDirectionsAndPositions(); + void updateDirectionsAndPositions(float *rot); void getTip(float* tip); void calcLiftFactor(float* v, float rho, State *s); void getDownWash(float *pos, float * v_heli, float *downwash);