]> git.mxchange.org Git - flightgear.git/blob - src/FDM/YASim/Rotor.hpp
Maik JUSTUS: "further (final?) modifications for the jet ranger rotor"
[flightgear.git] / src / FDM / YASim / Rotor.hpp
1 #ifndef _ROTOR_HPP
2 #define _ROTOR_HPP
3
4 #include "Vector.hpp"
5 #include "Rotorpart.hpp"
6 #include "Integrator.hpp"
7 #include "RigidBody.hpp"
8 #include "BodyEnvironment.hpp"
9
10 namespace yasim {
11
12 class Surface;
13 class Rotorpart;
14 class Ground;
15 const float rho_null=1.184f; //25DegC, 101325Pa
16
17 class Rotor {
18     friend std::ostream &  operator<<(std::ostream & out, /*const*/ Rotor& r);
19 private:
20     float _torque;
21     float _omega,_omegan,_omegarel,_ddt_omega,_omegarelneu;
22     float _phi_null;
23     float _chord;
24     float _taper;
25     float _airfoil_incidence_no_lift;
26     float _collective;
27     float _airfoil_lift_coefficient;
28     float _airfoil_drag_coefficient0;
29     float _airfoil_drag_coefficient1;
30     int _ccw;
31     int _number_of_blades;
32     int _number_of_segments;
33     int _number_of_parts;
34
35 public:
36     Rotor();
37     ~Rotor();
38
39     // Rotor geometry:
40     void setNormal(float* normal);
41     //the normal vector (direction of rotormast, pointing up)
42
43     void setForward(float* forward);
44     //the normal vector pointing forward (for ele and ail)
45     void setForceAtPitchA(float force);
46     void setPowerAtPitch0(float value);
47     void setPowerAtPitchB(float value);
48     void setNotorque(int value);
49     void setPitchA(float value);
50     void setPitchB(float value);
51     void setMinCyclicail(float value);
52     void setMinCyclicele(float value);
53     void setMaxCyclicail(float value);
54     void setMaxCyclicele(float value);
55     void setMaxCollective(float value);
56     void setMinCollective(float value);
57     void setDiameter(float value);
58     void setWeightPerBlade(float value);
59     void setNumberOfBlades(float value);
60     void setRelBladeCenter(float value);
61     void setDelta3(float value);
62     void setDelta(float value);
63     void setDynamic(float value);
64     void setTranslift(float value);
65     void setC2(float value);
66     void setStepspersecond(float steps);
67     void setRPM(float value);
68     void setPhiNull(float value);
69     void setRelLenHinge(float value);
70     void setBase(float* base);        // in local coordinates
71     void getPosition(float* out);
72     void setCyclicail(float lval,float rval);
73     void setCyclicele(float lval,float rval);
74     void setCollective(float lval);
75     void setAlphaoutput(int i, const char *text);
76     void setCcw(int ccw);
77     int getCcw() {return _ccw;};
78     void setParameter(char *parametername, float value);
79     void setGlobalGround(double* global_ground, float* global_vel);
80     float getTorqueOfInertia();
81     int getValueforFGSet(int j,char *b,float *f);
82     void setName(const char *text);
83     void inititeration(float dt,float omegarel,float ddt_omegarel,float *rot);
84     void compile();
85     void getTip(float* tip);
86     void calcLiftFactor(float* v, float rho, State *s);
87     void getDownWash(float *pos, float * v_heli, float *downwash);
88     int getNumberOfBlades(){return _number_of_blades;}
89
90     // Query the list of Rotorpart objects
91     int numRotorparts();
92     Rotorpart* getRotorpart(int n);
93     void setAlpha0(float f);
94     void setAlphamin(float f);
95     void setAlphamax(float f);
96     void setTeeterdamp(float f);
97     void setMaxteeterdamp(float f);
98     void setRelLenTeeterHinge(float value);
99     void setAlpha0factor(float f);
100     void setTorque(float f);
101     void addTorque(float f);
102     float getTorque() {return _torque;}
103     float getLiftFactor();
104     float getLiftCoef(float incidence,float speed);
105     float getDragCoef(float incidence,float speed);
106     float getOmegaRel() {return _omegarel;}
107     float getOmegaRelNeu() {return _omegarelneu;}
108     void setOmegaRelNeu(float orn) {_omegarelneu=orn;}
109     float getOmegan() {return _omegan;}
110     float getTaper() { return _taper;}
111     float getChord() { return _chord;}
112     int getNumberOfParts() { return _number_of_parts;}
113     float getOverallStall() 
114         {if (_stall_v2sum !=0 ) return _stall_sum/_stall_v2sum; else return 0;}
115     float getAirfoilIncidenceNoLift() {return _airfoil_incidence_no_lift;}
116     Vector _rotorparts;
117     void findGroundEffectAltitude(Ground * ground_cb,State *s);
118     float *getGravDirection() {return _grav_direction;}
119     void writeInfo();
120     void setSharedFlapHinge(bool s);
121
122 private:
123     void strncpy(char *dest,const char *src,int maxlen);
124     void interp(float* v1, float* v2, float frac, float* out);
125     float calcStall(float incidence,float speed);
126     float findGroundEffectAltitude(Ground * ground_cb,State *s,
127         float *pos0,float *pos1,float *pos2,float *pos3,
128         int iteration=0,float a0=-1,float a1=-1,float a2=-1,float a3=-1);
129     Rotorpart* newRotorpart(float* pos, float *posforceattac, float *normal,
130         float* speed,float *dirzentforce, float zentforce,float maxpitchforce,
131         float delta3,float mass,float translift,float rellenhinge,float len);
132     float _base[3];
133     float _groundeffectpos[4][3];
134     float _ground_effect_altitude;
135     //some postions, where to calcualte the ground effect
136     float _normal[3];//the normal vector (direction of rotormast, pointing up)
137     float _normal_with_yaw_roll[3];//the normal vector (perpendicular to rotordisc)
138     float _forward[3];
139     float _diameter;
140     float _weight_per_blade;
141     float _rel_blade_center;
142     float _min_pitch;
143     float _max_pitch;
144     float _force_at_pitch_a;
145     float _pitch_a;
146     float _power_at_pitch_0;
147     float _power_at_pitch_b;
148     int _no_torque;
149     int _sim_blades;
150     float _pitch_b;
151     float _rotor_rpm;
152     float _rel_len_hinge;
153     float _maxcyclicail;
154     float _maxcyclicele;
155     float _mincyclicail;
156     float _mincyclicele;
157     float _delta3;
158     float _delta;
159     float _dynamic;
160     float _translift;
161     float _c2;
162     float _stepspersecond;
163     char _alphaoutput[8][256];
164     char _name[256];
165     int _engineon;
166     float _alphamin,_alphamax,_alpha0,_alpha0factor;
167     float _teeterdamp,_maxteeterdamp;
168     float _rellenteeterhinge;
169     float _translift_ve;
170     float _translift_maxfactor;
171     float _ground_effect_constant;
172     float _vortex_state_lift_factor;
173     float _vortex_state_c1;
174     float _vortex_state_c2;
175     float _vortex_state_c3;
176     float _vortex_state_e1;
177     float _vortex_state_e2;
178     float _vortex_state_e3;
179     float _lift_factor,_f_ge,_f_vs,_f_tl;
180     float _vortex_state;
181     double _global_ground[4];
182     float _liftcoef;
183     float _dragcoef0;
184     float _dragcoef1;
185     float _twist; //outer incidence = inner inner incidence + _twist
186     float _rel_len_where_incidence_is_measured;
187     float _torque_of_inertia;
188     float _rel_len_blade_start;
189     float _incidence_stall_zero_speed;
190     float _incidence_stall_half_sonic_speed;
191     float _lift_factor_stall;
192     float _stall_change_over;
193     float _drag_factor_stall;
194     float _stall_sum;
195     float _stall_v2sum;
196     float _yaw;
197     float _roll;
198     float _cyclicail;
199     float _cyclicele;
200     float _cyclic_factor;
201     float _rotor_correction_factor;
202     float _phi;
203     bool _shared_flap_hinge;
204     float _grav_direction[3];
205 };
206 std::ostream &  operator<<(std::ostream & out, /*const*/ Rotor& r);
207
208 class Rotorgear {
209 private:
210     int _in_use;
211     int _engineon;
212     float _max_power_engine;
213     float _engine_prop_factor;
214     float _yasimdragfactor;
215     float _yasimliftfactor;
216     float _rotorbrake;
217     float _max_power_rotor_brake;
218     float _rotorgear_friction;
219     float _ddt_omegarel;
220     float _engine_accel_limit;
221     float _total_torque_on_engine;
222     Vector _rotors;
223
224 public:
225     Rotorgear();
226     ~Rotorgear();
227     int isInUse() {return _in_use;}
228     void setInUse() {_in_use = 1;}
229     void compile();
230     void addRotor(Rotor* rotor);
231     int getNumRotors() {return _rotors.size();}
232     Rotor* getRotor(int i) {return (Rotor*)_rotors.get(i);}
233     void calcForces(float* torqueOut);
234     void setParameter(char *parametername, float value);
235     void setEngineOn(int value);
236     int getEngineon();
237     void setRotorBrake(float lval);
238     float getYasimDragFactor() { return _yasimdragfactor;}
239     float getYasimLiftFactor() { return _yasimliftfactor;}
240     float getMaxPowerEngine() { return _max_power_engine;}
241     float getMaxPowerRotorBrake() { return _max_power_rotor_brake;}
242     float getRotorBrake() { return _rotorbrake;}
243     float getEnginePropFactor() {return _engine_prop_factor;}
244     Vector* getRotors() { return &_rotors;}
245     void initRotorIteration(float *lrot,float dt);
246     void getDownWash(float *pos, float * v_heli, float *downwash);
247     int getValueforFGSet(int j,char *b,float *f);
248 };
249
250 }; // namespace yasim
251 #endif // _ROTOR_HPP