gpt4 book ai didi

algorithm - 通过代码求解弹道方程

转载 作者:塔克拉玛干 更新时间:2023-11-03 06:02:00 25 4
gpt4 key购买 nike

这似乎是一个解决起来非常简单的问题,但我发现的关于它的一切都太复杂了,我无法理解。

我有这个基本的弹道方程:

ballistic trajectory

鉴于我知道 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com