]> git.mxchange.org Git - flightgear.git/commitdiff
Vivian Meazza:
authorehofman <ehofman>
Fri, 17 Sep 2004 16:32:58 +0000 (16:32 +0000)
committerehofman <ehofman>
Fri, 17 Sep 2004 16:32:58 +0000 (16:32 +0000)
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
src/AIModel/AIBallistic.hxx
src/AIModel/AIManager.cxx
src/Systems/submodel.cxx
src/Systems/submodel.hxx

index 4b2b51c7ac4f9966a1c748316be9d8d98d4b93ed..bd0c8530f5753c5a316aa26e219b4188f91696a3 100644 (file)
@@ -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
index 8a230b3c79e5e74e79dc21d910b82b2f29d15a7d..54f08215bdf980c737e14ed23611ed98d3efedfa 100644 (file)
@@ -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
index a4a713a7da08a2e928c8ee90db1d861fd3de0b81..c5a34bdeb84c498e70978d76e60f94ce7d713ae4 100644 (file)
@@ -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;
index b2a2171a7067bfbeb55fe9d5d486f541d3db7818..d405e63d453f29c3851406da44a73813e809ddbb 100644 (file)
@@ -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
 
 
+
index d5cb3ecf8404c8940c5afdd7021e06403667c657..b7155034f7f4d59a89523bff41f842973b94d04f 100644 (file)
@@ -127,3 +127,4 @@ private:
 };
 
 #endif // __SYSTEMS_SUBMODEL_HXX
+