Java - 三角学地狱
我的任务是能够用 Java 编写一个类来计算从北到某个点的方位角。唯一已知的物体有 2 个位置,两者的方位角和距离均为 0。例如,位置 1 - 30 度和 10m,位置 2 - 190 度和 50m。例如,如果您想从位置 1 行驶到位置 2 或从位置 2 行驶到位置 1,您将如何计算方位角?我可以使用余弦规则计算两个位置之间的距离,但不知道如何创建一个能够在不同场景下准确计算方位的类?
任何帮助或建议将不胜感激。
I have a task of being able to program a Class in Java to calculate the bearing from North to a point. The only objects that are known are 2 positions, both have a bearing from North and the distance from 0. So for example - position 1 - 30 degrees and 10m, position 2 - 190 degrees and 50m. How would you calculate the bearing if you wanted to travel from position 1 to position 2 for instance or from position 2 to 1? I can calculate the distance between the 2 positions using the cosine rule, but have no idea how to create a class that will accuratly calculate the bearing in different scenarios?
Any help or advise would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
来自http://en.wikipedia.org/wiki/Law_of_cosines#Applications:
< img src="https://i.sstatic.net/E7DwF.png" alt="在此处输入图像描述">
...一旦您获得了所有三个边长,这将为您提供第三个角度你的三角形。
(半正矢公式用于球体上的导航......我认为我们只是担心平面上的向量。)
From http://en.wikipedia.org/wiki/Law_of_cosines#Applications:
...once you have all three side lengths, this will give you the third angle of your triangle.
(The Haversine formula is for navigation on a sphere... I think we're just worried about vectors on a plane.)
我相信您正在寻找的是 Haversine 公式,谷歌搜索它会产生各种语言的实现。
I believe what you are looking for is the Haversine formula, googling it will yield implementations in various languages.
这是从此处给出的 javascript 解决方案移植的 java 版本:
在 Javascript 中使用半正矢公式 作者:talkol
This is a java version ported from a javascript solution given here:
Using the Haversine Formula in Javascript by talkol