eclipse中使用J2ME中的acos函数出现问题

发布于 2024-12-03 17:00:12 字数 526 浏览 1 评论 0原文

“我在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

爱的那么颓废 2024-12-10 17:00:12
public static double acos(double a)
{
    final double epsilon=1.0E-7; 
    double x=a;
    do {
        x-=(Math.sin(x)-a)/Math.cos(x);
    }
    while (Math.abs(Math.sin(x)-a)>epsilon);

    // returned angle is in radians
    return -1*(x-Math.PI/2);
}
public static double acos(double a)
{
    final double epsilon=1.0E-7; 
    double x=a;
    do {
        x-=(Math.sin(x)-a)/Math.cos(x);
    }
    while (Math.abs(Math.sin(x)-a)>epsilon);

    // returned angle is in radians
    return -1*(x-Math.PI/2);
}
琉璃梦幻 2024-12-10 17:00:12

您可以尝试实现反余弦,如此处所示。

You could try to implement the arccosine as shown here.

帅的被狗咬 2024-12-10 17:00:12

如果您有可用的位置 API,则可以使用 Cooperatives 类中的距离方法。从坐标 API:

public float distance(Coordinates to)

计算两点之间的大地距离
根据WGS84的椭球模型。
计算中忽略了高度。
实现应尽可能准确地计算此值。
但要求结果与正确结果的误差在0.35%以内。

If you have the Location API available you can use the distance method from the Coordinates class. From the Coordinates API:

public float distance(Coordinates to)

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文