Using a Quartic Equation to Find Parabolic Projectile Paths

That hideous image at the top of this post is the solution to a “quartic” equation. That’s just like the “quadratic formula” that you learned in high school algebra class, except the quartic has x4 in it, instead of just x2. In order to create realistic paths for things that accelerate, I took on the challenge of simplifying that monster down to something useful.

If you look in the bottom-right corner, you can see the fully simplified version that I’m using in the game. It’s probably overkill, but it gives my rocket projectiles some very realistic curving paths as they home in on their targets.

I tried to avoid spending the time (I think it took four or five days) to do all the math, but the more simple solutions weren’t reliable. The simplest approach that I tried was just “fly directly towards the target.” The problem with that approach is that with realistic physics, you won’t hit the target – you’ll usually go into orbit around it. The Earth is constantly pulling the Moon towards itself, but the Moon’s inertia won’t allow it to just fall directly down in a straight line, thankfully!

The same was happening when I just accelerated the rockets directly toward their target. They almost always fell into an elliptical orbit around the target. But the quartic solution does exactly the right thing most of the time. Sometimes, the rocket will slightly miss the target, but then it reverses and comes back to hit it. I also just think it looks cool.

If anyone would like to see the full solution, I could post it to Math StackExchange. I started a thread there, asking for help with the algebra.

Fire some curvy homing rockets in version

One thought on “Using a Quartic Equation to Find Parabolic Projectile Paths”

Leave a Reply

Your email address will not be published.