Yem*_*lat 26 javascript math canvas vector polar-coordinates

我需要找到第二点的坐标.我知道弧度点之间的角度,我也知道矢量的长度.
如果有人能指出我的解决方案,我真的很感激.
mjv*_*mjv 38
给定L作为矢量的长度,Ang作为角度
x2 = x1 + Math.cos(Ang) * L
y2 = y1 + Math.sin(Ang) * L
Run Code Online (Sandbox Code Playgroud)
哎呀...我刚刚注意到Y轴的从上到下的方向...... Konstantin Levin,你需要稍微调整,因为上面的公式假设一个典型的三角坐标系.在您的情况下,公式应为:
x2 = x1 + Math.cos(Ang) * L // unchanged
y2 = y1 - Math.sin(Ang) * L // minus on the Sin
Run Code Online (Sandbox Code Playgroud)
另外(毋庸置疑,也有人说它......)参考角度应该是这样当y2 == y1和x2> x1时,Ang应该为零,并且当第二个点移动时它应该增加 - 围绕第一个.