SimApi Convertor globalToLocal

From SIMboxWiki
Jump to navigation Jump to search

Icon attributes.pngstatic void SimApi::Convertor::globalToLocal(const double &longitude, const double &latitude, float &x, float &y)


    Converts world global coordinates (given in WGS84 format) to world local coordinates.


    longitude - Longitude world global coordinate (radians)
    latitude - Latitude world global coordinate (radians)
    x - The X coordinate of world local coordinates system (meters)
    y - The Y coordinate of world local coordinates system (meters)


    Type: void   Description: Local coordinates in the x,y parameters (meters)


Simulation uses SIMBox (local) coordinate system called 'World Local' for position representation and computation. Objects position is often given in 'World Global' coordinate system (entity settings form example). When using SIMBox simulation API, you must convert WGS84 coordinates to 'WorldLocal' coordinates that are used by SIMBox simulation API. See "SIMBox Coordinates Systems" for more information.

    Code Sample

          void MyConversion(double i_Longitude, double i_Latitude)
	float x = 0.0;
	float y = 0.0;

	//convert world global position to world local

	//print results
	cout<<"Position X: "<<x<<endl;
	cout<<"Position Y: "<<y<<endl;

int main(int argc, char* argv[])
	// Latitude and Longitude in degrees
	double lat = 36;
	double lon = -115;
	//Convert from degrees to radians
	lat = lat * PI / 180;
	lon = lon * PI / 180;

	MyConversion(lon, lat);
	return 0;


Position X: -7252.3706
Position Y: 2415.3342

    See Also


    Related Links

     SIMbox Coordinates Systems Overview