I’m trying to convert the following javascript to java
var lat2 = Math.asin( Math.sin(lat1)*Math.cos(d/R) +
Math.cos(lat1)*Math.sin(d/R)*Math.cos(brng) );
var lon2 = lon1 + Math.atan2(Math.sin(brng)*Math.sin(d/R)*Math.cos(lat1),
Math.cos(d/R)-Math.sin(lat1)*Math.sin(lat2));
it’s all fairly simple except I’m unsure what the comma after cos(lat1) does?
I read that in javascript it is used to assign the value after the coma to a variable while still evaluating the first expression, although in the above code the expression before the comma is not stored?
Any help on converting this to java or understanding what the comma does?
The original maths formula also has a comma
φ2 = asin( sin(φ1)*cos(d/R) + cos(φ1)*sin(d/R)*cos(θ) )
λ2 = λ1 + atan2( sin(θ)*sin(d/R)*cos(φ1), cos(d/R)−sin(φ1)*sin(φ2) )
It’s not an operator, it’s simply separating the two arguments to
atan2. It’s exactly the same in Java.(Recall that
atan2takes thexandycomponents separately, in order to resolve rotational ambiguity.)