How to outrun a crashing alien spaceship

June 11, 2012

(This article was first published on Win-Vector Blog » R, and kindly contributed to R-bloggers)

Hollywood movies are obsessed with outrunning explosions and outrunning crashing alien spaceships. For explosions the movies give the optimal (but unusable) solution: run straight away. For crashing alien spaceships they give the same advice, but in this case it is wrong. We demonstrate the correct angle to flee.


Running from a crashing alien spaceship, Prometheus 2012, copyright 20th Century Fox
To flee an explosion the movies give the right advice: run straight away. They incorrectly give the impression that you can outrun a nearby explosion that expands faster than you run, but the advice is optimal.


Die Hard, copyright 20th Century Fox

However, for slower explosions this is useful advice.


Walk For Your Lives, Invader Zim, copyright Nickelodeon

But what about outrunning a crashing alien spaceship? Since the spaceship is not expanding the situation is no longer isotropic. Some directions may be better than others. In fact if the spaceship is moving faster than you, getting out of its way may be better than trying to outrun it. So we consider the following diagram of the situation:


If the crashing spaceship is approximated as a large red circle moving towards our astronaut (green circle) with a velocity “u” and our astronaut starts with a head start of “d” and a running speed of “v” at an angle “a” from the direction of motion of the spaceship. An angle of zero means the astronaut is running straight away (and hoping the spaceship will give up). Lets give quantities values. Let us say our olympic star astronaut can run (in space suit) at 6 meters per second, the crashing ship is moving at a cinematic 12 meters per second and our astronaut has a 240 meter head start. We can code up in R these values and a function that computes the distance between the two centers (spaceship and astronaut) as a function of time t and fleeing angle a:

v <- 6
u <- 12
d <- 240
distsq <- function(t,a) { (d+v*cos(a)*t - u*t)^2 + (v*sin(a)*t)^2 }

A little calculus and algebra lets us define a function that gives the time of closest approach for each angle of retreat:

topt <- function(a) { -d*(v*cos(a)-u)/((v*cos(a)-u)^2+(v*sin(a))^2) }

Plugging in the time of closest approach back into our distance function gives us the nearest distance encountered for each angle of retreat:

dmin <- function(a) { sqrt(distsq(topt(a),a)) }

We can plot this to get a glimpse of the best angle (notice both running away and running towards end up with the astronaut getting smushed since the astronaut is slower than the crashing alien spaceship):

df <- data.frame(angle=seq(from=0,to=pi,length.out=200))
df$mindist <- sapply(df$angle,dmin)
ggplot(df,aes(x=angle,y=mindist)) + geom_line()


This graph suggests that for this combination of initial distance and velocities the optimal fleeing angle is around 1 radian. We can solve for the optimal angle:


Which turns out to be:

[1] 1.047206

[1] 120

Or 1.047 radians with a closest approach of 120 meters. This already is an angle of fleeing that is more across than away. For even faster ships we would have optimal fleeing plans that are closer and closer to being at right angles to the direction of spaceship motion. For example if we had u=24 the optimal fleeing angle is 1.32 radians with a closest approach of 60 meters.

We sincerely hope that more movies will feature cybernetic characters capable of on the fly calculation and execution optimal fleeing (or pursuit) solutions.


Terminator’s view, copyright Orion Pictures

David Prometheus Robot

David, Prometheus, copyright 20th Century Fox

All images copyright their respective holders, included under fair use doctrine.

Related posts:

  1. Kernel Methods and Support Vector Machines de-Mystified
  2. The cranky guide to trying R packages
  3. Why I don’t like Dynamic Typing

To leave a comment for the author, please follow the link and comment on their blog: Win-Vector Blog » R. offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Tags: , , , , , ,

Comments are closed.

Recent popular posts


Mango solutions

RStudio homepage

Zero Inflated Models and Generalized Linear Mixed Models with R

Dommino data lab

Quantide: statistical consulting and training



CRC R books series

Six Sigma Online Training

Contact us if you wish to help support R-bloggers, and place your banner here.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)