get point coordinates based on direction and distance (vector)

女生的网名这么多〃 提交于 2019-12-03 07:36:43

问题


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.


回答1:


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

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

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

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.



来源:https://stackoverflow.com/questions/12959237/get-point-coordinates-based-on-direction-and-distance-vector

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!