calculate distance between two points

mrkrishnan
Global Mapper User
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
-
While there's no API to calculate the 3D distance, just calculate the 2D distanced with GM_CalcDistance, then just use the Pythagorean theorem to add the altitude. Your 3D distance can be calculated as:
alt_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 -
thanks mike. i am using that formula only. i just want to conform weather any API is available or not?
-
No, there is not any API available for 3D distance calculation.
Thanks,
Mike
Global Mapper Support
support@globalmapper.com -
I have made an example distance calculate but it always returns 0,
this is my script:
double aDist;GlobalMapperDLL.GM_CalcDistance(159.09988, 200.99877, 176.09987, 225.9887, 201, out aDist);
Plz, show tell what wrong i did.
many thanks -
The call for GM_CalcDistance is:public static extern GM_Error_t32 GM_CalcDistance(double aFromX, // IN: start X/longitude coordinatedouble aFromY, // IN: start Y/latitude coordinatedouble aToX, // IN: stop X/longitude coordinatedouble aToY, // IN: stop Y/latitude coordinatebyte aLatLon, // IN: TRUE - coordinates are lat/lon, FALSE - coordinates are in the current projection?out double aDist // OUT: distance in meters between the points);
I'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.
Categories
- 12.4K All Categories
- 5.4K Features Discussion
- 314 Downloading Imagery
- 1.3K Elevation Data
- 377 Georeferencing Imagery Discussion
- 603 GM Script Language
- 49 User Scripts
- 112 GPS Features
- 394 Projection Questions
- 800 Raster Data
- 1.3K Vector Data
- 6.5K Support
- 161 Announcement and News
- 890 Bug Report
- 556 SDK
- 1.2K Suggestion Box
- 3.7K Technical Support
- 537 Other Discussion
- 128 GIS Data Sources
- 26 Global Mapper Showcase
- 224 How I use Global Mapper
- 104 Global Mapper Forum Website