作者热门文章
- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
这似乎是一个解决起来非常简单的问题,但我发现的关于它的一切都太复杂了,我无法理解。
我有这个基本的弹道方程:
鉴于我知道 v、g、x 和 y,我将如何找到 theta?在纸上很容易阅读,但我不知道如何用代码完成。
[编辑 #3:] 我的尝试(从下面的答案输入)是这样的:
gx = g*x
brackets = gx^2 + 2*y*v^2
sqrroot = sqrt( v^4 - g*brackets )
top1 = v^2 + sqrroot
theta1 = atan( top1 / gx )
top2 = v^2 - sqrroot
theta2 = atan( top2 / gx )
最佳答案
你忽略了一个解决方案 - 你有
top = v^2 + sqrroot
但您还需要重新计算
top = v^2 - sqrroot
考虑方程中的 ±
。
所以:
top1 = v^2 + sqrroot
top2 = v^2 - sqrroot
theta1 = atan(top1 / gx)
theta2 = atan(top2 / gx)
(我不知道你的代码中的 equation
是什么,但我假设你的意思是 top
)
关于algorithm - 通过代码求解弹道方程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17680065/
我正在使用 OpenGL 创建 3D 空间。我有一艘可以发射激光的宇宙飞船。 到目前为止,我已经掌握了它,以便激光一旦发射就会更深入 Z 轴。但是我正在尝试制作一个带有十字准线的正确瞄准系统,以便您可
我正在尝试制作一个运动行为在图中显示为红色的弹丸。 我现在知道和拥有的是两个向量;开始和结束。 最终目标是在迭代时使弧线具有一些随机性,并以 lerp 方式改变射弹速度。我以前做过几代线性运动,但没有
我是一名优秀的程序员,十分优秀!