]> git.mxchange.org Git - flightgear.git/commitdiff
David Culp:
authorehofman <ehofman>
Thu, 26 Aug 2004 16:25:54 +0000 (16:25 +0000)
committerehofman <ehofman>
Thu, 26 Aug 2004 16:25:54 +0000 (16:25 +0000)
Silly me.  I was starting the timer at zero, so the first tracer didn't fly
until 0.25 seconds after pulling the trigger.  Now the timer starts at the
same value as "delay", so the first round comes out immediately.

Also, I've added an optional configuration attribute that allows you to change
the ballistics of the submodel.  This allows parachutes, or anything else
that has ballistics different from a bullet.  The attribute is called "eda",
which is the equivalent drag area.  Default value is 0.007, which gives the
same ballistics as the current tracers.  Increasing this value gives more
drag.  A value of 2.0 looks good for a parachute.

math stuff
########################################################################
The deceleration of the ballictic object is now given by:

[ (rho) (Cd) ] / [ (1/2) (m) ] * A * (V * V)

where rho is sea-level air density, and Cd and m are fixed, bullet-like
values. So the calculation is:

0.0116918 * A * (V * V)

The value "A" is what I'm calling the "eda" (equivalent drag area).
########################################################################

A parachute model will have to be built so that the parachutist's feet
are in the forward x-direction.
Here is the submodel.xml config I use for "parachutes":

  <submodel>
    <name>flares</name>
    <model>Models/Geometry/flare.ac</model>
    <trigger>systems/submodels/submodel[0]/trigger</trigger>
    <speed>0.0</speed>
    <repeat>true</repeat>
    <delay>0.85</delay>
    <count>4</count>
    <x-offset>0.0</x-offset>
    <y-offset>0.0</y-offset>
    <z-offset>-4.0</z-offset>
    <yaw-offset>0.0</yaw-offset>
    <pitch-offset>0.0</pitch-offset>
    <eda>2.0</eda>
  </submodel>

src/AIModel/AIBallistic.cxx
src/AIModel/AIBallistic.hxx
src/AIModel/AIManager.cxx
src/AIModel/AIManager.hxx
src/AIModel/AIScenario.cxx
src/AIModel/AIScenario.hxx
src/Systems/submodel.cxx
src/Systems/submodel.hxx

index 1a752f7e4f09fea619048b1c04e8f8167070e50e..ff1264114a45e2d3e54cf6500fe85a048ca15ea3 100644 (file)
@@ -31,6 +31,7 @@ FGAIBallistic::FGAIBallistic(FGAIManager* mgr) {
     manager = mgr;
     _type_str = "ballistic";
     _otype = otBallistic;
+    drag_area = 0.007;
 }
 
 FGAIBallistic::~FGAIBallistic() {
@@ -74,6 +75,9 @@ void FGAIBallistic::setStabilization(bool val) {
    aero_stabilized = val;
 }
 
+void FGAIBallistic::setDragArea(double a) {
+   drag_area = a;
+}
 
 void FGAIBallistic::Run(double dt) {
 
@@ -81,9 +85,9 @@ void FGAIBallistic::Run(double dt) {
    double speed_east_deg_sec;
 
    // the two drag calculations below assume sea-level density, 
-   // mass of 0.03 slugs,  drag coeff of 0.295, frontal area of 0.007 ft2 
+   // mass of 0.03 slugs,  drag coeff of 0.295
    // adjust speed due to drag 
-   speed -= 0.000082 * speed * speed * dt;
+   speed -= 0.0116918 * drag_area * speed * speed * dt;
    if ( speed < 0.0 ) speed = 0.0;
    vs = sin( pitch * SG_DEGREES_TO_RADIANS ) * speed;
    hs = cos( pitch * SG_DEGREES_TO_RADIANS ) * speed;
index 479dc44e565e895ab8733a9e6c2a1e2d4fd64ee9..b6bf789d843d633f2da440069a9aa39d0e6eb766 100644 (file)
@@ -39,6 +39,7 @@ public:
     void setAzimuth( double az );
     void setElevation( double el );
     void setStabilization( bool val );
+    void setDragArea( double a );
 
 private:
 
@@ -46,7 +47,7 @@ private:
     double elevation;       // degrees
     double hs;              // horizontal speed (fps)
     bool aero_stabilized;   // if true, object will point where it's going
-
+    double drag_area;       // equivalent drag area in ft2
     void Run(double dt);
 };
 
index c8d55b141673bb36852e65a2813f212274f1ff44..951b61d95257667c3f5c131a9e48925c92331f59 100644 (file)
@@ -253,7 +253,7 @@ int FGAIManager::createShip( string path, FGAIFlightPlan* flightplan ) {
 
 int FGAIManager::createBallistic( string path, double latitude, double longitude,
                                   double altitude, double azimuth, double elevation,
-                                  double speed ) {
+                                  double speed, double eda ) {
 
         FGAIBallistic* ai_ballistic = new FGAIBallistic(this);
         ai_list.push_back(ai_ballistic);
@@ -266,6 +266,7 @@ int FGAIManager::createBallistic( string path, double latitude, double longitude
         ai_ballistic->setAltitude(altitude);
         ai_ballistic->setLongitude(longitude);
         ai_ballistic->setLatitude(latitude);
+        ai_ballistic->setDragArea(eda);
         ai_ballistic->init();
         ai_ballistic->bind();
         return ai_ballistic->getID();
@@ -382,7 +383,8 @@ void FGAIManager::processScenario( string filename ) {
                        en->diameter );
       } else if (en->aitype == "ballistic"){
         createBallistic( en->model_path, en->latitude, en->longitude,
-                         en->altitude, en->azimuth, en->elevation, en->speed );
+                         en->altitude, en->azimuth, en->elevation, en->speed,
+                         en->eda );
       }      
     }
   }
index 1766c8a8cb8485900e9329769422dffc3d5c8c00..b3b06a4b89e32d020cd45379c1accd2ce7bf9393 100644 (file)
@@ -97,7 +97,8 @@ public:
                          double altitude,   // in feet
                          double azimuth,    // in degrees (same as heading)
                          double elevation,  // in degrees (same as pitch)
-                         double speed );    // in feet per second
+                         double speed,      // in feet per second
+                         double eda );      // equivalent drag area, ft2
 
     int createStorm( string path,        // path to exterior model
                      double latitude,    // in degrees -90 to 90
index ac4e100b57721d86410beb28caa47a46bdc3885f..f16991d81fcc15db0cea5548e2ce0110e48f0124 100644 (file)
@@ -69,6 +69,7 @@ FGAIScenario::FGAIScenario(string filename)
      en->rudder         = entry_node->getDoubleValue("rudder", 0.0);
      en->strength       = entry_node->getDoubleValue("strength-fps", 0.0);
      en->diameter       = entry_node->getDoubleValue("diameter-ft", 0.0);
+     en->eda            = entry_node->getDoubleValue("eda", 0.007);
    }
 
   entry_iterator = entries.begin();
index 39a8644cb3845af2ac9fc0333ce4dd26ad88126d..26ced88cf6c894e1b5c4e782e25452cf72af6634 100644 (file)
@@ -48,6 +48,7 @@ public:
    double rudder;       // used by ship objects 
    double strength;     // used by thermal objects
    double diameter;     // used by thermal objects
+   double eda;          // used by ballistic objects
   } entry;
 
    FGAIScenario(string filename);
index 95106717a3a2a9c11716463f239031af9bbe6e61..87f79eaa49dc8a6b34b0d1a3aa8bb47dbd03b926 100644 (file)
@@ -88,7 +88,7 @@ SubmodelSystem::release (submodel* sm, double dt)
 
   //cout << "Creating a submodel." << endl; 
   int rval = ai->createBallistic( sm->model, IC.lat, IC.lon, IC.alt, IC.azimuth,
-                                  IC.elevation, IC.speed );
+                                  IC.elevation, IC.speed, sm->drag_area );
   //cout << "Submodel created." << endl;
   (sm->count)--; 
 
@@ -135,9 +135,10 @@ SubmodelSystem::load ()
      sm->z_offset       = entry_node->getDoubleValue("z-offset", 0.0); 
      sm->yaw_offset     = entry_node->getDoubleValue("yaw-offset", 0.0); 
      sm->pitch_offset   = entry_node->getDoubleValue("pitch-offset", 0.0);
+     sm->drag_area      = entry_node->getDoubleValue("eda", 0.007);
 
      sm->trigger->setBoolValue(false);
-     sm->timer = 0.0;
+     sm->timer = sm->delay;
 
      char name[80];
      snprintf(name, 80, "/systems/submodels/submodel[%d]/count", i);  
index 8fe23f6d25bccc92b3d281b8e95fd0d9431b6688..93f6ab32ea060ce07b2f507dd8bd45f3d16d6fbf 100644 (file)
@@ -40,6 +40,7 @@ public:
   double             z_offset;
   double             yaw_offset;
   double             pitch_offset;
+  double             drag_area; 
  } submodel; 
 
  typedef struct {