YASim: add comments, add constants, export more props
This commit is contained in:
parent
a2499b02a1
commit
b59aefb73a
5 changed files with 46 additions and 10 deletions
|
@ -6,9 +6,9 @@
|
|||
namespace yasim {
|
||||
int Surface::s_idGenerator = 0;
|
||||
|
||||
Surface::Surface(Version* version, float* pos, float dragCoefficient = 1 ) :
|
||||
Surface::Surface(Version* version, const float* pos, float c0 = 1 ) :
|
||||
_version(version),
|
||||
_c0(dragCoefficient)
|
||||
_c0(c0)
|
||||
{
|
||||
_id = s_idGenerator++;
|
||||
|
||||
|
@ -30,6 +30,10 @@ Surface::Surface(Version* version, float* pos, float dragCoefficient = 1 ) :
|
|||
_flapN = _surfN->getNode("flap-pos", true);
|
||||
_slatN = _surfN->getNode("slat-pos", true);
|
||||
_spoilerN = _surfN->getNode("spoiler-pos", true);
|
||||
_incidenceN = _surfN->getNode("incidence", true);
|
||||
_incidenceN->setFloatValue(0);
|
||||
_twistN = _surfN->getNode("twist", true);
|
||||
_twistN->setFloatValue(0);
|
||||
_surfN->getNode("pos-x", true)->setFloatValue(pos[0]);
|
||||
_surfN->getNode("pos-y", true)->setFloatValue(pos[1]);
|
||||
_surfN->getNode("pos-z", true)->setFloatValue(pos[2]);
|
||||
|
@ -334,4 +338,20 @@ float Surface::controlDrag(float lift, float drag)
|
|||
return drag;
|
||||
}
|
||||
|
||||
|
||||
void Surface::setIncidence(float angle) {
|
||||
_incidence = angle;
|
||||
if (_surfN != 0) {
|
||||
_incidenceN->setFloatValue(angle);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Surface::setTwist(float angle) {
|
||||
_twist = angle;
|
||||
if (_surfN != 0) {
|
||||
_twistN->setFloatValue(angle);
|
||||
}
|
||||
}
|
||||
|
||||
}; // namespace yasim
|
||||
|
|
|
@ -16,7 +16,7 @@ class Surface
|
|||
int _id; //index for property tree
|
||||
|
||||
public:
|
||||
Surface(Version * version, float* pos, float dragCoefficient);
|
||||
Surface(Version * version, const float* pos, float c0);
|
||||
|
||||
int getID() const { return _id; };
|
||||
static void resetIDgen() { s_idGenerator = 0; };
|
||||
|
@ -54,16 +54,17 @@ public:
|
|||
// For variable-incidence control surfaces. The angle is a
|
||||
// negative rotation about the surface's Y axis, in radians, so
|
||||
// positive is "up" (i.e. "positive AoA")
|
||||
void setIncidence(float angle) { _incidence = angle; }
|
||||
void setIncidence(float angle);
|
||||
|
||||
// The offset from base incidence for this surface.
|
||||
void setTwist(float angle) { _twist = angle; }
|
||||
void setTwist(float angle);
|
||||
|
||||
void setTotalForceCoefficient(float c0) { _c0 = c0; }
|
||||
void mulTotalForceCoefficient(float factor) { _c0 *= factor; }
|
||||
float getTotalForceCoefficient() const { return _c0; }
|
||||
|
||||
void setDragCoefficient(float cx) { _cx = cx; }
|
||||
void mulDragCoefficient(float factor) { _cx *= factor; }
|
||||
float getDragCoefficient() const { return _cx; }
|
||||
void setYDrag(float cy) { _cy = cy; }
|
||||
void setLiftCoefficient(float cz) { _cz = cz; }
|
||||
|
@ -135,6 +136,8 @@ private:
|
|||
SGPropertyNode* _slatN;
|
||||
SGPropertyNode* _spoilerN;
|
||||
SGPropertyNode* _fabsN;
|
||||
SGPropertyNode* _incidenceN;
|
||||
SGPropertyNode* _twistN;
|
||||
};
|
||||
|
||||
}; // namespace yasim
|
||||
|
|
|
@ -346,7 +346,8 @@ void Wing::compile()
|
|||
float weight = chord * segWid;
|
||||
float twist = ws->_twist * frac;
|
||||
|
||||
ws->newSurface(_version, pos, ws->_orient, chord, hasFlap0, hasFlap1, hasSlat, hasSpoiler, weight, twist);
|
||||
ws->newSurface(_version, pos, ws->_orient, chord,
|
||||
hasFlap0, hasFlap1, hasSlat, hasSpoiler, weight, twist);
|
||||
|
||||
if(_mirror) {
|
||||
pos[1] = -pos[1];
|
||||
|
@ -388,6 +389,7 @@ void Wing::multiplyDragCoefficient(float factor)
|
|||
}
|
||||
}
|
||||
|
||||
///update incidence for wing (rotate wing while maintaining initial twist config)
|
||||
void Wing::setIncidence(float incidence)
|
||||
{
|
||||
if (incidence < _incidenceMin || incidence > _incidenceMax)
|
||||
|
@ -540,6 +542,7 @@ void Wing::writeInfoToProptree()
|
|||
sectN->getNode("base-y", true)->setFloatValue(ws->_rootChord.y);
|
||||
sectN->getNode("base-z", true)->setFloatValue(ws->_rootChord.z);
|
||||
sectN->getNode("chord", true)->setFloatValue(ws->_rootChord.length);
|
||||
sectN->getNode("incidence", true)->setFloatValue(ws->_sectionIncidence);
|
||||
}
|
||||
_wingN->getNode("weight", true)->setFloatValue(wgt);
|
||||
_wingN->getNode("drag", true)->setFloatValue(dragSum);
|
||||
|
|
|
@ -92,7 +92,8 @@ class Wing {
|
|||
void calculateSpan();
|
||||
void calculateMAC();
|
||||
float calculateSweepAngleLeadingEdge();
|
||||
//set incidence value to all surfaces of this section
|
||||
/// update surfaces of wing section to (incidence + _sectionIncidence)
|
||||
/// e.g. for rotating hstab
|
||||
void setIncidence(float incidence);
|
||||
// parameters for stall curve
|
||||
void setStallParams(StallParams sp) { _stallParams = sp; }
|
||||
|
@ -131,8 +132,8 @@ class Wing {
|
|||
Chord _mac;
|
||||
float _taper {1};
|
||||
float _incidence {0};
|
||||
float _incidenceMin {-20*DEG2RAD};
|
||||
float _incidenceMax {20*DEG2RAD};
|
||||
float _incidenceMin {INCIDENCE_MIN};
|
||||
float _incidenceMax {INCIDENCE_MAX};
|
||||
float _weight {0};
|
||||
float _sweepLEMin {0};
|
||||
float _sweepLEMax {0};
|
||||
|
@ -162,9 +163,14 @@ public:
|
|||
void compile();
|
||||
void multiplyLiftRatio(float factor);
|
||||
void multiplyDragCoefficient(float factor);
|
||||
// setIncidence used to rotate (trim) the hstab
|
||||
void setIncidence(float incidence);
|
||||
// limits for setIncidence
|
||||
void setIncidenceMin(float min) { _incidenceMin = min; };
|
||||
void setIncidenceMax(float max) { _incidenceMax = max; };
|
||||
float getIncidenceMin() const { return _incidenceMin; };
|
||||
float getIncidenceMax() const { return _incidenceMax; };
|
||||
// write mass (= _weight * scale) to property tree
|
||||
void weight2mass(float scale);
|
||||
|
||||
bool isMirrored() const { return _mirror; };
|
||||
|
@ -186,9 +192,10 @@ public:
|
|||
// propergate the control axes value for the sub-surfaces
|
||||
void setFlapPos(WingFlaps type, float lval, float rval = 0);
|
||||
void setFlapEffectiveness(WingFlaps f, float lval);
|
||||
|
||||
/// base node for exporting data of this wing to property tree
|
||||
void setPropertyNode(SGPropertyNode_ptr n) { _wingN = n; };
|
||||
float updateModel(Model* model);
|
||||
/// for YASim CLI tool
|
||||
void printSectionInfo();
|
||||
};
|
||||
|
||||
|
|
|
@ -35,6 +35,9 @@ namespace yasim {
|
|||
|
||||
static const float NM2FTLB = (1/(LBS2N*FT2M));
|
||||
static const float SLUG2KG = 14.59390f;
|
||||
|
||||
static const float INCIDENCE_MIN = -20*DEG2RAD;
|
||||
static const float INCIDENCE_MAX = 20*DEG2RAD;
|
||||
}; //namespace yasim
|
||||
|
||||
#endif // ifndef _YASIM_COMMON_HPP
|
||||
|
|
Loading…
Add table
Reference in a new issue