本文介绍了根据方向和距离(矢量)获取点坐标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要找到第二点的坐标。我知道弧度点之间的角度,我也知道向量的长度

I need to find the coordinates of the second point. I know the angle between the points in radians and I also know the length of the vector.

我会真的很感激,如果有人能指出我的解决方案。

I would really appreciate if someone could point me towards the solution.

推荐答案

鉴于 L 作为向量的长度, Ang 角度

Given L as the length of the vector and Ang the angle

x2 = x1 + Math.cos(Ang) * L
y2 = y1 + Math.sin(Ang) * L

糟糕...我刚刚注意到Y轴从上到下的方向...
Konstantin Levin,你需要稍微调整一下,因为上面的公式假设一个典型的三角坐标系统。在您的情况下,公式应为:

Oops... I just noted the top to bottom orientation of the Y axis...Konstantin Levin, you will need adapt slightly because the formulas above assume a typical trigonometric coordinates system. In your case the formulas should be:

x2 = x1 + Math.cos(Ang) * L    // unchanged
y2 = y1 - Math.sin(Ang) * L    // minus on the Sin

此外(不言而喻,其中一个也说它......)参考角度应该是这样当y2 == y1和x2> x1时,Ang应该为零,并且当第二个点逆时针移动时它应该增加围绕第一个。

Also (what goes without saying, also goes in one says it...) the reference angle should be such that when y2 == y1 and x2 > x1, Ang should be zero, and it should increase as the second point is moved counter-clockwise around the first one.

这篇关于根据方向和距离(矢量)获取点坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-06 06:50