Fix to keep longitude between -180 ... 180.
This commit is contained in:
parent
780a3c6831
commit
2375ae99e3
1 changed files with 13 additions and 3 deletions
|
@ -23,6 +23,8 @@
|
||||||
|
|
||||||
#include "LaRCsim.hxx"
|
#include "LaRCsim.hxx"
|
||||||
|
|
||||||
|
#include <Include/fg_constants.h>
|
||||||
|
|
||||||
#include <Aircraft/aircraft.hxx>
|
#include <Aircraft/aircraft.hxx>
|
||||||
#include <Controls/controls.hxx>
|
#include <Controls/controls.hxx>
|
||||||
#include <Debug/logstream.hxx>
|
#include <Debug/logstream.hxx>
|
||||||
|
@ -328,11 +330,19 @@ int fgLaRCsim_2_FGInterface (FGInterface& f) {
|
||||||
<< " lat_geoc = " << Lat_geocentric << " lat_geod = " << Latitude
|
<< " lat_geoc = " << Lat_geocentric << " lat_geod = " << Latitude
|
||||||
<< " alt = " << Altitude << " sl_radius = " << Sea_level_radius
|
<< " alt = " << Altitude << " sl_radius = " << Sea_level_radius
|
||||||
<< " radius_to_vehicle = " << Radius_to_vehicle );
|
<< " radius_to_vehicle = " << Radius_to_vehicle );
|
||||||
|
|
||||||
|
double tmp_lon_geoc = Lon_geocentric;
|
||||||
|
while ( tmp_lon_geoc < -FG_PI ) { tmp_lon_geoc += FG_2PI; }
|
||||||
|
while ( tmp_lon_geoc > FG_PI ) { tmp_lon_geoc -= FG_2PI; }
|
||||||
|
|
||||||
|
double tmp_lon = Longitude;
|
||||||
|
while ( tmp_lon < -FG_PI ) { tmp_lon += FG_2PI; }
|
||||||
|
while ( tmp_lon > FG_PI ) { tmp_lon -= FG_2PI; }
|
||||||
|
|
||||||
// Positions
|
// Positions
|
||||||
f.set_Geocentric_Position( Lat_geocentric, Lon_geocentric,
|
f.set_Geocentric_Position( Lat_geocentric, tmp_lon_geoc,
|
||||||
Radius_to_vehicle );
|
Radius_to_vehicle );
|
||||||
f.set_Geodetic_Position( Latitude, Longitude, Altitude );
|
f.set_Geodetic_Position( Latitude, tmp_lon, Altitude );
|
||||||
f.set_Euler_Angles( Phi, Theta, Psi );
|
f.set_Euler_Angles( Phi, Theta, Psi );
|
||||||
|
|
||||||
// Miscellaneous quantities
|
// Miscellaneous quantities
|
||||||
|
|
Loading…
Reference in a new issue