回复:导弹,宇宙飞船的空间物理学

编程入门 行业动态 更新时间:2024-10-22 19:44:07
本文介绍了回复:导弹,宇宙飞船的空间物理学的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在这篇相当有用的CodeProject文章中,一个有进取心和非常有帮助的人完成了牛顿导弹击中牛顿目标所需的数学运算(它还可以使飞船之间的航向和速度相匹配,并且需要一点点输入).

我过去用这写过的一本书是在多达数百艘飞船(块)之间互相发射导弹(块)之间的战斗.相当整齐.

但是,它仅适用于纯粹的牛顿飞行器,正如大多数空间模拟器中关注飞行的任何人都可以告诉您(或喜欢推测性FTL方法的人)那样,牛顿并不是唯一的飞行方式.

在我看来,有了所有这些出色的计算机硬件,应该有一个计算机程序可以使用,例如,p + v * t + 0.5 * a * t * t = P + V * t + 0.5 * A * t * t并吐出方程式,这将为您提供t和A(或a,具体取决于跟踪者位于左侧还是右侧).

Algebrator离我发现的位置最近(MATLAB可以使其胜任,但我确实没有$ 2,100的预算),但是如果我用1-collumn,2-row替代,这会令人窒息向量矩阵". (我有4.2,而不是5)

所以-帮我在星际大屠杀吗?我不是击败MiB的邪恶外星霸主,保证! :D

我不是在寻找解决方案方程式;我正在寻找可以为我提供这些求解方程式的软件.

谢谢.

解决方案

我仍然不确定您要做什么.如果您想在代码编写时求解代数方程,则Wolfram Alpha非常有用,例如 www.wolframalpha/input/?i=Solve%5Bq0+%2B+v0 + t +%2B + a0%2F2 + t%5E2 +%3D%3D + q1 +%2B + v1 + t +%2B + a1%2F2 + t%5E2%2C%7Ba1%2Ct%7D%5D . /p>

如果要在运行时求解代数方程式,通常这是一个非常棘手的问题.如果您为我提供了有关您要做什么的更多详细信息,我也许可以推荐一些不错的免费软件包.

您可能想解决的示例问题:

问:给定一艘初始位置为q0,初始速度为v0且加速度恒定为a0的太空船,以及一艘初始位置为q1的导弹,我想找到大小为M的导弹速度v1,这将导致导弹最终与飞船.

A:您正在尝试求解方程组

q0 + v0 t + 1/2 a0 t^2 = q1 + v1 t v1 . v1 = M^2

对于向量v1的

,其中的冲击时间t也未知.据我所知,这个系统很难以封闭形式解决:Wolfram Alpha对此感到窒息,甚至Mathematica也很难.然而,用数值方法来攻击它是相对简单的.为此,我们首先将第一个方程式插入第二个方程式来求解t:

(q0 - q1 + v0 t + 1/2 a0 t^2) . (q0 - q1 + v0 t + 1/2 a0 t^2) == M^2 t^2

这是t的四次多项式,具有已知系数:

[(q0 - q1).(q0-q1)] + [2 (q0 - q1).v0] t + [v0.v0 + (q0-q1).a0 - M^2] t^2 + [v0.a0] t^3 + [1/4 a0.a0] t^4 = 0

括号中的所有内容都是标量,您可以根据已知数量进行计算.要查找此四次方的根,请使用黑盒根求解器(我强烈建议您在www.crbond/download/misc/rpoly.cpp上找到Jenkins-Traub:C ++代码,Java和Fortran版本也浮动在'net).

一旦有了根,就选择最小的正正负号(该正负号将与使导弹尽可能早地撞击飞船的方向相对应)并将其插入第一个方程式,并轻松求出v1.

>

问:给定一艘初始位置为q0,初始速度为v0且恒加速度为a0的飞船,以及一艘初始位置为q1且初始速度为v1的导弹,我想找到大小为M的导弹加速度a1,它将导致导弹最终与飞船相撞.

A:这个问题与第一个非常相似.您的方程式现在是

q0 + v0 t + 1/2 a0 t^2 = q1 + v1 t + 1/2 a1 t^2 a1 . a1 = M^2

其中a1和t未知.同样,可以将这些等式组合起来以得到已知系数的t的四次方:

[(q0 - q1).(q0-q1)] + [2 (q0 - q1).(v0-v1)] t + [(v0-v1).(v0-v1) + (q0-q1).a0] t^2 + [(v0-v1).a0] t^3 + [1/4 a0.a0 - 1/4 M^2] t^4 = 0

再次,使用詹金斯-特劳布(Jenkins-Traub)查找根,然后将最小的正根插入第一个方程中,并求解a1.

In this rather useful CodeProject article, an enterprising and very helpful person has done the math needed for a newtonian missile to hit a newtonian target (it also works for matching course and speed between spaceships, with a bit of fiddling of inputs).

One of the things I've written with this in the past is a battle between up to hundreds of spaceships (blocks), firing missiles (blocks) at each other. Quite neat.

However, it only works for purely newtonian craft and, as anyone who's paid attention to flight in most space simulators can tell you (or who likes speculative FTL methods), newtonian isn't the only way to fly.

And it seems to me that, with all this wonderful computer hardware, there should be a computer program that can take, say, p+v*t+0.5*a*t*t = P+V*t+0.5*A*t*t and spit out equations that will give you t and A (or a, depending on whether the pursuer is on the left or the right).

Algebrator comes closest that I've found (MATLAB might be able to ace it, but I do Not have a $2,100 budget), but chokes if I substitute in 1-collumn, 2-row vector "matrices". (I have 4.2, not 5)

So - Help me wreak carnage among the stars? I'm not an evil alien overlord out to defeat the MiB, promise! :D

Edit: I'm not looking for solution equations; I'm looking for software that can give me those solution equations.

Thanks.

解决方案

I'm still not completely sure what you are trying to do. If you want to solve an algebraic equation at code-writing time, Wolfram Alpha is quite useful, e.g. www.wolframalpha/input/?i=Solve%5Bq0+%2B+v0+t+%2B+a0%2F2+t%5E2+%3D%3D+q1+%2B+v1+t+%2B+a1%2F2+t%5E2%2C%7Ba1%2Ct%7D%5D.

If you want to solve an algebraic equation at runtime, that is a very hard problem in general. If you give me more details about exactly what you are trying to do, I might be able to recommend some good free packages.

EDIT: Example problem you might be trying to solve:

Q: Given a spaceship with initial position q0, initial velocity v0, and constant acceleration a0, and a missile with initial position q1, I want to find the missile velocity v1 with magnitude M that will cause the missile to eventually collide with the spaceship.

A: You are trying to solve the system of equations

q0 + v0 t + 1/2 a0 t^2 = q1 + v1 t v1 . v1 = M^2

for the vector v1, where the time of impact t is also unknown. This system is very difficult to solve in closed form, as far as I can tell: Wolfram Alpha chokes on it, and even Mathematica has a hard time. It is, however, relatively simply to attack it with numerical methods. To do so we first solve for t by plugging the first equation into the second:

(q0 - q1 + v0 t + 1/2 a0 t^2) . (q0 - q1 + v0 t + 1/2 a0 t^2) == M^2 t^2

This is a quartic polynomial in t with known coefficients:

[(q0 - q1).(q0-q1)] + [2 (q0 - q1).v0] t + [v0.v0 + (q0-q1).a0 - M^2] t^2 + [v0.a0] t^3 + [1/4 a0.a0] t^4 = 0

Everything in brackets is a scalar you can compute from known quantities. To find the roots of this quartic, use a black-box root solver (I highly recommend Jenkins-Traub: C++ code available at www.crbond/download/misc/rpoly.cpp, Java and Fortran versions are also floating around the 'net).

Once you have the roots, choose the smallest positive one (this one will correpond to the direction that makes the missile hit the spaceship as early as possible) and plug it into the first equation, and trivially solve for v1.

EDIT2:

Q: Given a spaceship with initial position q0, initial velocity v0, and constant acceleration a0, and a missile with initial position q1 and initial velocity v1, I want to find the missile acceleration a1 with magnitude M that will cause the missile to eventually collide with the spaceship.

A: This problem is very similar to the first; your equations now is

q0 + v0 t + 1/2 a0 t^2 = q1 + v1 t + 1/2 a1 t^2 a1 . a1 = M^2

Where a1 and t are unknown. Again, these equations can be combined to get a quartic in t with known coefficients:

[(q0 - q1).(q0-q1)] + [2 (q0 - q1).(v0-v1)] t + [(v0-v1).(v0-v1) + (q0-q1).a0] t^2 + [(v0-v1).a0] t^3 + [1/4 a0.a0 - 1/4 M^2] t^4 = 0

Again, use Jenkins-Traub to find the roots, then plug in the smallest positive root into the first equation, and solve for a1.

更多推荐

回复:导弹,宇宙飞船的空间物理学

本文发布于:2023-06-04 19:10:06,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/503362.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:宇宙飞船   物理学   导弹   空间

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!