]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/MagicCarpet.cxx
Updates from the Jon and Tony show.
[flightgear.git] / src / FDM / MagicCarpet.cxx
index 995486fd1051a352b85cbe430623497fed93841b..7964c7a41a333d7bffaad2cbc42de99cc748e84a 100644 (file)
@@ -61,11 +61,18 @@ int FGMagicCarpet::update( int multiloop ) {
     set_Euler_Angles( get_Phi(), get_Theta(), fmod(get_Psi() + turn, FG_2PI) );
 
     // update (lon/lat) position
-    Point3D start( get_Longitude(), get_Latitude(), 0.0 );
-    Point3D end = calc_lon_lat( start, -get_Psi(), dist );
-
-    set_Longitude( end.x() );
-    set_Latitude( end.y() );
+    double lat2, lon2, az2;
+    geo_direct_wgs_84 ( get_Altitude(),
+                       get_Latitude() * RAD_TO_DEG,
+                       get_Longitude() * RAD_TO_DEG,
+                       get_Psi() * RAD_TO_DEG,
+                       dist, &lat2, &lon2, &az2 );
+    set_Longitude( lon2 * DEG_TO_RAD );
+    set_Latitude( lat2 * DEG_TO_RAD );
+
+    // cout << "lon error = " << fabs(end.x()*RAD_TO_DEG - lon2)
+    //      << "  lat error = " << fabs(end.y()*RAD_TO_DEG - lat2)
+    //      << endl;
 
     double sl_radius, lat_geoc;
     fgGeodToGeoc( get_Latitude(), get_Altitude(), &sl_radius, &lat_geoc );
@@ -77,8 +84,10 @@ int FGMagicCarpet::update( int multiloop ) {
 
     set_Geocentric_Position( lat_geoc, get_Longitude(), 
                             sl_radius + get_Altitude() + climb );
-    set_Geodetic_Position( end.y(), end.x(), 
-                          get_Altitude() + climb );
+    // cout << "sea level radius (ft) = " << sl_radius << endl;
+    // cout << "(setto) sea level radius (ft) = " << get_Sea_level_radius() << endl;
+    set_Sea_level_radius( sl_radius * METER_TO_FEET);
+    set_Altitude( get_Altitude() + climb );
 
     return 1;
 }