Facebook
From Scorching Dove, 2 Months ago, written in Java.
Embed
Download Paste or View Raw
Hits: 52
  1. X = cos θb * sin ∆L
  2. Y = cos θa * sin θb – sin θa * cos θb * cos ∆L
  3. β = atan2(X,Y)
  4. Next, we must find the distance between the two latitude and longitude in Unity:
  5. var R = 6371e3; // metres
  6. var φ1 = lat1.toRadians();
  7. var φ2 = lat2.toRadians();
  8. var Δφ = (lat2-lat1).toRadians();
  9. var Δλ = (lon2-lon1).toRadians();
  10. var a = Math.sin(Δφ/2) * Math.sin(Δφ/2) +
  11. Math.cos(φ1) * Math.cos(φ2) *
  12. Math.sin(Δλ/2) * Math.sin(Δλ/2);
  13. var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
  14. var d = R * c;
  15.