导弹、宇宙飞船的空间物理 - 学习微积分版
假设我们有导弹 A,具有位置矢量和速度大小(忽略加速度,就像许多游戏一样)和宇宙飞船 B,具有位置和速度矢量。现在,这枚导弹,作为一个讨厌的寻找导弹,将尝试为宇宙飞船B找到最佳拦截。
导弹A有两个优点:它懂微积分,它可以计算多项式的根。然而,导弹,或者抽象地说,程序员,仍在学习微积分,并想知道他是否有正确的方程。 (多项式根将由一个叫 Jenkins-Traub 的好人解决,代码由 Netlib 实现)
即:
mp = 导弹位置
mv = 导弹速度
sp = 太空飞船位置
sv = 太空飞船速度
t = Time
根据程序员的最佳猜测,截距方程为: tspsv + tspmv - tmpsv - tmpmv
但我很确定我我完全走错了路,因为在这场混乱中可能应该有一些指数;这是尝试解决: (sp-mp)(sv-mv)(t)
我的另一个选择是区分 (sp-mp)(sv-mv)^2,但我想首先获得反馈,部分原因是,除非我弄错了,'( sp-mp)' 解析为 '1'。这看起来……很奇怪。 OTOH,该函数变化的速度可能就是我正在寻找的。
那么 - 我做错了什么,错在哪里,为什么?
谢谢。
编辑:
总结方程:
(a +bx) + (c+ex)
(a+1bx^0) + (c+1ex^0)
(a+1) + (c+1)
无效。
方程的乘积:
(a+bx)(c+ex)
ac+aex+cbx+bex^2
不是多项式(无法用 Jenkins-Traub 求解)并且看起来不太正确。
ac+1aex^0+1cbx^0+2bex^1
ac+ae+cb+2bex
我认为绝对不是这样。
Supposing we have Missile A, with a position vector and velocity magnitude (ignoring acceleration, as many games do) and Spaceship B, with position and velocity vectors. Now, this missile, being a Nasty Missile of Seeking, will try to find the best intercept for Spaceship B.
Missile A has two advantages: It knows calculus and it can calculate the roots of polynomials. However, the missile, or to abstract, the programmer, is still learning calculus and wants to know if he has the right equation. (Polynomial roots will be solved by a nice fellow called Jenkins-Traub Code Implemented From Netlib)
To wit:
mp = Missile Position
mv = Missile Velocity
sp = Spaceship Position
sv = Spaceship Velocity
t = Time
According to the programmer's best guess, the equation for intercept is:
tspsv + tspmv - tmpsv - tmpmv
Except I'm pretty sure I'm headed down the wrong track entirely, as there should probably be some exponents in that mess; this being an attempt at solving:
(sp-mp)(sv-mv)(t)
My other option is differentiating (sp-mp)(sv-mv)^2, but I wanted to get feedback first, partly because, unless I'm mistaken, '(sp-mp)' resolves to '1'. And that seems...Odd. OTOH, the rate at which that function is changing might be what I'm looking for.
So - What have I gotten wrong, where and why?
Thanks.
Potentially-useful link to first thread.
Edit:
Summing the equations:
(a+bx) + (c+ex)
(a+1bx^0) + (c+1ex^0)
(a+1) + (c+1)
Non-viable.
Product of the equations:
(a+bx)(c+ex)
ac+aex+cbx+bex^2
Not a polynomial (can't solve with Jenkins-Traub) and doesn't quite look right.
ac+1aex^0+1cbx^0+2bex^1
ac+ae+cb+2bex
And definitely not that, I think.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
导弹的二维运动方程为(假设从 t=0 开始)
飞船运动为
mpx(0)
mpy(0)
spx(0 )
spy(0)
是初始位置分量因此要相交,您必须有
mpx(t)=spx(t)
和mpy(t)=spy(t)
。这是求解两个未知数的两个方程。一个可能是拦截t
的时间,另一个可能是由slope=mvy/mvx
给出的导弹方向。或者它可以是导弹mpx(0)
和mpy(0)
的初始位置,或者给定目标拦截时间的速度分量。从问题中尚不清楚您要寻找什么。
The 2D equations of motion for the missile are (assume starting at t=0)
the spaceship motion is
where
mpx(0)
mpy(0)
spx(0)
spy(0)
are the initial position componentsSo to intersect you must have
mpx(t)=spx(t)
andmpy(t)=spy(t)
. Which is two equations to solve for two unknowns. One may be the time to interceptt
, and the other the direction of the missile given byslope=mvy/mvx
. Or it could be the initial position of the misslempx(0)
andmpy(0)
, or the velocity components given a target intercept time.It is not clear from the question what you a looking for.
瞬时解
Position_Ship + t*Velocity_Ship = Position_Missile + t*Velocity_Missile
如果它们设置为拦截,那么您可以轻松地在任一维度上求解
t
。如果您想确定
Velocity_Missile
,我们还需要一个约束。N = (Position_Missile - Position_Ship) ^ Velocity_Ship
(叉积)N dot Velocity_Missle = 0
这将为您提供一对或线性联立方程。
动态解决方案
如果最初给定
Velocity_Missile
,并且我们想要应用加速直到进入限制半径内,那么它就会变得棘手。您可以使用简单的追求曲线获得美观的解决方案,或者我们可以得到数值...让
Velocity_Missile'
为上面的瞬时解决方案,导出相应的t'
,给定电机的功率,您可以计算出传递速度变化所需的时间t''
。添加此t''*Ship_Velocity
以获取更新的目标位置。迭代。Instantaneous Solution
Position_Ship + t*Velocity_Ship = Position_Missile + t*Velocity_Missile
If they are set to intercept then you can trivially solve for
t
over either dimension.If you want to determine
Velocity_Missile
we need one more constraint.N = (Position_Missile - Position_Ship) ^ Velocity_Ship
(cross-product)N dot Velocity_Missle = 0
This will give you a pair or linear simultaneous equations.
Dynamic Solution
If the
Velocity_Missile
is initially given and we want to apply accelleration until we get within a limiting radius, then it becomes thorny. You can get an aesthetically pleasing solution using a simple curve of persuit, or we can get numerical...Let
Velocity_Missile'
be the instantaneous solutions from above, derive the correspondingt'
, given the power of the motor you can calculate the timet''
taken to deliver that change in velocity. Add thist''*Ship_Velocity
to get an updated target position. Iterate.如果你有 mp、mv 和 sp,那么计算 sv 和 t:
然后我们可以解决:
我没有时间进一步简化,但它可以完成,或者只是评估它。
然后将 t 代入:
以获得 s 向量。
也许我在某个地方做错了......
If you have mp, mv and sp, then to calculate sv and t:
Which we then can solve:
I don't have time to simplify further, but it can be done, or just evaluate it.
Then plug t back into:
To get the s vector.
Maybe I've done a mistake somewhere...