Intro

description

Explanation

This is the closed-form ballistic solution for hitting a static target with constant gravity.

Steps:

  1. Compute displacement (Note: the pseudocode has it backwards) [ \Delta = end - start ]

  2. Solve a quadratic in (t^2) derived from projectile motion.

  3. The two solutions correspond to:

    • high arc
    • low arc
  4. Pick the smallest positive time.

  5. Plug that time into the velocity equation to compute the launch direction vector.

The final vector is the normalized firing direction scaled by muzzle velocity.

Derivation

It is the same equations from Ballistic Trajectory for Static Target rearranged into a quadratic that solves for time automatically.


1. Kinematic Equation

Projectile motion with gravity:

To hit a target:

Rearrange:


2. Solve for the launch velocity

Rearranging for :

But the muzzle speed is fixed:

So you square both sides:

Substitute the velocity expression.

That produces a quartic in , which simplifies to a quadratic in .


3. Millington’s trick

Millington defines

Then solves the quadratic

with

Then he solves it using the quadratic formula.


4. Why the pseudocode looks weird

Because it solves

Then takes

which is why you see:


time = sqrt(...)
time1 = sqrt(...)


5. Final velocity formula

Once time is known:

That’s exactly the line in the pseudocode.


Millington just:

  • algebraically simplified it
  • packaged it into a stable closed-form algorithm for games

Millington Static Target Method — Derivation

This is the same physics as Ballistic Trajectory for Static Target, but rearranged to produce a closed-form solution for time.


Projectile Motion

Projectile position under constant gravity:

To hit the target:

Rearrange:


Solve for Launch Velocity

The projectile speed is fixed:

Square both sides:

Substitute the velocity expression:

This simplifies to a quartic in , which becomes a quadratic in .


Quadratic Form

Let

Then the equation becomes:

Quadratic coefficients:


Transition to Millington’s Form

For implementation, Millington multiplies the entire equation by 4 to remove the fraction:

This produces the coefficients used in the pseudocode:


Solve for Time

Using the quadratic formula:

Since

Two solutions correspond to:

  • low arc
  • high arc

Final Firing Velocity

Once is known: