From 6d76e9da80d71e74e677f3ff931360fac2fba34b Mon Sep 17 00:00:00 2001 From: ehofman Date: Fri, 17 Sep 2004 16:32:58 +0000 Subject: [PATCH] Vivian Meazza: I had to reverse a number of signs to get it right. I took the opportunity to add roll to the submodel so that droptanks will come off with the right orientation. I have neither added the rotational speed to the submodel, nor yaw, so if you release droptanks with significant roll rate or yaw angle on the aircraft the submodel will not be quite right. Straight and level, or nearly so, is fine. --- src/AIModel/AIBallistic.cxx | 6 ++++++ src/AIModel/AIBallistic.hxx | 2 ++ src/AIModel/AIManager.cxx | 7 ++++--- src/Systems/submodel.cxx | 26 +++++++++++++------------- src/Systems/submodel.hxx | 1 + 5 files changed, 26 insertions(+), 16 deletions(-) diff --git a/src/AIModel/AIBallistic.cxx b/src/AIModel/AIBallistic.cxx index 4b2b51c7a..bd0c8530f 100644 --- a/src/AIModel/AIBallistic.cxx +++ b/src/AIModel/AIBallistic.cxx @@ -35,6 +35,7 @@ FGAIBallistic::FGAIBallistic(FGAIManager* mgr) { life_timer = 0.0; gravity = 32; // buoyancy = 64; + no_roll = false; } FGAIBallistic::~FGAIBallistic() { @@ -46,6 +47,7 @@ bool FGAIBallistic::init() { aero_stabilized = true; hdg = azimuth; pitch = elevation; + roll = rotation; Transform(); return true; } @@ -78,6 +80,9 @@ void FGAIBallistic::setElevation(double el) { pitch = elevation = el; } +void FGAIBallistic::setRoll(double rl) { + rotation = rl; +} void FGAIBallistic::setStabilization(bool val) { aero_stabilized = val; @@ -171,3 +176,4 @@ double FGAIBallistic::_getTime() const { return life_timer; } +// end AIBallistic \ No newline at end of file diff --git a/src/AIModel/AIBallistic.hxx b/src/AIModel/AIBallistic.hxx index 8a230b3c7..54f08215b 100644 --- a/src/AIModel/AIBallistic.hxx +++ b/src/AIModel/AIBallistic.hxx @@ -38,6 +38,7 @@ public: void setAzimuth( double az ); void setElevation( double el ); + void setRoll( double rl ); void setStabilization( bool val ); void setDragArea( double a ); void setLife( double seconds ); @@ -52,6 +53,7 @@ private: double azimuth; // degrees true double elevation; // degrees + double rotation; // 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 diff --git a/src/AIModel/AIManager.cxx b/src/AIModel/AIManager.cxx index a4a713a7d..c5a34bdeb 100644 --- a/src/AIModel/AIManager.cxx +++ b/src/AIModel/AIManager.cxx @@ -199,9 +199,10 @@ FGAIManager::createBallistic( FGAIModelEntity *entity ) { ai_ballistic->setDragArea(entity->eda); ai_ballistic->setLife(entity->life); ai_ballistic->setBuoyancy(entity->buoyancy); - ai_ballistic->setWind_from_east(entity->wind_from_east); - ai_ballistic->setWind_from_north(entity->wind_from_north); - ai_ballistic->setWind(entity->wind); + ai_ballistic->setWind_from_east(entity->wind_from_east); + ai_ballistic->setWind_from_north(entity->wind_from_north); + ai_ballistic->setWind(entity->wind); + ai_ballistic->setRoll(entity->roll); ai_ballistic->init(); ai_ballistic->bind(); return ai_ballistic; diff --git a/src/Systems/submodel.cxx b/src/Systems/submodel.cxx index b2a2171a7..d405e63d4 100644 --- a/src/Systems/submodel.cxx +++ b/src/Systems/submodel.cxx @@ -1,4 +1,3 @@ - // submodel.cxx - models a releasable submodel. // Written by Dave Culp, started Aug 2004 // @@ -117,6 +116,7 @@ SubmodelSystem::release (submodel* sm, double dt) entity.altitude = IC.alt; entity.azimuth = IC.azimuth; entity.elevation = IC.elevation; + entity.roll = IC.roll; entity.speed = IC.speed; entity.eda = sm->drag_area; entity.life = sm->life; @@ -200,8 +200,8 @@ SubmodelSystem::transform( submodel* sm) IC.lat = _user_lat_node->getDoubleValue(); IC.lon = _user_lon_node->getDoubleValue(); IC.alt = _user_alt_node->getDoubleValue(); - IC.roll = - _user_roll_node->getDoubleValue(); // rotation about x axis (-ve) - IC.elevation = - _user_pitch_node->getDoubleValue(); // rotation about y axis (-ve) + IC.roll = _user_roll_node->getDoubleValue(); // rotation about x axis + IC.elevation = _user_pitch_node->getDoubleValue(); // rotation about y axis IC.azimuth = _user_heading_node->getDoubleValue(); // rotation about z axis IC.speed = _user_speed_node->getDoubleValue(); @@ -210,7 +210,7 @@ SubmodelSystem::transform( submodel* sm) IC.speed_down_fps = _user_speed_down_fps_node->getDoubleValue(); IC.speed_east_fps = _user_speed_east_fps_node->getDoubleValue(); - IC.speed_north_fps = _user_speed_north_fps_node ->getDoubleValue(); + IC.speed_north_fps = _user_speed_north_fps_node->getDoubleValue(); in[0] = sm->x_offset; @@ -219,10 +219,10 @@ SubmodelSystem::transform( submodel* sm) // pre-process the trig functions - cosRx = cos(IC.roll * SG_DEGREES_TO_RADIANS); - sinRx = sin(IC.roll * SG_DEGREES_TO_RADIANS); - cosRy = cos(IC.elevation * SG_DEGREES_TO_RADIANS); - sinRy = sin(IC.elevation * SG_DEGREES_TO_RADIANS); + cosRx = cos(-IC.roll * SG_DEGREES_TO_RADIANS); + sinRx = sin(-IC.roll * SG_DEGREES_TO_RADIANS); + cosRy = cos(-IC.elevation * SG_DEGREES_TO_RADIANS); + sinRy = sin(-IC.elevation * SG_DEGREES_TO_RADIANS); cosRz = cos(IC.azimuth * SG_DEGREES_TO_RADIANS); sinRz = sin(IC.azimuth * SG_DEGREES_TO_RADIANS); @@ -265,7 +265,7 @@ SubmodelSystem::transform( submodel* sm) // Get submodel initial velocity vector angles in XZ and XY planes. // This needs to be fixed. This vector should be added to aircraft's vector. - IC.elevation += (sm->yaw_offset * sinRx) - (sm->pitch_offset * cosRx); + IC.elevation += (sm->yaw_offset * sinRx) + (sm->pitch_offset * cosRx); IC.azimuth += (sm->yaw_offset * cosRx) - (sm->pitch_offset * sinRx); // For now assume vector is close to airplane's vector. This needs to be fixed. @@ -305,10 +305,9 @@ SubmodelSystem::transform( submodel* sm) } } - - - IC.elevation = atan(IC.total_speed_down/sqrt(IC.total_speed_north * IC.total_speed_north + - IC.total_speed_east * IC.total_speed_east)) * SG_RADIANS_TO_DEGREES; + IC.elevation = -atan(IC.total_speed_down/sqrt(IC.total_speed_north * + IC.total_speed_north + + IC.total_speed_east * IC.total_speed_east)) * SG_RADIANS_TO_DEGREES; } @@ -323,3 +322,4 @@ SubmodelSystem::updatelat(double lat) // end of submodel.cxx + diff --git a/src/Systems/submodel.hxx b/src/Systems/submodel.hxx index d5cb3ecf8..b7155034f 100644 --- a/src/Systems/submodel.hxx +++ b/src/Systems/submodel.hxx @@ -127,3 +127,4 @@ private: }; #endif // __SYSTEMS_SUBMODEL_HXX + -- 2.39.5