Conversion between geographic and FS XY coordinates
Often it is needed to convert between geographic (latitude and longitude) coordinates and the XY coordinates relative to a reference point. These are for example used in GMax. With the formulas given below it is possible to convert between those two systems.
Geographic to XY
This formula gives the XY coordinates from a given reference point for a set of geographic coordinates.
x = (lon - lon_ref) * (40075000.0 / (2.0 * PI)) * Cos(lat_ref) y = (lat - lat_ref) * (40007000.0 / (2.0 * PI))
Where (lat_ref, lon_ref) is the reference point and (lat, lon) is the geographic location of which you want to know the XY coordinates. Be aware that the formula assumes all geographic coordinates are given in radians.
XY to Geographic
This formula gives the geographic coordinates for a XY offset from the reference point.
lat = lat_ref + y / (40007000.0 / (2.0 * PI)) lon = lon_ref + x / ((40075000.0 / (2.0 * PI)) * Cos(lat_ref))
Where (lat_ref, lon_ref) is the reference point and (x,y) the XY offset from this reference point of which you want to know the geographic coordinates. Be aware that the formula assumes all geographic coordinates are given in radians.