eclipse中使用J2ME中的acos函数出现问题
“我在 eclipse 中使用 J2ME,需要使用属于 Math 包的方法 acos()
,问题是该包可用于 J2ME 数学不是那个函数(手机的限制),那么我需要一种算法或方法来计算余弦,
我需要“acos”来计算以下公式:
long2 = cood[i].getLongitud();
lat2 = cood[i].getLatitud();
dlong = (long1 - long2);
c = dlong * degtorad;
dvalue = (Math.sin(a) * Math.sin(b))+(Math.cos(a) * Math.cos(b)*Math.cos(c));
dd = Math.acos(dvalue) * radtodeg;
km = (dd * 111.302);
该函数允许我从两个地理坐标到。计算之间的距离(以公里为单位)如果有另一种方法来计算这个距离(不使用余弦),我
对此也会有帮助吗?
"I'm working with J2ME in eclipse, and need to use the method acos()
belongs to the Math package, the question is that the package available for J2ME Math is not that function (limitations of mobiles), then I want an algorithm or method alternative to calculate the cosine.
I need the "acos" to calculate the following formula:
long2 = cood[i].getLongitud();
lat2 = cood[i].getLatitud();
dlong = (long1 - long2);
c = dlong * degtorad;
dvalue = (Math.sin(a) * Math.sin(b))+(Math.cos(a) * Math.cos(b)*Math.cos(c));
dd = Math.acos(dvalue) * radtodeg;
km = (dd * 111.302);
This function allows me from two geographical coordinates to calculate the distance in kilometers between them. If there is an alternative method to calculate this distance (where the cosine is not used), I also would be useful.
Any help on this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以尝试实现反余弦,如此处所示。
You could try to implement the arccosine as shown here.
如果您有可用的位置 API,则可以使用 Cooperatives 类中的距离方法。从坐标 API:
计算两点之间的大地距离
根据WGS84的椭球模型。
计算中忽略了高度。
实现应尽可能准确地计算此值。
但要求结果与正确结果的误差在0.35%以内。
If you have the Location API available you can use the distance method from the Coordinates class. From the Coordinates API:
Calculates the geodetic distance between the two points
according to the ellipsoid model of WGS84.
Altitude is neglected from calculations.
The implementation shall calculate this as exactly as it can.
However, it is required that the result is within 0.35% of the correct result.