问题
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