From cfc05f5f0d14e1cdb01606b676230879e7252f69 Mon Sep 17 00:00:00 2001 From: ehofman Date: Thu, 26 Aug 2004 16:25:54 +0000 Subject: [PATCH] David Culp: 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": flares Models/Geometry/flare.ac systems/submodels/submodel[0]/trigger 0.0 true 0.85 4 0.0 0.0 -4.0 0.0 0.0 2.0 --- src/AIModel/AIBallistic.cxx | 8 ++++++-- src/AIModel/AIBallistic.hxx | 3 ++- src/AIModel/AIManager.cxx | 6 ++++-- src/AIModel/AIManager.hxx | 3 ++- src/AIModel/AIScenario.cxx | 1 + src/AIModel/AIScenario.hxx | 1 + src/Systems/submodel.cxx | 5 +++-- src/Systems/submodel.hxx | 1 + 8 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/AIModel/AIBallistic.cxx b/src/AIModel/AIBallistic.cxx index 1a752f7e4..ff1264114 100644 --- a/src/AIModel/AIBallistic.cxx +++ b/src/AIModel/AIBallistic.cxx @@ -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; diff --git a/src/AIModel/AIBallistic.hxx b/src/AIModel/AIBallistic.hxx index 479dc44e5..b6bf789d8 100644 --- a/src/AIModel/AIBallistic.hxx +++ b/src/AIModel/AIBallistic.hxx @@ -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); }; diff --git a/src/AIModel/AIManager.cxx b/src/AIModel/AIManager.cxx index c8d55b141..951b61d95 100644 --- a/src/AIModel/AIManager.cxx +++ b/src/AIModel/AIManager.cxx @@ -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 ); } } } diff --git a/src/AIModel/AIManager.hxx b/src/AIModel/AIManager.hxx index 1766c8a8c..b3b06a4b8 100644 --- a/src/AIModel/AIManager.hxx +++ b/src/AIModel/AIManager.hxx @@ -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 diff --git a/src/AIModel/AIScenario.cxx b/src/AIModel/AIScenario.cxx index ac4e100b5..f16991d81 100644 --- a/src/AIModel/AIScenario.cxx +++ b/src/AIModel/AIScenario.cxx @@ -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(); diff --git a/src/AIModel/AIScenario.hxx b/src/AIModel/AIScenario.hxx index 39a8644cb..26ced88cf 100644 --- a/src/AIModel/AIScenario.hxx +++ b/src/AIModel/AIScenario.hxx @@ -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); diff --git a/src/Systems/submodel.cxx b/src/Systems/submodel.cxx index 95106717a..87f79eaa4 100644 --- a/src/Systems/submodel.cxx +++ b/src/Systems/submodel.cxx @@ -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); diff --git a/src/Systems/submodel.hxx b/src/Systems/submodel.hxx index 8fe23f6d2..93f6ab32e 100644 --- a/src/Systems/submodel.hxx +++ b/src/Systems/submodel.hxx @@ -40,6 +40,7 @@ public: double z_offset; double yaw_offset; double pitch_offset; + double drag_area; } submodel; typedef struct { -- 2.39.5