Hey all Unity developers and programmers i am developing a game where i need the length between two GPS-locations in KM.

lets say we have two locations points like this:

(87.090329, 25.883993)

(89.393944, 31.92494)

how can i get the length between these two positions? anyone know?

if you could code it for me in c#

Best Regards

The most common solution is to approximate using the Haversine formula.

Pseudo-code:

```
var a = sinÂ²(Î”Ï†/2) + cos Ï†1 * cos Ï†2 * sinÂ²(Î”Î»/2);
var c = 2 * atan2( âˆša, âˆš(1âˆ’a) );
var d = R * c;
```

where:

Ï† is latitude, Î» is longitude, R is radius of the Earth (use 6,371km if unsure)

The easiest way I would think is get a map of a place you needâ€¦

Such the entire USA.

Okay, find the points of GPS you would like.

Then find a line of sight distance, then divide the distance or something like that.

That way you can calculate the distance per grid.