回复:导弹,宇宙飞船的空间物理学 [英] Re: Space physics for missiles, spaceships

查看:117
本文介绍了回复:导弹,宇宙飞船的空间物理学的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这篇相当有用的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非常有用,例如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. http://www.wolframalpha.com/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.com/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.

这篇关于回复:导弹,宇宙飞船的空间物理学的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆