admin管理员组文章数量:1026231
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 ma after cos(lat1) does? I read that in javascript it is used to assign the value after the a to a variable while still evaluating the first expression, although in the above code the expression before the ma is not stored?
Any help on converting this to java or understanding what the ma does?
The original maths formula also has a ma
φ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) )
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 ma after cos(lat1) does? I read that in javascript it is used to assign the value after the a to a variable while still evaluating the first expression, although in the above code the expression before the ma is not stored?
Any help on converting this to java or understanding what the ma does?
The original maths formula also has a ma
φ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) )
Share
Improve this question
edited Jan 14, 2013 at 14:12
Danilo Valente
11.4k8 gold badges54 silver badges70 bronze badges
asked Jan 14, 2013 at 14:11
drunkmonkeydrunkmonkey
1,1911 gold badge17 silver badges27 bronze badges
3 Answers
Reset to default 11It's not an operator, it's simply separating the two arguments to atan2
. It's exactly the same in Java.
(Recall that atan2
takes the x
and y
ponents separately, in order to resolve rotational ambiguity.)
Math.atan2
method accepts two arguments. Comma simply separates it.
Math.atan2(y, x)
Returns the arctangent of the quotient of its arguments.
Reference:
- https://developer.mozilla/en-US/docs/JavaScript/Reference/Global_Objects/Math/atan2
The only change required is to give the variables a type.
double lat2 = Math.asin(Math.sin(lat1) * Math.cos(d / R) +
Math.cos(lat1) * Math.sin(d / R) * Math.cos(brng));
double lon2 = lon1 + Math.atan2(Math.sin(brng) * Math.sin(d / R) * Math.cos(lat1),
Math.cos(d / R) - Math.sin(lat1) * Math.sin(lat2));
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 ma after cos(lat1) does? I read that in javascript it is used to assign the value after the a to a variable while still evaluating the first expression, although in the above code the expression before the ma is not stored?
Any help on converting this to java or understanding what the ma does?
The original maths formula also has a ma
φ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) )
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 ma after cos(lat1) does? I read that in javascript it is used to assign the value after the a to a variable while still evaluating the first expression, although in the above code the expression before the ma is not stored?
Any help on converting this to java or understanding what the ma does?
The original maths formula also has a ma
φ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) )
Share
Improve this question
edited Jan 14, 2013 at 14:12
Danilo Valente
11.4k8 gold badges54 silver badges70 bronze badges
asked Jan 14, 2013 at 14:11
drunkmonkeydrunkmonkey
1,1911 gold badge17 silver badges27 bronze badges
3 Answers
Reset to default 11It's not an operator, it's simply separating the two arguments to atan2
. It's exactly the same in Java.
(Recall that atan2
takes the x
and y
ponents separately, in order to resolve rotational ambiguity.)
Math.atan2
method accepts two arguments. Comma simply separates it.
Math.atan2(y, x)
Returns the arctangent of the quotient of its arguments.
Reference:
- https://developer.mozilla/en-US/docs/JavaScript/Reference/Global_Objects/Math/atan2
The only change required is to give the variables a type.
double lat2 = Math.asin(Math.sin(lat1) * Math.cos(d / R) +
Math.cos(lat1) * Math.sin(d / R) * Math.cos(brng));
double lon2 = lon1 + Math.atan2(Math.sin(brng) * Math.sin(d / R) * Math.cos(lat1),
Math.cos(d / R) - Math.sin(lat1) * Math.sin(lat2));
本文标签: javascript comma operator in javaStack Overflow
版权声明:本文标题:javascript comma operator in java - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745630547a2160137.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论