SimApi Convertor getTerrainHeight

From SIMboxWiki
Jump to navigation Jump to search



Icon attributes.pngstatic float SimApi::Convertor::getTerrainHeight(const float &x, const float &y)

    Description

    Gets the terrain height of a particular point.

    Parameters

    x - The X coordinate of world local coordinates system (meters)
    y - The Y coordinate of world local coordinates system (meters)

    Return

    Type: float   Description: The height of the terrain in the point (meters)

    Remarks
    

The return value is the height of the terrain loaded by the simulation in given coordinates. See "Terrain" for more information on terrains in simulation.


    Code Sample
    

          float HeightAboveGround(float i_X, float i_Y, float i_Height)
{
	//get Terrain height
	float terrainHeight = SimApi::Convertor::getTerrainHeight(i_X,i_Y);
	 
	//compute height above ground
	float heightAboveGround = i_Height - terrainHeight;
	
	return heightAboveGround;
}

int main(int argc, char* argv[])
{
	// Latitude and Longitude in radians
	double lat = 0.6283; // == 36 degrees 
	double lon =  -2.0071; // == -115 degrees
	float height = 3500;
	
	float heightAboveGround = HeightAboveGround(lon,lat,height);
	
	cout<<"Height above ground: "<<heightAboveGround<<endl;
	return 0;
}


Output:
-------

Height above ground: 2758.4456


    See Also

     getTerrainHeightGlobal

    Related Links

     SIMbox Coordinates Systems Overview

     Terrain