Hello together,
I'm currently trying to calculate the distance between two positions in a widget. I've found this javaScript algorithm to do so but am not really sure how to translate it to MC:
var R = 6371000; // metres
var φ1 = lat1.toRadians();
var φ2 = lat2.toRadians();
var Δφ = (lat2-lat1).toRadians();
var Δλ = (lon2-lon1).toRadians();
var a = Math.sin(Δφ/2) * Math.sin(Δφ/2) +
Math.cos(φ1) * Math.cos(φ2) *
Math.sin(Δλ/2) * Math.sin(Δλ/2);
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
var d = R * c;
The problem is these two lines:
var Δφ = (lat2-lat1).toRadians();
var Δλ = (lon2-lon1).toRadians();
since I dont know how to convert the two subtracted degrees to radians.
Any help would be appreciated.