This used to work. I have no idea how YY ends-up being a "method" (function pointer).
try {
var XX = Math.cos(radLat1) * Math.sin(radLat2) - Math.sin(radLat1) * Math.cos(radLat2) * Math.cos(radLonDelta);
System.println("XX="+XX);
var YY1 = Math.sin(radLonDelta.toDouble());
System.println("YY1="+YY1);
var YY2 = Math.cos(radLat2.toDouble());
System.println("YY2="+YY2);
var YY = YY1.toDouble() * YY2.toDouble();
System.println("YY="+YY);
var ZZ = Math.atan2(YY, XX); // Reversed argument order than in Excel.
System.println("ccc3");
// bearing = (Math.toDegrees(ZZ).toLong()+360) % 360;
}
ccc
XX=-0.002073
YY1=0.000449
YY2=0.755157
YY=method
Cannot convert object to Double
Invalid Value