Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Space Physics for missiles, spaceships - Learning Calculus edition

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.

like image 538
Narf the Mouse Avatar asked Nov 04 '22 14:11

Narf the Mouse


1 Answers

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.

like image 144
John Alexiou Avatar answered Nov 25 '22 01:11

John Alexiou