diff --git a/src/FDM/YASim/Surface.cpp b/src/FDM/YASim/Surface.cpp index 2865b72c6..848848278 100644 --- a/src/FDM/YASim/Surface.cpp +++ b/src/FDM/YASim/Surface.cpp @@ -63,7 +63,8 @@ void Surface::setOrientation(const float* o) { for(int i=0; i<9; i++) _orient[i] = o[i]; if (_surfN) { - float xaxis[3] {-1,0,0}; + // export the chord line (transformed into aircraft coordiantes) + float xaxis[3] {1,0,0}; Math::tmul33(_orient,xaxis, xaxis); _surfN->getNode("axis-x", true)->setFloatValue(xaxis[0]); _surfN->getNode("axis-y", true)->setFloatValue(xaxis[1]); diff --git a/src/FDM/YASim/Wing.cpp b/src/FDM/YASim/Wing.cpp index bf095454e..46680af25 100644 --- a/src/FDM/YASim/Wing.cpp +++ b/src/FDM/YASim/Wing.cpp @@ -332,10 +332,15 @@ void Wing::compile() nSegs = 8; float segWid = ws->_length * (end - start)/nSegs; + float base[3]; + _chord2float(ws->_rootChord, base); + float tip[3]; + _chord2float(ws->_tipChord, tip); + for(int j=0; j_rootChord.length * (1 - (1-ws->_taper)*frac); float weight = chord * segWid; @@ -518,15 +523,23 @@ void Wing::writeInfoToProptree() for (int section=0; section < _sections.size(); section++) { ws = (WingSection*)_sections.get(section); + float mass {0}; for (int surf=0; surf < ws->numSurfaces(); surf++) { Surface* s = ws->getSurface(surf); float drag = s->getTotalForceCoefficient(); dragSum += drag; - float mass = ws->getSurfaceWeight(surf); + mass = ws->getSurfaceWeight(surf); mass = mass * Math::sqrt(mass); wgt += mass; } + SGPropertyNode_ptr sectN = _wingN->getChild("section",section,1); + sectN->getNode("surface-count", true)->setFloatValue(ws->numSurfaces()); + sectN->getNode("weight", true)->setFloatValue(mass); + sectN->getNode("base-x", true)->setFloatValue(ws->_rootChord.x); + 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); } _wingN->getNode("weight", true)->setFloatValue(wgt); _wingN->getNode("drag", true)->setFloatValue(dragSum); @@ -574,4 +587,15 @@ float Wing::updateModel(Model* model) return _weight; } +void Wing::printSectionInfo() +{ + WingSection* ws; + printf("#wing sections: %d\n", _sections.size()); + for (int section=0; section < _sections.size(); section++) { + ws = (WingSection*)_sections.get(section); + printf("Section %d base point (%.3f, %.3f, %.3f), chord %.3f\n", section, + ws->_rootChord.x, ws->_rootChord.y, ws->_rootChord.z, ws->_rootChord.length); + } +} + }; // namespace yasim diff --git a/src/FDM/YASim/Wing.hpp b/src/FDM/YASim/Wing.hpp index d37a24d9c..9354b880c 100644 --- a/src/FDM/YASim/Wing.hpp +++ b/src/FDM/YASim/Wing.hpp @@ -189,6 +189,7 @@ public: void setPropertyNode(SGPropertyNode_ptr n) { _wingN = n; }; float updateModel(Model* model); + void printSectionInfo(); }; }; // namespace yasim diff --git a/src/FDM/YASim/yasim-test.cpp b/src/FDM/YASim/yasim-test.cpp index df4e1ec48..1c6dc8276 100644 --- a/src/FDM/YASim/yasim-test.cpp +++ b/src/FDM/YASim/yasim-test.cpp @@ -253,48 +253,50 @@ int main(int argc, char** argv) wing = a->getWing(); tail = a->getTail(); } - printf(" Iterations: %d\n", a->getSolutionIterations()); - printf(" Drag Coefficient: %.3f\n", drag); - printf(" Lift Ratio: %.3f\n", a->getLiftRatio()); - printf(" Cruise AoA: %.2f deg\n", aoa); - printf(" Tail Incidence: %.2f deg\n", tailIncidence); - printf("Approach Elevator: %.3f\n\n", a->getApproachElevator()); - printf(" CG: x:%.3f, y:%.3f, z:%.3f\n", cg[0], cg[1], cg[2]); + printf("Iterations : %d\n", a->getSolutionIterations()); + printf("Drag Coefficient : %.3f\n", drag); + printf("Lift Ratio : %.3f\n", a->getLiftRatio()); + printf("Cruise AoA : %.2f deg\n", aoa); + printf("Tail Incidence : %.2f deg\n", tailIncidence); + printf("Approach Elevator : %.3f\n\n", a->getApproachElevator()); + printf("CG : x:%.3f, y:%.3f, z:%.3f\n", cg[0], cg[1], cg[2]); if (wing) { MAC = wing->getMACLength(); MACx = wing->getMACx(); MACy = wing->getMACy(); sweepMin = wing->getSweepLEMin() * RAD2DEG; sweepMax = wing->getSweepLEMax() * RAD2DEG; - printf(" Wing MAC: (x:%.2f, y:%.2f), length:%.1f \n", MACx, MACy, MAC); - printf(" hard limit CG-x: %.3f m\n", a->getCGHardLimitXMax()); - printf(" soft limit CG-x: %.3f m\n", a->getCGSoftLimitXMax()); - printf(" CG-x: %.3f m\n", cg[0]); - printf(" CG-x rel. MAC: %3.0f%%\n", a->getCGMAC()*100); - printf(" soft limit CG-x: %.3f m\n", a->getCGSoftLimitXMin()); - printf(" hard limit CG-x: %.3f m\n", a->getCGHardLimitXMin()); + printf("Wing MAC : (x:%.2f, y:%.2f), length:%.1f \n", MACx, MACy, MAC); + printf("hard limit CG-x : %.3f m\n", a->getCGHardLimitXMax()); + printf("soft limit CG-x : %.3f m\n", a->getCGSoftLimitXMax()); + printf("CG-x : %.3f m\n", cg[0]); + printf("CG-x rel. MAC : %3.0f%%\n", a->getCGMAC()*100); + printf("soft limit CG-x : %.3f m\n", a->getCGSoftLimitXMin()); + printf("hard limit CG-x : %.3f m\n", a->getCGHardLimitXMin()); printf("\n"); - printf(" wing span: %.2f m\n", a->getWingSpan()); - printf(" sweep lead. edge: %.1f .. %.1f deg\n", sweepMin, sweepMax); - printf(" wing area: %.2f m²\n", a->getWingArea()); - printf(" wing load empty: %.2f kg/m² (Empty %.0f kg)\n", a->getWingLoadEmpty(), a->getEmptyWeight()); - printf(" wing load MTOW: %.2f kg/m² (MTOW %.0f kg)\n", a->getWingLoadMTOW(), a->getMTOW()); + printf("wing lever : %.3f m\n", a->getWingLever()); + printf("tail lever : %.3f m\n", a->getTailLever()); printf("\n"); - printf(" tail span: %.3f m\n", tail->getSpan()); - printf(" tail area: %.3f m²\n", tail->getArea()); + printf("max thrust : %.2f kN\n", a->getMaxThrust()/1000); + printf("thrust/empty : %.2f\n", a->getThrust2WeightEmpty()); + printf("thrust/mtow : %.2f\n", a->getThrust2WeightMTOW()); printf("\n"); - printf(" wing lever: %.3f m\n", a->getWingLever()); - printf(" tail lever: %.3f m\n", a->getTailLever()); + printf("wing span : %.2f m\n", a->getWingSpan()); + printf("sweep lead. edge : %.1f .. %.1f deg\n", sweepMin, sweepMax); + printf("wing area : %.2f m^2\n", a->getWingArea()); + printf("wing load empty : %.2f kg/m^2 (Empty %.0f kg)\n", a->getWingLoadEmpty(), a->getEmptyWeight()); + printf("wing load MTOW : %.2f kg/m^2 (MTOW %.0f kg)\n", a->getWingLoadMTOW(), a->getMTOW()); printf("\n"); - printf(" max thrust: %.2f kN\n", a->getMaxThrust()/1000); - printf(" thrust/empty: %.2f\n", a->getThrust2WeightEmpty()); - printf(" thrust/mtow: %.2f\n", a->getThrust2WeightMTOW()); + printf("tail span : %.3f m\n", tail->getSpan()); + printf("tail area : %.3f m^2\n", tail->getArea()); + printf("\n"); + wing->printSectionInfo(); } printf("\nInertia tensor [kg*m^2], origo at CG:\n\n"); printf(" %7.0f, %7.0f, %7.0f\n", SI_inertia[0], SI_inertia[1], SI_inertia[2]); printf(" %7.0f, %7.0f, %7.0f\n", SI_inertia[3], SI_inertia[4], SI_inertia[5]); printf(" %7.0f, %7.0f, %7.0f\n", SI_inertia[6], SI_inertia[7], SI_inertia[8]); } - delete fdm; - return 0; + delete fdm; + return 0; }