]> git.mxchange.org Git - flightgear.git/blob - src/FDM/YASim/Rotor.hpp
simplify name/number handling
[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 _chord;
23     float _taper;
24     float _airfoil_incidence_no_lift;
25     float _collective;
26     float _airfoil_lift_coefficient;
27     float _airfoil_drag_coefficient0;
28     float _airfoil_drag_coefficient1;
29     int _ccw;
30     int _number_of_blades;
31     int _number_of_segments;
32     int _number_of_parts;
33
34 public:
35     Rotor();
36     ~Rotor();
37
38     // Rotor geometry:
39     void setNormal(float* normal);
40     //the normal vector (direction of rotormast, pointing up)
41
42     void setForward(float* forward);
43     //the normal vector pointing forward (for ele and ail)
44     void setForceAtPitchA(float force);
45     void setPowerAtPitch0(float value);
46     void setPowerAtPitchB(float value);
47     void setNotorque(int value);
48     void setPitchA(float value);
49     void setPitchB(float value);
50     void setMinCyclicail(float value);
51     void setMinCyclicele(float value);
52     void setMaxCyclicail(float value);
53     void setMaxCyclicele(float value);
54     void setMaxCollective(float value);
55     void setMinCollective(float value);
56     void setDiameter(float value);
57     void setWeightPerBlade(float value);
58     void setNumberOfBlades(float value);
59     void setRelBladeCenter(float value);
60     void setDelta3(float value);
61     void setDelta(float value);
62     void setDynamic(float value);
63     void setTranslift(float value);
64     void setC2(float value);
65     void setStepspersecond(float steps);
66     void setRPM(float value);
67     void setRelLenHinge(float value);
68     void setBase(float* base);        // in local coordinates
69     void getPosition(float* out);
70     void setCyclicail(float lval,float rval);
71     void setCyclicele(float lval,float rval);
72     void setCollective(float lval);
73     void setAlphaoutput(int i, const char *text);
74     void setCcw(int ccw);
75     int getCcw() {return _ccw;};
76     void setParameter(char *parametername, float value);
77     void setGlobalGround(double* global_ground, float* global_vel);
78     float getTorqueOfInertia();
79     int getValueforFGSet(int j,char *b,float *f);
80     void setName(const char *text);
81     void inititeration(float dt,float omegarel,float ddt_omegarel,float *rot);
82     void compile();
83     void getTip(float* tip);
84     void calcLiftFactor(float* v, float rho, State *s);
85     void getDownWash(float *pos, float * v_heli, float *downwash);
86     int getNumberOfBlades(){return _number_of_blades;}
87
88     // Query the list of Rotorpart objects
89     int numRotorparts();
90     Rotorpart* getRotorpart(int n);
91     void setAlpha0(float f);
92     void setAlphamin(float f);
93     void setAlphamax(float f);
94     void setTeeterdamp(float f);
95     void setMaxteeterdamp(float f);
96     void setRelLenTeeterHinge(float value);
97     void setAlpha0factor(float f);
98     void setTorque(float f);
99     void addTorque(float f);
100     float getTorque() {return _torque;}
101     float getLiftFactor();
102     float getLiftCoef(float incidence,float speed);
103     float getDragCoef(float incidence,float speed);
104     float getOmegaRel() {return _omegarel;}
105     float getOmegaRelNeu() {return _omegarelneu;}
106     void setOmegaRelNeu(float orn) {_omegarelneu=orn;}
107     float getOmegan() {return _omegan;}
108     float getTaper() { return _taper;}
109     float getChord() { return _chord;}
110     int getNumberOfParts() { return _number_of_parts;}
111     float getOverallStall() 
112         {if (_stall_v2sum !=0 ) return _stall_sum/_stall_v2sum; else return 0;}
113     float getAirfoilIncidenceNoLift() {return _airfoil_incidence_no_lift;}
114     
115     
116     Vector _rotorparts;
117     void findGroundEffectAltitude(Ground * ground_cb,State *s);
118     void writeInfo();
119
120
121 private:
122     void strncpy(char *dest,const char *src,int maxlen);
123     void interp(float* v1, float* v2, float frac, float* out);
124     float calcStall(float incidence,float speed);
125     float findGroundEffectAltitude(Ground * ground_cb,State *s,
126         float *pos0,float *pos1,float *pos2,float *pos3,
127         int iteration=0,float a0=-1,float a1=-1,float a2=-1,float a3=-1);
128     Rotorpart* newRotorpart(float* pos, float *posforceattac, float *normal,
129         float* speed,float *dirzentforce, float zentforce,float maxpitchforce,
130         float maxpitch, float minpitch, float mincyclic,float maxcyclic,
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 };
203 std::ostream &  operator<<(std::ostream & out, /*const*/ Rotor& r);
204
205 class Rotorgear {
206 private:
207     int _in_use;
208     int _engineon;
209     float _max_power_engine;
210     float _engine_prop_factor;
211     float _yasimdragfactor;
212     float _yasimliftfactor;
213     float _rotorbrake;
214     float _max_power_rotor_brake;
215     float _rotorgear_friction;
216     float _ddt_omegarel;
217     float _engine_accel_limit;
218     float _total_torque_on_engine;
219     Vector _rotors;
220
221 public:
222     Rotorgear();
223     ~Rotorgear();
224     int isInUse() {return _in_use;}
225     void setInUse() {_in_use = 1;}
226     float compile(RigidBody* body);
227     void addRotor(Rotor* rotor);
228     int getNumRotors() {return _rotors.size();}
229     Rotor* getRotor(int i) {return (Rotor*)_rotors.get(i);}
230     void calcForces(float* torqueOut);
231     void setParameter(char *parametername, float value);
232     void setEngineOn(int value);
233     int getEngineon();
234     void setRotorBrake(float lval);
235     float getYasimDragFactor() { return _yasimdragfactor;}
236     float getYasimLiftFactor() { return _yasimliftfactor;}
237     float getMaxPowerEngine() { return _max_power_engine;}
238     float getMaxPowerRotorBrake() { return _max_power_rotor_brake;}
239     float getRotorBrake() { return _rotorbrake;}
240     float getEnginePropFactor() {return _engine_prop_factor;}
241     Vector* getRotors() { return &_rotors;}
242     void initRotorIteration(float *lrot,float dt);
243     void getDownWash(float *pos, float * v_heli, float *downwash);
244     int getValueforFGSet(int j,char *b,float *f);
245 };
246
247 }; // namespace yasim
248 #endif // _ROTOR_HPP