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