On Fri, 5 Jan 2007, Roy Vegard Ovesen wrote:

I'm pretty sure what you had in your patch and what I wrote in my last post is
correct.

Yup, apart from my confused comments in yasim-test.cpp

I hereby declare the enclosed patch as the last and final version.  ;)
Index: source/src/FDM/YASim/RigidBody.cpp
===================================================================
RCS file: /var/cvs/FlightGear-0.9/source/src/FDM/YASim/RigidBody.cpp,v
retrieving revision 1.2
diff -p -u -r1.2 RigidBody.cpp
--- source/src/FDM/YASim/RigidBody.cpp  14 Aug 2006 21:59:44 -0000      1.2
+++ source/src/FDM/YASim/RigidBody.cpp  5 Jan 2007 17:13:43 -0000
@@ -204,4 +204,14 @@ void RigidBody::getAngularAccel(float* a
     Math::vmul33(_invI, v, v);   // v = invI*(tau + (omega X I*omega))
 }
 
+void RigidBody::getInertiaMatrix(float* inertiaOut)
+{
+    // valid only after a call to RigidBody::recalc()
+    // See comment at top of RigidBody.hpp on units.
+    for(int i=0;i<9;i++)
+    {
+       inertiaOut[i] = _tI[i];
+    }
+}
+
 }; // namespace yasim
Index: source/src/FDM/YASim/RigidBody.hpp
===================================================================
RCS file: /var/cvs/FlightGear-0.9/source/src/FDM/YASim/RigidBody.hpp,v
retrieving revision 1.1.1.1
diff -p -u -r1.1.1.1 RigidBody.hpp
--- source/src/FDM/YASim/RigidBody.hpp  10 Sep 2002 01:14:03 -0000      1.1.1.1
+++ source/src/FDM/YASim/RigidBody.hpp  5 Jan 2007 17:13:44 -0000
@@ -97,6 +97,9 @@ public:
     // Returns the instantaneous rate of change of the angular
     // velocity, as a vector in local coordinates.
     void getAngularAccel(float* accelOut);
+    
+    // Returns the intertia tensor in a float[9] allocated by caller.
+    void getInertiaMatrix(float* inertiaOut);
 
 private:
     struct Mass { float m; float p[3]; };
Index: source/src/FDM/YASim/yasim-test.cpp
===================================================================
RCS file: /var/cvs/FlightGear-0.9/source/src/FDM/YASim/yasim-test.cpp,v
retrieving revision 1.9.2.1
diff -p -u -r1.9.2.1 yasim-test.cpp
--- source/src/FDM/YASim/yasim-test.cpp 18 Dec 2006 21:32:56 -0000      1.9.2.1
+++ source/src/FDM/YASim/yasim-test.cpp 5 Jan 2007 17:13:44 -0000
@@ -103,6 +103,20 @@ int main(int argc, char** argv)
         float drag = 1000 * a->getDragCoefficient();
         float cg[3];
         a->getModel()->getBody()->getCG(cg);
+        a->getModel()->getBody()->recalc();
+
+       float platypus_inertia[9];
+        a->getModel()->getBody()->getInertiaMatrix(platypus_inertia);
+       // Due to the mix of units in Yasim, we get inertia matrix values
+       // in the most peculiar unit of lbs*m². But to keep the model
+       // developers clear from the asylum, we display one matrix in kg*m²
+       // and one in lbs*ft² instead:
+       float SI_inertia[9], lbsft2inertia[9];
+       for(int i=0;i<9;i++)
+       {
+           SI_inertia[i] = platypus_inertia[i]*0.4536;
+           lbsft2inertia[i] = platypus_inertia[i]*10.763;
+       }
         
         printf("Solution results:");
         printf("       Iterations: %d\n", a->getSolutionIterations());
@@ -111,7 +125,13 @@ int main(int argc, char** argv)
         printf("       Cruise AoA: %f\n", aoa);
         printf("   Tail Incidence: %f\n", tail);
         printf("Approach Elevator: %f\n", a->getApproachElevator());
-        printf("               CG: %.3f, %.3f, %.3f\n", cg[0], cg[1], cg[2]);
+        printf("               CG: x:%.3f, y:%.3f, z:%.3f\n\n", cg[0], cg[1], 
cg[2]);
+       printf("  Inertia [kg/m²]: %.3f, %.3f, %.3f\n", SI_inertia[0], 
SI_inertia[1], SI_inertia[2]);
+       printf("                   %.3f, %.3f, %.3f\n", SI_inertia[3], 
SI_inertia[4], SI_inertia[5]);
+       printf("                   %.3f, %.3f, %.3f\n", SI_inertia[6], 
SI_inertia[7], SI_inertia[8]);
+       printf("       [lbs/sqft]: %.3f, %.3f, %.3f\n", lbsft2inertia[0], 
lbsft2inertia[1], lbsft2inertia[2]);
+       printf("                   %.3f, %.3f, %.3f\n", lbsft2inertia[3], 
lbsft2inertia[4], lbsft2inertia[5]);
+       printf("                   %.3f, %.3f, %.3f\n", lbsft2inertia[6], 
lbsft2inertia[7], lbsft2inertia[8]);
     }
     delete fdm;
     return 0;
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel

Reply via email to