根据速度计算角方向
我正在尝试计算射弹的角方向,知道它的 X 和 Y 速度,我可以找到其运动的幅度,但我很难集中精力获得它的角方向(以弧度为单位)正在移动...
我认为涉及晒黑或罪恶,但除此之外我有点无能为力...
I'm trying to calculate the angular direction of a projectile, knowing it's X and Y velocity I can find the magnitude of its movement, but I'm having a hard time wrapping my mind around getting the angular direction (in radians) that it is moving...
I assume there is a tan or a sin involved, but I'm a bit clueless otherwise...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可能对
Math.atan2
感兴趣。给定原点周围的
x
和y
,它将返回角度。例如,它确实考虑了方向,因此您不必担心
1 / 1
或-1 / -1
(这通常会导致相同的角度)。You might be interested in
Math.atan2
.Given an
x
andy
around the origin, it will return the angle. E.g.It does take the direction into account, so you don't have to worry about
1 / 1
or-1 / -1
(which would normally result in the same angle).tan-1(y/x)
不知道你是否考虑了重力等等。
tan-1(y/x)
Don't know if you're taking gravity into consideration and so.