Access to this full-text is provided by Wiley.

Content available from

**International Journal of Computer Games Technology**This content is subject to copyright. Terms and conditions apply.

Research Article

Analytical Ballistic Trajectories with Approximately Linear Drag

Giliam J. P. de Carpentier

Linnaeusstraat 32 bis, 3553 CE Utrecht, e Netherlands

Correspondence should be addressed to Giliam J. P. de Carpentier; giliam@decarpentier.nl

Received April ; Accepted September ; Published January

Academic Editor: Jue Wang

Copyright © Giliam J. P. de Carpentier. is is an open access article distributed under the Creative Commons Attribution

License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly

cited.

is paper introduces a practical analytical approximation of projectile trajectories in D and D roughly based on a linear drag

model and explores a variety of dierent planning algorithms for these trajectories. Although the trajectories are only approximate,

they still capture manyof the characteristics of a real projectile in free fall under the inuence of an invariantwind, gravitational pull,

and terminal velocity, while the required math for these trajectories and planners is still simple enough to eciently run on almost

all modern hardware devices. Together, these properties make the proposed approach particularly useful for real-time applications

where accuracy and performance need to be carefully balanced, such as in computer games.

1. Introduction

A ballistic trajectory is the path of an object that is dropped,

thrown,served,launched,orshotbuthasnoactivepropul-

sion during its actual ight. Consequently, the trajectory is

fully determined by a given initial velocity and the eects

of gravity and air resistance. Mortars, bullets, particles, and

jumping computer game characters (between key presses) are

all examples of ballistics, while actively controlled aircra and

rocket-propelled grenades are not.

Describing the exact motion of an object in free fall

is a classic problem that can become quite complex when

including eects like drag, turbulence, height-dependent

medium pressure, position-dependent gravity, buoyancy, li,

and rotation. For this research paper, the problem will be

approached on a relatively pragmatic level, as it will be based

on a reasonably simple drag model that does not consider

the dynamics of projectile rotation and assumes that wind,

gravity, and terminal velocity all remain xed over the whole

trajectory. As a result, some accuracy will be sacriced for the

sake of computational eciency and exibility in practical

use, while still maintaining much of the essence of the

ballistic motion through a resistive medium. Although such

a choice does not make much sense for most scientic and

military applications, it does make sense for computer games,

where performance is typically more important than physical

correctness.

Currently, computer games hardly ever use trajectories

inuenced by air resistance when complex planning is

required. at might partially be because implementing a

computer player that is capable of quickly calculating the

ideal angle to re a mortar with a xed initial speed to

hit a given target, for example, is harder when having to

take into account drag and wind conditions. In fact, the

added complexity and computational intensity that would be

required for working with many of the current drag models

might simply not be justiable.

is paper introduces a trajectory model that is designed

totinthegapwhereworkingwithaccuratemodelswould

be too complex and working with simple dragless parabola-

shaped trajectories would be insucient. e proposed

model’s use and practicality will be demonstrated by covering

a number of its properties and showing how these trajectories

can be planned in a variety of ways.

In Section , previous work is shortly considered. In

Section , the new model will be introduced and qualitatively

compared to other models. In Section ,therstplanneris

covered. Other planners use a dierent space as explained in

Section and will be covered in Section . is is followed by

adiscussionofFutureWorkinSection ,theConclusionin

Hindawi Publishing Corporation

International Journal of Computer Games Technology

Volume 2014, Article ID 463489, 13 pages

http://dx.doi.org/10.1155/2014/463489

International Journal of Computer Games Technology

double GetTimeToTargetRWithMinimalInitialSpeed(double k, double vInfinity,

double rX, double rY) {

// 1. Start by getting coefficients for the function f(t) = a4∗t∧4+a3∗t∧3

// + a1∗t + a0 which is 0 at the sought time-to-target t. Solving f(t) = 0

// for t >0 is equivalent to solving e(u) = f(1/u)∗u∧4=a0∗u∧4+a1∗u∧3+

// a3∗u + a4 = 0 for u where u = 1 / t, but the latter is more well-behaved,

// being a strictly concave function for u >0 for any set of valid inputs,

// so solve e(u)=0 for u instead by converging from an upper bound towards

double kVInfinity = k ∗vInfinity, rr = rX ∗rX+rY∗rY; // the root and

double a0 = −rr, a1 = a0 ∗k,a3=k∗kVInfinity ∗rY; // return 1/u.

double a4 = kVInfinity ∗kVInfinity;

double maxInvRelError = 1.0E6; // Use an achievable inverse error bound.

double de, e, uDelta = 0;

// 2. Set u to an upper bound by solving e(u) with a3 = a1 = 0, clamped by

// the result of a Newton method’s iteration at u=0ifpositive.

double u = std::sqrt(kVInfinity / std::sqrt(rr));

if (rY <0) u = std::min(u, −vInfinity / rY);

// 3. Let u monotonically converge to e(u)’s positive root using a modified

// Newton’s method that speeds up convergence for double roots, but is likely

// to overshoot eventually. Here, “e”= e(u) and “de”= de(u)/du.

for (int it = 0; it <10; ++it, uDelta = e / de, u −= 1.9 ∗uDelta) {

de=a0∗u;e=de+a1;de=de+e;e=e∗u;

de=de∗u+e;e=e∗u+a3;de=de∗u+e;e=e∗u + a4;

if (!(e <0&&de<0)) break; // Overshot the root.

}u += 0.9 ∗uDelta; // Trace back to the unmodified Newton method’s output.

// 4. Continue to converge monotonically from the overestimated u to e(u)’s

// only positive root using Newton’s method.

for (int it = 0; uDelta ∗maxInvRelError >u&&it<10; ++it) {

de=a0∗u;e=de+a1;de=de+e;e=e∗u;

de=de∗u+e;e=e∗u+a3;de=de∗u+e;e=e∗u + a4;

uDelta = e / de; u −= uDelta;

}// 5. Return the solved time t to hit [rX, rY], or 0 if no solution exists.

return u >0?1/u: 0;

}

A : Specialized C++ Quartic Solver.

Section , and the References. e included Algorithms and

contain C++ functions that eciently solve the two most

complex planning problems.

2. Previous Work

e motion of ballistic projectiles has been covered in many

physics papers and textbooks, and all of these use their

own set of assumptions to create an approximate model of

theforcesactingonaprojectile.Althoughsomeballistics

research focuses on eects like shape and orientation [],

spin [], or (sub)orbital ight [], most works on ballistic

trajectories assume a xed gravitational pull and use a

simplied drag model. ese drag models typically ignore all

eects of in-ight rotation and are only dependent on the

local velocity relative to the medium and on a given xed

terminal velocity or drag coecient.

e used drag model inuences both realism and com-

putational complexity. For example, when no drag force is

applied, the trajectory will always be a parabola, which is

easy to work with and plan for. If the drag force is chosen

to be linear in velocity, an explicit function describing the

trajectory can be found by solving a set of linear dieren-

tial equations []. is transcendental function is already

computationally harder to calculate and even harder to plan

with (i.e., solve for) []. To approximate reality even better,

the drag force can be made quadratic in the object’s velocity

relative to the medium. But as no exact analytic solution for

the resulting trajectory exists, calculating a trajectory requires

either crude approximation or numerical integration, and

planning a trajectory requires reiteration [–].

e research in this paper is based on a novel approxi-

mation of the trajectory function that follows from the linear

drag model, sacricing some of its moderate accuracy for a

further increase in both eciency and exibility.

3. The Approximated Trajectory

3.1. Ballistic Parameters. Before presenting the proposed

trajectory function and its properties, the necessary ballistic

International Journal of Computer Games Technology

double GetTimeToTargetRGivenInitialSpeedS(double k, double vInfinity, double rX,

double rY, double s, bool highArc) {

// 1. Start by getting coefficients for the function f(t) = a4∗t∧4+a3∗t∧3

// + a2∗t∧2+a1∗t + a0 which is 0 at the sought time-to-target t. Solving

// f(t) = 0 for t >0 is equivalent to solving e(u) = f(1/u)∗u∧3=a0∗u∧3+

// a1∗u∧2+a2∗u + a3 + a4/u for u whereu=1/t,butthelatter is more

// well-behaved, being a strictly convex function for u >0 for any set of

// inputs iff a solution exists, so solve for e(u)=0instead by converging

// from a high or low bound towards the closest root and return 1/u.

double kRX = k ∗rX, kRY = k ∗rY, kRXSq = kRX ∗kRX, sS = s ∗s;

double twoKVInfinityRY = vInfinity ∗(kRY + kRY), kVInfinity = k ∗vInfinity;

double a0 = rX ∗rX + rY ∗rY,a1=(k+k)∗a0;

double a2 = kRXSq + kRY ∗kRY + twoKVInfinityRY −sS;

double a3 = twoKVInfinityRY ∗k, a4 = kVInfinity ∗kVInfinity;

double maxInvRelError = 1.0E6; // Use an achievable inverse error bound.

double maxV0YSq = sS −kRXSq;// maxV0YSq is the max squared “V0.y”that leaves

double e, de, u, uDelta = 0; // enough “V0.x”to reach rX horizontally.

// 2. Set u to a lower/upper bound for the high/low arc, respectively.

if (highArc) {// Get smallest u vertically moving rY at max possible +v0.y.

double minusB = std::sqrt(maxV0YSq) −kRY;

double determ = minusB ∗minusB −(twoKVInfinityRY + twoKVInfinityRY);

u = (kVInfinity + kVInfinity) / (minusB + std::sqrt(determ));

maxInvRelError = −maxInvRelError; // Convergence over negative slopes.

}else if (rY <0) {// Get largest u vertically moving rY at most neg. v0.y.

double minusB = −std::sqrt(maxV0YSq) −kRY;

double determ = minusB ∗minusB −(twoKVInfinityRY + twoKVInfinityRY);

u = (minusB −std::sqrt(determ)) / (rY + rY);

// Clamp the above bound by the largest u that reaches rX horizontally.

u = std::min(s / rX −k, u);

}elseu=s/std::sqrt(a0) −k; // Get the (largest) u hitting rX

// horizontally a.s.a.p. while launching in the direction of [rX,rY].

// 3. Let u monotonically converge to e(u)’s closest root using a modified

// Newton’s method, almost scaling the delta as if the solution is a double

int it = 0; // root. Note that “e”=e(u)∗u∧2and“de”= de(u)/du ∗u∧2.

for (; it <12; ++it, uDelta = e / de, u −= 1.9 ∗uDelta) {

de=a0∗u;e=de+a1;de=de+e;e=e∗u + a2; de = de ∗u+e;

e=e∗u+a3;e=(e∗u + a4) ∗u; de = de ∗u∗u−a4;

if (!(u >0&&de∗maxInvRelError >0&&e>0)) break; // Overshot.

}u+=0.9∗uDelta; // Trace back to unmodified Newton method’s output.

// 4. Continue to converge monotonically to e(u)’s closest root using

// Newton’s method from the last known conservative estimate on the convex

// function. (Note that in practice, u will have converged enough in <12

for (; u >0&&it<12; ++it) {// iterations iff a solution does exists.)

de=a0∗u;e=de+a1;de=de+e;e=e∗u + a2; de = de ∗u+e;

e=e∗u+a3;e=(e∗u + a4) ∗u; de = de ∗u∗u−a4;

uDelta = e / de; u −= uDelta;

if (!(de ∗maxInvRelError >0)) break; // Wrong side of the convex “dip”.

if (uDelta ∗maxInvRelError <u&&u>0) return 1 / u; // 5a. Found it!

}// 5b. If no solution was found, return 0. This only happens if s (minus

// a small epsilon) is too small to have a solution, the target is at the

return 0; // origin, or the parameters are so extreme they cause overflows.

}

A : Specialized C++ Quartic Solver.

International Journal of Computer Games Technology

parameters will be dened here rst. Starting with a general

note, vector variables in this paper are always distinguished

from scalar variables by the →symbol above their names.

Also, the length of any vector

is denoted as ‖

‖,whichis

equal to

⋅

,where⋅is the dot product.

A ballistic object is assumed to be launched from the

initial position

0with the initial velocity

V0at time =

0. Furthermore, the object will be travelling through a

medium (e.g., the air) which itself travels at the xed (wind)

velocity

Vmedium.Itisalsopulledbygravityatthexed

gravitational acceleration ,whichisroughly.m/s

2for

“earthly” applications. e amount of drag while moving

through the medium is dened as follows.

=1

2

Vterminal

.()

Here,

Vterminal is the invariant terminal velocity relative to

Vmedium that is reached eventually as the forces of gravity and

air resistance nally cancel each other out. On earth, that is

equivalent to saying that

Vterminal is the xed velocity that is

approached when the object is dropped from an enormous

height on a windless day. Lastly, the absolute terminal velocity

V∞,beingtheabsolutevelocityapproachedwhentimegoes

to ∞, is therefore

V∞=

Vterminal +

Vmedium.()

Togeth e r,

0,

V0,

V∞,anduniquely dene a trajectory

in the proposed model. To give a real-world example of

the parameters dened above, suppose a tennis ball with a

terminal velocity of m/s is served at m/s at a ∘angle

from the m high roof of the Empire State building into

a m/s horizontal wind in D. en,

0= [0,381],

V0=

[50cos(30∘),50sin(30∘)] ≈ [43.30,25], = 0.1635,and

V∞= [−10,−30]. e trajectory resulting from these values

is shown in Figure .

3.2. Deriving the Trajectory Function. In terms of the param-

eters dened above, the dierential equation for the exact

linear drag model has the following analytic solution:

linear ()=1

2

V0−

V∞1−−2𝑘𝑡+

V∞+

0.()

is function calculates the D or D position

linear on

a trajectory at time where ≥0.eabovefunctionis

far from new and will not be explained here in detail, as it

has already been covered in many textbooks [], occasionally

even targeting game developers in particular [](albeitwith

slightly dierent notation and parameter denitions).

e function above will not be used directly in this

paper. Instead, it will be approximated by substituting its

exponential function 𝑥with the rst degree rational function

(2+ )/(2 − ) shown in Figure .Oneofthereasonsfor

selecting this approximation over all possible other approx-

imations to 𝑥is that it has a value, rst derivative and second

derivative that match those of 𝑥at =0.ismeansthatit

approximates 𝑥near =0well and therefore will guarantee

a good approximation of

linear()near =0.Furthermore,

F : Serving a tennis ball from the Empire State Building

upwind.

the rst derivative of (2+)/(2−)monotonically decreases

from to as tends from to −∞,similartothe

rst derivative of 𝑥itself. When used to approximate 𝑥

in

linear(), this property will cause the initial velocity to

monotonically converge to the terminal velocity over time.

Note that no polynomial approximation of 𝑥has this specic

property, and of all possible rational functions that do possess

the above properties, the proposed approximation is the

simplest and thus the most ecient. Lastly, its inverse is also

a rst degree rational function, resulting in relatively simple

algebraic solutions for all (otherwise algebraic) equations that

useittoapproximate𝑥.

When the exponential function in

linear()is substituted

by the rational approximation, the following function is the

result

()=

V0+

V∞

1+ +

0.()

Because of the aforementioned properties,

()will not

only be more ecient to compute on modern computers,

but it will also still share many of its characteristics with

linear() and allow trajectory planning to be done with

relative ease. e remainder of this paper mainly revolves

around exploring these and other properties of

()together

with their implications.

3.3. A Qualitative Comparison. As

()is only an approxi-

mation, it will dier from the linear drag model’s trajectory

function it is based on, as well as from the results of other

models. For comparison purposes, the trajectories that follow

from launching three dierent sport balls using four dierent

International Journal of Computer Games Technology

F : Approximating 𝑥using a simple rational function.

models are plotted side by side in Figure . All balls are

launched at an ∘angle at m/s on a windless earthly day

( = 9.81m/s2). e dierent drag models are calibrated

to respect the respective ball’s terminal velocities (except for

the dragless model, which always has an innite terminal

velocity).

Each of the alternating thick and thin segments in the

trajectories shown in Figure (and in all other trajectory

plots in this paper, for that matter) represents a projectile’s

movement over a period of exactly one second, making it

possible to not only compare the shapes of the trajectories

but also their local speeds. e results from the novel

()

function are plotted in black, the results from the linear drag

model

linear() areplottedinblue,andtheresultsofthe

physically (most) correct quadratic drag model simulation

quadratic() are plotted in green. Lastly, the red parabola

dragless()represents the trajectory of each of the three balls

in a perfect vacuum (in other words, when there is no drag

and

V∞’s length goes to innite).

When comparing the trajectories for

()to the results

of the two more accurate drag models, they are certainly

dierent but they still reasonably mimic these in look,

feel, and properties. Consequently, the proposed model is

physically at least quite plausible and is probably accurate

enoughformostcomputergamepurposes.Furthermore,

in some cases,

() is actually closer to

quadratic() than

linear(), making it in these cases arguably even physically

more accurate than the model it is approximating to. Lastly,

the trajectories for all three drag models perfectly approach

dragless()when

V∞’s length go e s t o i n n i t e .

3.4. Exploring Some of p(t)’s Properties. e function

()

given by () can be factored, solved, and parameterized in

many dierent ways. For example, basic algebra allows it to

be written as

()=

V0+

as well, where =/(1+)and

=

V∞(−)+

0.Notethatinthisform,theinitialvelocityis

separated from all other factors, and it becomes immediately

clear that

()is a linear function in terms of

V0. is implies

that when launching multiple objects at some =0with all

properties equal except for the initial velocity, each of these

objects has the same value for and for

.isfeaturemaybe

exploited in particle explosion systems on modern GPUs, for

example, requiring only one evaluation of and

per frame

per explosion (layer) on the CPU and one MAD (multiply-

and-add) GPU instruction per particle per frame to calculate

each particle’s position.

e linearity of

() in terms of the initial velocity

V0

canalsobeusedformanyotherpurposes.Forexample,

in Figure ,

() is used to calculate the green and blue

positions for two dierent “extreme” initial velocities, which

are interpreted as the top-le and bottom-right positions of

a textured rectangle or quad.Notethatthe(signed)sizeof

the quad is thus simply

green() −

blue() = (

V0,green +

)− (

V0,blue +

) = (

V0,green −

V0,blue).Furthermore,all

the bilinearly interpolated texels within this quad, including

the red one, will move over

()trajectories themselves as well

by virtue of the linearity in terms of the initial velocities. In

other words, each texel will follow a

()trajectory with some

initial velocity that is interpolated bilinearly between the

dierent extreme initial velocities, as if the individual texels

themselves are under direct control of a physics simulation.

Consequently, it should be physically plausible to use the

above to scale sprites and billboards of, for example, simple

smoke (for which

V∞would typically be upwards to simulate

positive buoyancy), explosion debris, and reworks.

Many other useful properties can easily be derived from

()as well. For example, the velocity

V()of

()is

V()=

()

=

V0+(2+)

V∞

(1+)2.()

e nonnegative time top,⃗

𝑛at which the trajectory hits

its maximum in the direction of a given unit-length vector

can be found by solving

V()⋅

=0for assuming that the

direction to nd the maximum in is pointing away from

V∞

(i.e.,

V∞⋅

<0). If that assumption is false, then the top will

be at time =0. e solution to both cases is summarized by

the following formula:

top,⃗

𝑛=1−min 0,

V0⋅

/

V∞⋅

−1

.()

is top,⃗

𝑛maybeusedwith()togetthetrajectory’s

maximum position in the

direction. Note that when

is

axis-aligned, the dot products in ()canbeoptimizedaway.

For example, when

is equal to the +axis, then top,⃗

𝑛

becomes

top,𝑦 =1−min 0,

V0,𝑦/

V∞,𝑦−1

.()

See Figure for an example of

V()and

(top,𝑦).

International Journal of Computer Games Technology

F : e trajectories resulting from four models for three dierent ball types.

F : e trajectory of a textured quad.

4. Planning in World Space:

Hitting a Target at a Given Time

Whenaprojectileneedstohitsomegiventargetposition,

()

canbeusedtosolveor“plan”theinitialvelocitythatleadsto

precisely hitting this target at some given future point in time.

To be more specic, when trying to hit some position

at the

given time 𝑟,thesolutionisfoundbysolving

(𝑟)=

for

V0,

which results in the following formula:

V0=

−

0−

V∞𝑟+

−

0

𝑟.()

F : e velocity and -top of a trajectory.

In Figure , this formula is used to plan the trajectories to

six dierent target

positions, all taking exactly ten seconds

to reach their target. In other words, 𝑟=10,whichresultsin

having exactly ve thick and ve thin segments per trajectory

in this gure.

One interesting property of this function is that the

and components (or the ,,andcomponents in the

D case) of

V0are completely independent from each other.

As a direct consequence, similar projectiles that target the

International Journal of Computer Games Technology

F : Planning to hit all six dierent target positions in exactly

ten seconds.

same horizontal distance but a dierent height will always

move at the same horizontal speed over the whole trajectory

and vice versa. Also, trajectories for targets at equal height

but dierent horizontal distances will all have the same top

height, as can be observed in Figure as well.

Note that the given time parameter 𝑟could be any

positive value, including the one that is dependent on another

function of

. One simple example of such a function is 𝑟=

−

0/Vstraight,whereVstraight is a given average speed over

the straight line from

0to

.InFigure ,thisisillustrated

using Vstraight =25m/s.

Afunctionfor𝑟couldbemadearbitrarilycomplex.e

time planners that will be explored in Section are examples

of moderately complex functions, solving dierent additional

constraints for 𝑟given

.Butevenmorecomplexplanners

would be necessary if 𝑟and

were to be dependent on

each other. is can happen, for example, when a moving

targetneedstobehitwhileplanningtolaunchataxed

speed, making 𝑟inuence the prediction of the future target

position

,whichinuences𝑟again. ese relationships are

not explored in detail in this paper, but it is worth mentioning

that some of these problems may be solved iteratively by

starting with a rough estimate for 𝑟and then letting it

converge to the right solution by repeatedly going from 𝑟to

and from

to an improved 𝑟.eseiterationscouldpossibly

even be spread over multiple frames to amortize costs, for

example, improving accuracy with each new frame.

5. The Principal Frame of Reference

and Its Properties

Most planners for

()are still to be presented. However, as

these planners depend on a special frame of reference to keep

the required planner math as simple as possible, this frame of

reference will be covered here rst.

F : Planning trajectories to six targets, taking the exact same

time as travelling with m/s over the straight line from initial to

target position.

Inspecting

()reveals that the function always outputs

0plus a linear combination (i.e., a weighted sum) of

V0and

V∞. Geometrically, this implies that all trajectories, even with

wind coming from any D direction, are guaranteed to lie

on a plane spanned by

V0and

V∞which passes through

0.

Consequently,

()may be rewritten as

()=()

+()

+

0,()

where

and

, respectively, describe an orthonormal tangent

and bitangent direction in world space of the plane over

which the projectile moves. Within this plane’s D frame

of reference, the vector [(),()]describes the movement

on the trajectory over time relative to

0andintermsof

this alternative axis (i.e., the tangent) and axis (i.e., the

bitangent).

Put into terms perhaps more familiar to computer graph-

ics and game developers, the D function [(),()]is like a

procedural UV coordinate that denes a projectile’s location

on an unwrapped plane which maps UV [0,0] to

0and

has an orthonormal tangent vector

and bitangent vector

. All this is shown in Figure ,wherethetrajectory

()is

visualized as the intersection between the described plane (on

which is thus lies) and another curved surface.

Although there is an innite amount of ways to dene the

and

vectors, the following denitions are used in this

paper for their particularly useful properties:

=

−

⋅

−

⋅

,

=−

V∞

V∞.

()

International Journal of Computer Games Technology

F : A D trajectory with wind at an angle, and its decompo-

sition on the principal plane (in blue).

Here, V∞is used as a shorthand for

V∞.And

=

V0

if

V0is already known. In the case that

V0is not (yet) known,

any position relative to

0known to be lying on the trajectory

maybeusedfor

instead. For example, use

=

−

0when

targeting the position

.Notethatinthecasethat

V∞and

are collinear, the trajectory can be described by movement

solely in the

direction. To still get a valid D basis in that

case, an arbitrary vector that is noncollinear should be used

for

instead.

e frame of reference dened by

0,

,and

is what

will be called the trajectory’s principal space.Itiscalledthat

because this space allows the math describing the trajectory

to be decomposed into a particularly compact and well-

behaved form. In particular, wind and gravity do not aect

movement over the principal

axis at all, but solely over the

principal

axis. is allows the function () in ()tobe

simplied as will be shown and put to good use soon.

e second useful property of this principal space is that

it guarantees that V𝑥≥0. at is, all initial and in-ight

velocities expressed in principal space are guaranteed to have

nonnegative values on the axis, causing ballistic objects to

nevermovetoorbeonthenegativeside of this space, even

thoughtheyobviouslycanstillmoveinanydirectioninworld

space. Similarly, targets are never on the negative side in

principal space either. e advantage of this property is that

it once again will allow for further simplications in some of

the planner math that is still to be discussed.

e third useful property of this particular space is that

it is easy to convert from world space to principal space and

back as

and

are orthonormal. Converting from any world

space position

to the position [,]in principal space and

vice versa can simply be done using ()and(), respectively

as follows:

,=

−

0⋅

,

−

0⋅

, ()

=

+

+

0.()

Similarly, it is possible to eciently convert from any

world space velocity

Vto the principal velocity [V𝑥,V𝑦]and

back using ()and(), respectively as follows:

V𝑥,V𝑦=

V⋅

,

V⋅

, ()

V=V𝑥

+V𝑦

.()

Starting a new notational convention here for clarity,

vector names (i.e., variables decorated with a →symbol)

areonlyusedforvariablesinworldspace,whilevariables

in principal space never use this decoration and always

represent individual scalar quantities. So, for example,

V𝑥is

the component of the vector representing the world space

velocity

V,whileV𝑥is a scalar representing a velocity in the

direction in principal space.

Now that the frame of reference itself has been covered,

it is possible to dene the two scalar functions that make up

the principal space trajectory function [(),()]:

()=V0,𝑥

1+,()

()=V0,𝑦 −V∞

1+ .()

ese functions are derived by transforming

() into

this space using (). Note that gravity and wind do indeed

not aect movement over the direction in this space. And

[(0),(0)]is equal to [0,0], which means that trajectories in

principal space always start at the origin (while starting at

0

in world space).

e simpler formula for ()makes it possible to uniquely

invert the function to get the time at which the component

of a certain position will be reached given the horizontal

initial velocity. e solution is as follows:

=

V0,𝑥 −.()

Here, 0≤≤V0,𝑥/,asthatisthevalidrangeof()

for ≥0as dened by (). By plugging ()into(), the

following explicit -for-relationship is found:

()=V∞/−V0,𝑥+V0,𝑦

V0,𝑥 .()

is function always has exactly one value for each

valid value, which would not necessarily be true for

an explicit trajectory function in any other space. is

International Journal of Computer Games Technology

property is demonstrated in Figure ,showingatrajectory

that is equivalent to the trajectory shown in Figure but

which is now plotted using ()in principal space, perfectly

overlayingtheoriginaltrajectorywhenmappedbackinto

world space.

For completeness, the principal space counterparts of the

world space properties described by (), (), and ()aregiven

here as well. Consider

V𝑥()=V0,𝑥

(1+)2,

V𝑦()=V0,𝑦 −(2+)V∞

(1+)2,

top,⃗

𝑛

=1+max 0,V0,𝑥,V0,𝑦⋅𝑥,𝑦/V∞𝑦 −1

top,𝑦 =1+max 0,V0,𝑦/V∞,𝑦−1

.

()

Lastly, the local slope in principal space in terms of time

(i.e., V𝑦()/V𝑥())andintermsof(i.e., ()/)isas

follows:

V𝑦()

V𝑥()=V0,𝑦 −(2+)V∞

V0,𝑥 ,

()

=V0,𝑦 +V∞

V0,𝑥 −V0,𝑥V∞

−V0,𝑥2.()

6. Planning in Principal Space

As the planners in this section all depend on the properties of

trajectories in principal space, the most relevant properties

are briey repeated here. Per denition, any ballistic object

in principal space is launched from the origin, any target

has a nonnegative component, and the combined eect of

gravity and wind results in a V∞value that is exactly in the

−direction. As the planners will expect their parameters to

be specied in principal space, the parameters of any world

space problem need to be converted to this space before

they can be used. To recap the necessary steps (assuming

the problem involves hitting some target position

), start by

dening the actual principal space’s

and

axes using ()

with

=

−

0. Next, convert

(or any other requested

position)toprincipalspaceusing()toget[𝑥,𝑦].

All planners covered here will return the exact time 𝑟

at which the target [𝑥,𝑦]mustbehittomeettheplanner’s

given constraints. To get the actual initial velocity in principal

space that leads to hitting [𝑥,𝑦]at this 𝑟,both𝑥(𝑟)=

𝑥

F : e same Empire State Building trajectory example as

from Figure but seen from the principal frame of reference.

and 𝑦(𝑟)=𝑦need to be solved for [V0,𝑥,V0,𝑦],whichcanbe

done using the following two formulas:

V0,𝑥 =𝑥+ 1

𝑟, ()

V0,𝑦 =𝑦+ 1

𝑟+V∞𝑟.()

To get the initial velocity in world space from these, it is

possible to convert [V0,𝑥,V0,𝑦]to

V0using (). But

V0may also

be directly calculated from 𝑟and

through (). Now that it is

clear how to make use of principal space planners in general,

the actual planners are presented.

6.1.HittingtheTargetGivenAnotherPositiontoPassrough.

A trajectory can be planned to pass through both position

[𝑥,𝑦]and through target [𝑥,𝑦]by solving (𝑥)=

𝑦

and (𝑥)=

𝑦for V0,𝑥,andusing()on𝑥and V0,𝑥 to

get 𝑟.isspecicformofplanningmaybeusefultoshoot

through a hole or exactly over an object at [𝑥,𝑦]to hit

[𝑥,𝑦],example.esolutiontoatwhattimetheposition

[𝑥,𝑦]needstobehitisasfollows:

𝑟=++ 2𝑥

𝑥−𝑥, ()

where =(

𝑥𝑦−𝑦𝑥)/2V∞𝑥. Note that the line from the

origin to the target position with the smallest must be at

least as steep as the line from the origin to the position with

International Journal of Computer Games Technology

F : Planning trajectories through and six dierent

targets.

the largest for a valid trajectory (and thus a real solution) to

exist. at is, 𝑦/𝑥≥

𝑦/𝑥if 𝑥<

𝑥,and𝑦/𝑥≥

𝑦/𝑥if

𝑥>

𝑥.InFigure , two of the six targets do not meet this

requirement, explaining why there are only four trajectories

there.

6.2. Hitting the Target While Touching a Line. When looking

for the time 𝑟at which a trajector y passes through [𝑥,𝑦]and

touches the line =+in principal space, ()/=

hastobesolvedforrst,whichcanthenbeusedtosolve

()=+for V0,𝑥.BothV0,𝑥 and 𝑥canthenbeusedagain

with ()toget𝑟.esolutionmaybewrittenasfollows.

𝑟=+2+V∞𝑥−𝑦

V∞,()

where =V∞+(1/2)(𝑥−𝑦+).Notethatareal

solution can only exist when ≥0and 𝑥+≥𝑦.atis,

thelinemustalwayspassthroughorbeabovetheinitialand

the target position.

In the example presented in Figure ,thelinetobe

touched is chosen to be horizontal, leading to a specication

of the trajectories’ vertical tops in principal space. But it is

also possible to nd the 𝑟that leads to hitting a top dened

in another space. For example, to let a trajectory’s top touch

the world-space plane with normal

and through point

,=

+becomes the line in principal space that describes the

intersection between this plane and the trajectory’s principal

plane. In that case, =−(

⋅

)/(

⋅

)and =((

−

0)⋅

)/(

⋅

).Asalways,when

is axis-aligned, the dot products

can be optimized away. For example, when only interested

in trajectories exactly hitting a world space height at their

tops (in the +direction), this simplies to =−

𝑦/

𝑦and

=(−

0,𝑦)/

𝑦.

e principal space slope can also be calculated from

the slope of a world-space elevation angle world (i.e.,

F : Planning trajectories through six dierent targets, touch-

ing a line at each top.

=tan(world)) by using the conversion formula =

(sign(

𝑦)(

2

𝑦+

2

𝑦)−2−

𝑦

𝑦)/(

2

𝑦−

2),where

=1+

2and sign() = [ ≥ 0]−[ < 0].isis only

valid if an equivalent elevation with a positive component in

principal space exists, which is the case if (

2

𝑦+

2

𝑦)−2≥0

and [1,]⋅[1−

2

𝑦,

𝑦]>0.isworld-spaceelevation

conversionmaybeparticularlyusefulwhenusedtogether

with the next two principal-space planners.

6.3. Hitting the Target Given the Initial Slope. is subsection

is about nding the time 𝑟at which a projectile will hit

position [𝑥,𝑦]while being launched at slope .Planningthis

way may be useful when there is control over the projectile’s

initial speed but not over its direction (e.g., for some weapon

mounted on a xed rig).

is problem is actually simply a special case of the

previous planner, where =0, meaning that the problem

is equivalent to nding the trajectory that touches the line

=.Aersubstitutingin () and applying some

basic algebra, the solution may be written more compactly as

follows:

𝑟=++2V∞

V∞,()

where = (1/2)(𝑥−𝑦).Obviously,theslopehas to be

steeperthanthelinefromtheorigintothetargetposition

(i.e., >𝑦/𝑥) for a solution to exist, which is the case for all

but one target position in Figure .

6.4. Hitting the Target Given the Target Slope. Similarly, it is

possible to hit [𝑥,𝑦]given the exact slope at the target

position. is type of planning allows for exact control over

the angle at which a target is hit. Again, this can be seen as a

International Journal of Computer Games Technology

specialcaseoftheplannerfromSection .,using𝑦−𝑥as

the value for . When substituted and simplied, this results

in the following more direct formula:

𝑟=𝑦−𝑥

V∞.()

For this particular planner, the slope needs to be less

than the slope of the line from the origin to the target position

(i.e., <𝑦/𝑥). Consequently,only ve of the six targets have

a valid trajectory in Figure .

6.5. Hitting the Target Given the Arc Height or “Curviness”.

e time 𝑟canalsobecalculatedforatargetposition[𝑥,𝑦]

and an “arc height” .Here,is dened as the maximum

dierence in the direction between the trajectory and the

straight line from origin to target. Equivalently, may be

interpreted as the height in principal space of the smallest

parallelogram containing the whole trajectory, as shown in

Figure .isproblemisanotherspecialcaseofthe“line

touching” problem and can be solved by substituting 𝑦/𝑥

for in (). Aer applying some basic algebra, the resulting

formula may be written as follows:

𝑟=

V∞+2

V∞.()

is function is particularly intuitive to plan with when

=2

𝑥+2

𝑦,()

where denes the “cur viness” of the trajectory. For example,

=0.01a lways leads to a low arc for any target position, while

=0.5always leads to a fairly high arc.

6.6. Hitting the Target with (Almost) Minimal Eort. Atrajec-

torycanalsobeplannedtohitatargetat[𝑥,𝑦]with the

smallest initial speed (and thus the least amount of energy)

possible. Planning a trajectory this way requires nding the

positive time-to-target 𝑟which solves (V2

0,𝑥 +V2

0,𝑦)/𝑟=0,

where V0,𝑥 and V0,𝑦 are dened by ()and(), respectively.

is equation can be expanded into the following form:

2V2

∞4

𝑟+2V∞𝑦3

𝑟−2

𝑥+2

𝑦𝑟−2

𝑥+2

𝑦=0.

()

Like all quartic equations, solving this in a closed form is

possible but dicult to do robustly []. In practice, quartic

equations are typically solved for any or all of their roots by

genericiterativerootsolvers[]. But by exploiting domain-

specic knowledge, it is also possible to implement a special-

ized iterative solver for () that is guaranteed to eciently

converge to the right root directly. One possible implemen-

tation is presented as a C++ function called GetTimeTo-

TargetRWithMinimalInitialSpeed() in Algorithm .ere,the

equation is rst transformed into an equivalent but more

well-behaved strictly convex quartic function for which a

conservative initial guess for (or rather, )iscalculated,

F : Planning trajectories through six dierent targets, all

starting with the slope /.

F : Planning trajectories through six dierent targets, all

ending at the slope −/.

which is then rened using multiple (but typically less than

a total of six) modied or normal conservative Newton’s

method iterations. is implementation has been carefully

craed with both robustness and eciency in mind. As with

any implementation, numeric precision can become an issue

when using extreme values, but results for practical ranges are

typically within a few oat epsilons of the exact value. See the

comments in the implementation itself for more details.

Alternatively, when only a rough approximation of the

minimal eort solution is needed, the simpler “curviness”

planner from ()and()couldbeusedwith=1/4.is

approximation is fairly accurate for larger values of V∞,asit

actually converges perfectly to the exact solution when V∞

goes to innity. But for high friction scenarios, the dierence

International Journal of Computer Games Technology

F : Planning trajectories through six dierent s,allwithan

arc height of .

F : Planning trajectories through six dierent swhile

minimizing the initial velocity using the exact method (in black)

and the approximate =1/4method (in red) in a medium-ction

scenario.

between the exact method and the approximation becomes

quitenoticeable.Togetanideaofthesizeoftheerrorfora

medium friction scenario, the trajectories resulting from the

exact method and the approximation are shown side by side

in Figure for the case of =9.81m/s2and V∞=25m/s.

6.7.HittingaTargetGiventheInitialSpeed. e last planning

algorithm covered in this paper solves for the time 𝑟required

to hit the target [𝑥,𝑦]given the projectile’s exact initial

speed . e solution is found by solving V2

0,𝑥 +V2

0,𝑦 =

2

for the positive time 𝑟to position [𝑥,𝑦],whereV0,𝑥 and

V0,𝑦 areonceagaindenedby()and(), respectively.

F : Planning trajectories through six dierent s, all starting

at m/s. Each of the ve reachable targets has a trajectory with a

(red) low arc and a (black) high arc.

is particular equation may be expanded into the following

quartic function:

2V2

∞4

𝑟+22V∞𝑦3

𝑟+22

𝑥+22

𝑦+2V∞𝑦−22

𝑟

+22

𝑥+2

𝑦𝑟+2

𝑥+2

𝑦=0. ()

Note that when is smaller than the minimal initial speed

to hit [𝑥,𝑦](i.e., the sought solution of ()), the problem

hasnovalidsolutions.Butwhenis larger than that, it

will always have exactly two valid solutions. In that case, the

smallerofthetwo𝑟values represents the time to hit the target

with a low arc, while the larger 𝑟root is the solution for a high

arc. See Figure for an example.

Using a similar approach as in the previous section, a spe-

cialized iterative solver can be implemented to solve this par-

ticular quartic function. e C++ function GetTimeToTar-

getRGivenInitialSpeedS() in Algorithm solves the equation

foreitherthehighorlowarcrootandreturnstheresulting

𝑟or returns if no solution exists. is implementation has

also been written with robustness, eciency, and accuracy for

a wide range of parameters in mind. Tests showed that the

procedure typically requires about six (modied) Newton’s

method iterations in total to converge to almost full oat

precision.

7. Future work

As already hinted at in Section , planning to hit moving

targets can sometimes be done using a feedback loop between

a target position prediction formula and a planner for a

static target, together converging to a solution over multiple

iterations. More research is necessary to explore the exact

International Journal of Computer Games Technology

boundary conditions for this convergence to occur or alter-

natively to look for ways to solve these problems analytically.

Additionally, it is likely that the model presented in this

paper can also be used for ecient exact collision detection

between a trajectory and an arbitrary polygonal mesh by test-

ing the trajectory in principal space against the intersection

of the mesh and the principal plane. is algorithm might

even be combined with the planners from Sections. and .

to allow for ecient planning of the most optimal trajectory

above or below a given polygonal mesh, respectively. ese

possibilities have not been investigated in depth for this paper

butmightbecoveredinfuturework.

8. Conclusion

A novel analytic approximation of ballistic trajectories with

air resistance has been presented that was designed to balance

physical accuracy and performance in a way that makes sense

in the eld of computer games.

e approximation’s linearity in velocity has been used to

dene a special principal frame of reference, which makes it

possible to always work with these trajectories in a simplied

D space, even though the original problem can be in D with

wind coming from any direction. e combined result is that

theproposedmodelisabletoproducetrajectoriesthatare

complex enough to be physically plausible, while keeping the

math simple enough to also allow for many dierent ways

of ecient trajectory planning that otherwise might be too

impractical for use in computer games.

Conflict of Interests

e author declares that there is no conict of interests

regarding the publication of this paper.

References

[] G. M. Gregorek, Aerodynamic Drag of Model Rockets,Estes

Industries, Penrose, Colo, USA, .

[] R. G. Watts and R. Ferrer, “e lateral force on a spinning

sphere: aerodynamics of a curveball,” American Journal of

Physics,vol.,no.,pp.–,.

[] H. D. Curtis, Orbital Mechanics for Engineering Students,ch–

, Elsevier Butterworth-Heinemann, Burlington, Mass, USA, st

edition, .

[] S.T.orntonandJ.B.Marion,Classical Dynamics of Particles

and Systems,Brooks/Cole,Belmont,Calif,USA,.

[] P. A. Karkantzakos, “Time of ight and range of the motion of a

projectile in a constant gravitational eld under the inuence

of a retarding force proportional to the velocity,” Journal of

Engineering Science and Technology Review,vol.,no.,pp.–

, .

[]R.D.H.Warburton,J.Wang,andJ.Burgd

¨

ofer, “Analytic

approximations of projectile motion with quadratic air resis-

tance,” Journal Service Science & Management, no. , pp. –,

.

[] P. S. Chudinov, “Approximate analytical investigation of projec-

tile motion in a medium with quadratic drag force,” Interna-

tional Journal of Sports Science and Engineering,vol.,no.,pp.

–, .

[] G. W. Parker, “Projectile motion with air resistance quadratic in

the speed,” American Journal of Physics,vol.,no.,pp.–

, .

[] D.M.Bourg,Physics for Game Developers,O’ReillyMedia,.

[] D. Herbison-Evans, “Solving quartics and cubics for graphics,”

Tech. Rep. TR-, Basser Department of Computer Science,

University of Sydney, .

[] W. H. Press, S. A. Teukolsky, W. T. Vetterling, and B. P. Flannery,

Numerical Recipes in C: e Art of Scientic Computing,Ch,

Cambridge University Press, nd edition, .

Available via license: CC BY

Content may be subject to copyright.