# calculate distance between two points

mrkrishnan
Global Mapper UserPosts:

**29**
hai

i want to calculate the distance between two points which are in Latitude, longitude and altitude format. I saw an API in Global mapper GM_calcDistance - which will convert the value only with respect to latitude and longitude, But i want to calculate with respect to altitude also.

Example: Position 1: Lat: 31 Long:35 Altitude:1000

Position 1: Lat: 32 Long:37 Altitude:5000

Is there any API to calculate like this?

If not how can i calculate?

Regards

Radhakrishnan

i want to calculate the distance between two points which are in Latitude, longitude and altitude format. I saw an API in Global mapper GM_calcDistance - which will convert the value only with respect to latitude and longitude, But i want to calculate with respect to altitude also.

Example: Position 1: Lat: 31 Long:35 Altitude:1000

Position 1: Lat: 32 Long:37 Altitude:5000

Is there any API to calculate like this?

If not how can i calculate?

Regards

Radhakrishnan

## Comments

17,238alt_diff = end_altitude - start_altitude; // 5000 - 1000 in your case

3d_dist = sqrt( 2d_dist * 2d_dist + alt_diff * alt_diff );

Be sure to check that your altitude units and distance units are the same before doing this.

Thanks,

Mike

Global Mapper Support

support@globalmapper.com

2917,238Thanks,

Mike

Global Mapper Support

support@globalmapper.com

2this is my script:

double aDist;

Plz, show tell what wrong i did.

many thanks

30Trusted UserI'm not sure what your coordinates should be but you are passing 201 as a byte which is effectively a bool value to select whether you are lat/lon or the current coordinate system. That means that it is saying true for using lat/lon but your x and y are greater than lat/lon should be.