导弹、宇宙飞船的空间物理 - 学习微积分版

发布于 2024-12-05 01:28:55 字数 1115 浏览 2 评论 0原文

假设我们有导弹 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

白龙吟 2024-12-12 01:28:55

导弹的二维运动方程为(假设从 t=0 开始)

[ mpx(t) = mpx(0) + mvx*t , mpy(t) = mpy(0) + mvy*t ]

飞船运动为

[ spx(t) = spx(0) + svx*t , spy(t) = spy(0) + svy*t ]

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)

[ mpx(t) = mpx(0) + mvx*t , mpy(t) = mpy(0) + mvy*t ]

the spaceship motion is

[ spx(t) = spx(0) + svx*t , spy(t) = spy(0) + svy*t ]

where mpx(0) mpy(0) spx(0) spy(0) are the initial position components

So to intersect you must have mpx(t)=spx(t) and mpy(t)=spy(t). Which is two equations to solve for two unknowns. One may be the time to intercept t, and the other the direction of the missile given by slope=mvy/mvx. Or it could be the initial position of the missle mpx(0) and mpy(0), or the velocity components given a target intercept time.

It is not clear from the question what you a looking for.

愁杀 2024-12-12 01:28:55

瞬时解

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 corresponding t', given the power of the motor you can calculate the time t'' taken to deliver that change in velocity. Add this t''*Ship_Velocity to get an updated target position. Iterate.

起风了 2024-12-12 01:28:55

如果你有 mp、mv 和 sp,那么计算 sv 和 t:

mp+mv(t)=sp+sv(t) and |sv|=q (maxspeed)
mp+mv(t)-sp+sv(t)=0

mpx+mvx*t-spx+svx*t=0
mpy+mvy*t-spy+svy*t=0

svx^2+svy^2=q^2
svx^2+svy^2-q^2=0

然后我们可以解决:

(mpx-spx)/t+mvx=svx
(mpy-spy)/t+mvy=svy

((mpx-spx)/t+mvx)^2+((mpy-spy)/t+mvy)^2=q^2
(mpx-spx)^2/t^2+2*mvx*(mpx-spx)/t+mvx^2+(mpy-spy)^2/t^2+2*mvy*(mpy-spy)/t+mvy^2=q^2
((mpx-spx)^2+(mpy-spy)^2)/t^2+(2*mvx*(mpx-spx)+2*mvy*(mpy-spy))/t+mvx^2+mvy^2-q^2=0
((mpx-spx)^2+(mpy-spy)^2)+(2*mvx*(mpx-spx)+2*mvy*(mpy-spy))*t+(mvx^2+mvy^2-q^2)*t^2=0
((mpx-spx)^2+(mpy-spy)^2)/(mvx^2+mvy^2-q^2)+(2*mvx*(mpx-spx)+2*mvy*(mpy-spy))/(mvx^2+mvy^2-q^2)*t+t^2=0

c = (mvx^2+mvy^2-q^2)
if   a = (2*mvx*(mpx-spx)+2*mvy*(mpy-spy))/c
and  b = ((mpx-spx)^2+(mpy-spy)^2)/c
then t = -a/2+-sqrt(a^2/4-b)

a/2 = (2*mvx*(mpx-spx)+2*mvy*(mpy-spy))/2c
a/2 = (mvx*(mpx-spx)+mvy*(mpy-spy))/c
a^2/4 = (mvx^2*(mpx-spx)^2+2*mvx*(mpx-spx)*mvy*(mpy-spy)+mvy^2*(mpy-spy)^2)/c^2

b/c^2=((mpx-spx)^2+(mpy-spy)^2)*c
b/c^2=((mpx-spx)^2+(mpy-spy)^2)*(mvx^2+mvy^2-q^2)
b/c^2=mvx^2(mpx-spx)^2+mvx^2(mpy-spy)^2+mvy^2(mpx-spx)^2+mvy^2(mpy-spy)^2-q^2(mpx-spx)^2-q^2(mpy-spy)^2

t = -(mvx*(mpx-spx)+mvy*(mpy-spy))/c +- sqrt((mvx^2*(mpx-spx)^2+2*mvx*(mpx-spx)*mvy*(mpy-spy)+mvy^2*(mpy-spy)^2)-(mvx^2(mpx-spx)^2+mvx^2(mpy-spy)^2+mvy^2(mpx-spx)^2+mvy^2(mpy-spy)^2-q^2(mpx-spx)^2-q^2(mpy-spy)^2))/c

t = -(mvx*(mpx-spx)+mvy*(mpy-spy))/c +- sqrt((2*mvx*(mpx-spx)*mvy*(mpy-spy))-(mvx^2(mpy-spy)^2+mvy^2(mpx-spx)^2)+q^2((mpx-spx)^2+(mpy-spy)^2)))/c

t = -(mvx*(mpx-spx)+mvy*(mpy-spy))/c +- sqrt(-(mvx(mpy-spy)-mvy(mpx-spx))^2+q^2((mpx-spx)^2+(mpy-spy)^2)))/c

t = -(mvx*(mpx-spx)+mvy*(mpy-spy))/c +- sqrt(-(mvx(mpy-spy)-mvy(mpx-spx))^2+q^2(c+q^2))/c
t = -(mvx*(mpx-spx)+mvy*(mpy-spy))/c +- sqrt(-(mvx(mpy-spy)-mvy(mpx-spx))^2+q^2(c+q^2))/c

t = -(mvx*(mpx-spx)+mvy*(mpy-spy))/c +- sqrt(-(mvx(mpy-spy)-mvy(mpx-spx))^2+q^2(c+q^2))/(mvx^2+mvy^2-q^2)

我没有时间进一步简化,但它可以完成,或者只是评估它。

然后将 t 代入:

svx=(mpx-spx)/t+mvx
svy=(mpy-spy)/t+mvy

以获得 s 向量。

也许我在某个地方做错了......

If you have mp, mv and sp, then to calculate sv and t:

mp+mv(t)=sp+sv(t) and |sv|=q (maxspeed)
mp+mv(t)-sp+sv(t)=0

mpx+mvx*t-spx+svx*t=0
mpy+mvy*t-spy+svy*t=0

svx^2+svy^2=q^2
svx^2+svy^2-q^2=0

Which we then can solve:

(mpx-spx)/t+mvx=svx
(mpy-spy)/t+mvy=svy

((mpx-spx)/t+mvx)^2+((mpy-spy)/t+mvy)^2=q^2
(mpx-spx)^2/t^2+2*mvx*(mpx-spx)/t+mvx^2+(mpy-spy)^2/t^2+2*mvy*(mpy-spy)/t+mvy^2=q^2
((mpx-spx)^2+(mpy-spy)^2)/t^2+(2*mvx*(mpx-spx)+2*mvy*(mpy-spy))/t+mvx^2+mvy^2-q^2=0
((mpx-spx)^2+(mpy-spy)^2)+(2*mvx*(mpx-spx)+2*mvy*(mpy-spy))*t+(mvx^2+mvy^2-q^2)*t^2=0
((mpx-spx)^2+(mpy-spy)^2)/(mvx^2+mvy^2-q^2)+(2*mvx*(mpx-spx)+2*mvy*(mpy-spy))/(mvx^2+mvy^2-q^2)*t+t^2=0

c = (mvx^2+mvy^2-q^2)
if   a = (2*mvx*(mpx-spx)+2*mvy*(mpy-spy))/c
and  b = ((mpx-spx)^2+(mpy-spy)^2)/c
then t = -a/2+-sqrt(a^2/4-b)

a/2 = (2*mvx*(mpx-spx)+2*mvy*(mpy-spy))/2c
a/2 = (mvx*(mpx-spx)+mvy*(mpy-spy))/c
a^2/4 = (mvx^2*(mpx-spx)^2+2*mvx*(mpx-spx)*mvy*(mpy-spy)+mvy^2*(mpy-spy)^2)/c^2

b/c^2=((mpx-spx)^2+(mpy-spy)^2)*c
b/c^2=((mpx-spx)^2+(mpy-spy)^2)*(mvx^2+mvy^2-q^2)
b/c^2=mvx^2(mpx-spx)^2+mvx^2(mpy-spy)^2+mvy^2(mpx-spx)^2+mvy^2(mpy-spy)^2-q^2(mpx-spx)^2-q^2(mpy-spy)^2

t = -(mvx*(mpx-spx)+mvy*(mpy-spy))/c +- sqrt((mvx^2*(mpx-spx)^2+2*mvx*(mpx-spx)*mvy*(mpy-spy)+mvy^2*(mpy-spy)^2)-(mvx^2(mpx-spx)^2+mvx^2(mpy-spy)^2+mvy^2(mpx-spx)^2+mvy^2(mpy-spy)^2-q^2(mpx-spx)^2-q^2(mpy-spy)^2))/c

t = -(mvx*(mpx-spx)+mvy*(mpy-spy))/c +- sqrt((2*mvx*(mpx-spx)*mvy*(mpy-spy))-(mvx^2(mpy-spy)^2+mvy^2(mpx-spx)^2)+q^2((mpx-spx)^2+(mpy-spy)^2)))/c

t = -(mvx*(mpx-spx)+mvy*(mpy-spy))/c +- sqrt(-(mvx(mpy-spy)-mvy(mpx-spx))^2+q^2((mpx-spx)^2+(mpy-spy)^2)))/c

t = -(mvx*(mpx-spx)+mvy*(mpy-spy))/c +- sqrt(-(mvx(mpy-spy)-mvy(mpx-spx))^2+q^2(c+q^2))/c
t = -(mvx*(mpx-spx)+mvy*(mpy-spy))/c +- sqrt(-(mvx(mpy-spy)-mvy(mpx-spx))^2+q^2(c+q^2))/c

t = -(mvx*(mpx-spx)+mvy*(mpy-spy))/c +- sqrt(-(mvx(mpy-spy)-mvy(mpx-spx))^2+q^2(c+q^2))/(mvx^2+mvy^2-q^2)

I don't have time to simplify further, but it can be done, or just evaluate it.

Then plug t back into:

svx=(mpx-spx)/t+mvx
svy=(mpy-spy)/t+mvy

To get the s vector.

Maybe I've done a mistake somewhere...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文