+ All Categories
Home > Documents > Research Article Analytical Ballistic Trajectories with...

Research Article Analytical Ballistic Trajectories with...

Date post: 09-Jul-2020
Category:
Upload: others
View: 0 times
Download: 0 times
Share this document with a friend
14
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; [email protected] Received 29 April 2013; Accepted 18 September 2013; Published 30 January 2014 Academic Editor: Jue Wang Copyright © 2014 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 2D and 3D roughly based on a linear drag model and explores a variety of different planning algorithms for these trajectories. Although the trajectories are only approximate, they still capture many of the characteristics of a real projectile in free fall under the influence of an invariant wind, gravitational pull, and terminal velocity, while the required math for these trajectories and planners is still simple enough to efficiently 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, or shot but has no active propul- sion during its actual flight. Consequently, the trajectory is fully determined by a given initial velocity and the effects 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ſt 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 effects like drag, turbulence, height-dependent medium pressure, position-dependent gravity, buoyancy, liſt, 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 fixed over the whole trajectory. As a result, some accuracy will be sacrificed for the sake of computational efficiency and flexibility 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 scientific 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 influenced 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 fire a mortar with a fixed 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 justifiable. is paper introduces a trajectory model that is designed to fit in the gap where working with accurate models would be too complex and working with simple dragless parabola- shaped trajectories would be insufficient. 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 2, previous work is shortly considered. In Section 3, the new model will be introduced and qualitatively compared to other models. In Section 4, the first planner is covered. Other planners use a different space as explained in Section 5 and will be covered in Section 6. is is followed by a discussion of Future Work in Section 7, the Conclusion in Hindawi Publishing Corporation International Journal of Computer Games Technology Volume 2014, Article ID 463489, 13 pages http://dx.doi.org/10.1155/2014/463489
Transcript
Page 1: Research Article Analytical Ballistic Trajectories with ...downloads.hindawi.com/journals/ijcgt/2014/463489.pdf//a3 u + a4 = 0 for u where u = 1/t, but the latter is more well -behaved,

Research ArticleAnalytical Ballistic Trajectories with Approximately Linear Drag

Giliam J P de Carpentier

Linnaeusstraat 32 bis 3553 CE Utrecht The Netherlands

Correspondence should be addressed to Giliam J P de Carpentier giliamdecarpentiernl

Received 29 April 2013 Accepted 18 September 2013 Published 30 January 2014

Academic Editor Jue Wang

Copyright copy 2014 Giliam J P de Carpentier This is an open access article distributed under the Creative Commons AttributionLicense which permits unrestricted use distribution and reproduction in any medium provided the original work is properlycited

This paper introduces a practical analytical approximation of projectile trajectories in 2D and 3D roughly based on a linear dragmodel and explores a variety of different planning algorithms for these trajectories Although the trajectories are only approximatethey still capturemany of the characteristics of a real projectile in free fall under the influence of an invariant wind gravitational pulland terminal velocity while the required math for these trajectories and planners is still simple enough to efficiently run on almostall modern hardware devices Together these properties make the proposed approach particularly useful for real-time applicationswhere 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 droppedthrown served launched or shot but has no active propul-sion during its actual flight Consequently the trajectory isfully determined by a given initial velocity and the effectsof gravity and air resistance Mortars bullets particles andjumping computer game characters (between key presses) areall examples of ballistics while actively controlled aircraft androcket-propelled grenades are not

Describing the exact motion of an object in free fallis a classic problem that can become quite complex whenincluding effects like drag turbulence height-dependentmedium pressure position-dependent gravity buoyancy liftand rotation For this research paper the problem will beapproached on a relatively pragmatic level as it will be basedon a reasonably simple drag model that does not considerthe dynamics of projectile rotation and assumes that windgravity and terminal velocity all remain fixed over the wholetrajectory As a result some accuracy will be sacrificed for thesake of computational efficiency and flexibility in practicaluse while still maintaining much of the essence of theballistic motion through a resistive medium Although sucha choice does not make much sense for most scientific andmilitary applications it doesmake sense for computer games

where performance is typically more important than physicalcorrectness

Currently computer games hardly ever use trajectoriesinfluenced by air resistance when complex planning isrequired That might partially be because implementing acomputer player that is capable of quickly calculating theideal angle to fire a mortar with a fixed initial speed tohit a given target for example is harder when having totake into account drag and wind conditions In fact theadded complexity and computational intensity that would berequired for working with many of the current drag modelsmight simply not be justifiable

This paper introduces a trajectory model that is designedto fit in the gap where working with accurate models wouldbe too complex and working with simple dragless parabola-shaped trajectories would be insufficient The proposedmodelrsquos use and practicality will be demonstrated by coveringa number of its properties and showing how these trajectoriescan be planned in a variety of ways

In Section 2 previous work is shortly considered InSection 3 the newmodel will be introduced and qualitativelycompared to other models In Section 4 the first planner iscovered Other planners use a different space as explained inSection 5 and will be covered in Section 6This is followed bya discussion of Future Work in Section 7 the Conclusion in

Hindawi Publishing CorporationInternational Journal of Computer Games TechnologyVolume 2014 Article ID 463489 13 pageshttpdxdoiorg1011552014463489

2 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) = a4lowasttand4 + a3lowasttand3

+ a1lowastt + a0 which is 0 at the sought time-to-target t Solving f(t) = 0

for t gt 0 is equivalent to solving e(u) = f(1u)lowastuand4 = a0lowastuand4 + a1lowastuand3 +

a3lowastu + a4 = 0 for u where u = 1 t but the latter is more well-behaved being a strictly concave function for u gt 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 lowast vInfinity rr = rX lowast rX + rY lowast rY the root and

double a0 = minusrr a1 = a0 lowast k a3 = k lowast kVInfinity lowast rY return 1u

double a4 = kVInfinity lowast kVInfinity

double maxInvRelError = 10E6 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 methodrsquos iteration at u = 0 if positive

double u = stdsqrt(kVInfinity stdsqrt(rr))

if (rY lt 0) u = stdmin(u minusvInfinity rY)

3 Let u monotonically converge to e(u)rsquos positive root using a modified

Newtonrsquos method that speeds up convergence for double roots but is likely

to overshoot eventually Here ldquoerdquo = e(u) and ldquoderdquo = de(u)dufor (int it = 0 it lt 10 ++it uDelta = e de u minus= 19 lowast uDelta)

de = a0 lowast u e = de + a1 de = de + e e = e lowast u

de = de lowast u + e e = e lowast u + a3 de = de lowast u + e e = e lowast u + a4

if ((e lt 0 ampamp de lt 0)) break Overshot the root

u += 09 lowast uDelta Trace back to the unmodified Newton methodrsquos output

4 Continue to converge monotonically from the overestimated u to e(u)rsquos only positive root using Newtonrsquos method

for (int it = 0 uDelta lowast maxInvRelError gt u ampamp it lt 10 ++it)

de = a0 lowast u e = de + a1 de = de + e e = e lowast u

de = de lowast u + e e = e lowast u + a3 de = de lowast u + e e = e lowast u + a4

uDelta = e de u minus= uDelta

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

return u gt 0 1 u 0

Algorithm 1 Specialized C++ Quartic Solver

Section 8 and the ReferencesThe included Algorithms 1 and2 contain C++ functions that efficiently solve the two mostcomplex planning problems

2 Previous Work

The motion of ballistic projectiles has been covered in manyphysics papers and textbooks and all of these use theirown set of assumptions to create an approximate model ofthe forces acting on a projectile Although some ballisticsresearch focuses on effects like shape and orientation [1]spin [2] or (sub)orbital flight [3] most works on ballistictrajectories assume a fixed gravitational pull and use asimplified drag model These drag models typically ignore alleffects of in-flight rotation and are only dependent on thelocal velocity relative to the medium and on a given fixedterminal velocity or drag coefficient

The used drag model influences both realism and com-putational complexity For example when no drag force isapplied the trajectory will always be a parabola which is

easy to work with and plan for If the drag force is chosento be linear in velocity an explicit function describing thetrajectory can be found by solving a set of linear differen-tial equations [4] This transcendental function is alreadycomputationally harder to calculate and even harder to planwith (ie solve for) [5] To approximate reality even betterthe drag force can be made quadratic in the objectrsquos velocityrelative to the medium But as no exact analytic solution forthe resulting trajectory exists calculating a trajectory requireseither crude approximation or numerical integration andplanning a trajectory requires reiteration [6ndash8]

The research in this paper is based on a novel approxi-mation of the trajectory function that follows from the lineardrag model sacrificing some of its moderate accuracy for afurther increase in both efficiency and flexibility

3 The Approximated Trajectory

31 Ballistic Parameters Before presenting the proposedtrajectory function and its properties the necessary ballistic

International Journal of Computer Games Technology 3

double GetTimeToTargetRGivenInitialSpeedS(double k double vInfinity double rX

double rY double s bool highArc)

1 Start by getting coefficients for the function f(t) = a4lowasttand4 + a3lowasttand3

+ a2lowasttand2 + a1lowastt + a0 which is 0 at the sought time-to-target t Solving

f(t) = 0 for t gt 0 is equivalent to solving e(u) = f(1u)lowastuand3 = a0lowastuand3 +

a1lowastuand2 + a2lowastu + a3 + a4u for u where u = 1 t but the latter is more

well-behaved being a strictly convex function for u gt 0 for any set of

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

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

double kRX = k lowast rX kRY = k lowast rY kRXSq = kRX lowast kRX sS = s lowast s

double twoKVInfinityRY = vInfinity lowast (kRY + kRY) kVInfinity = k lowast vInfinity

double a0 = rX lowast rX + rY lowast rY a1 = (k + k) lowast a0

double a2 = kRXSq + kRY lowast kRY + twoKVInfinityRY minus sS

double a3 = twoKVInfinityRY lowast k a4 = kVInfinity lowast kVInfinity

double maxInvRelError = 10E6 Use an achievable inverse error bound

double maxV0YSq = sS minus kRXSq maxV0YSq is the max squared ldquoV0yrdquo that leaves

double e de u uDelta = 0 enough ldquoV0xrdquo to reach rX horizontally

2 Set u to a lowerupper bound for the highlow arc respectively

if (highArc) Get smallest u vertically moving rY at max possible +v0y

double minusB = stdsqrt(maxV0YSq) minus kRY

double determ = minusB lowast minusB minus (twoKVInfinityRY + twoKVInfinityRY)

u = (kVInfinity + kVInfinity) (minusB + stdsqrt(determ))

maxInvRelError = minusmaxInvRelError Convergence over negative slopes

else if (rY lt 0) Get largest u vertically moving rY at most neg v0y

double minusB = minusstdsqrt(maxV0YSq) minus kRY

double determ = minusB lowast minusB minus (twoKVInfinityRY + twoKVInfinityRY)

u = (minusB minus stdsqrt(determ)) (rY + rY)

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

u = stdmin(s rX minus k u)

else u = s stdsqrt(a0) minus k Get the (largest) u hitting rX

horizontally asap while launching in the direction of [rXrY]

3 Let u monotonically converge to e(u)rsquos closest root using a modified

Newtonrsquos method almost scaling the delta as if the solution is a double

int it = 0 root Note that ldquoerdquo = e(u) lowast uand2 and ldquoderdquo = de(u)du lowast uand2

for ( it lt 12 ++it uDelta = e de u minus= 19 lowast uDelta)

de = a0 lowast u e = de + a1 de = de + e e = e lowast u + a2 de = de lowast u + e

e = e lowast u + a3 e = (e lowast u + a4) lowast u de = de lowast u lowast u minus a4

if ((u gt 0 ampamp de lowast maxInvRelError gt 0 ampamp e gt 0)) break Overshot

u += 09 lowast uDelta Trace back to unmodified Newton methodrsquos output

4 Continue to converge monotonically to e(u)rsquos closest root using

Newtonrsquos method from the last known conservative estimate on the convex

function (Note that in practice u will have converged enough in lt12

for ( u gt 0 ampamp it lt 12 ++it) iterations iff a solution does exists)

de = a0 lowast u e = de + a1 de = de + e e = e lowast u + a2 de = de lowast u + e

e = e lowast u + a3 e = (e lowast u + a4) lowast u de = de lowast u lowast u minus a4

uDelta = e de u minus= uDelta

if ((de lowast maxInvRelError gt 0)) break Wrong side of the convex ldquodiprdquoif (uDelta lowast maxInvRelError lt u ampamp u gt 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

Algorithm 2 Specialized C++ Quartic Solver

4 International Journal of Computer Games Technology

parameters will be defined here first Starting with a generalnote vector variables in this paper are always distinguishedfrom scalar variables by the rarr symbol above their namesAlso the length of any vector 119886 is denoted as 119886 which isequal toradic 119886 sdot 119886 where sdot is the dot product

A ballistic object is assumed to be launched from theinitial position

0with the initial velocity V

0at time 119905 =

0 Furthermore the object will be travelling through amedium (eg the air) which itself travels at the fixed (wind)velocity Vmedium It is also pulled by gravity at the fixedgravitational acceleration 119892 which is roughly 981ms2 forldquoearthlyrdquo applications The amount of drag 119896 while movingthrough the medium is defined as follows

119896 =1

2

1198921003817100381710038171003817Vterminal

1003817100381710038171003817 (1)

Here Vterminal is the invariant terminal velocity relative toVmedium that is reached eventually as the forces of gravity andair resistance finally cancel each other out On earth that isequivalent to saying that Vterminal is the fixed velocity that isapproached when the object is dropped from an enormousheight on awindless day Lastly the absolute terminal velocityVinfin being the absolute velocity approached when time 119905 goes

toinfin is therefore

Vinfin= Vterminal + Vmedium (2)

Together 0 V0 Vinfin and 119896 uniquely define a trajectory

in the proposed model To give a real-world example ofthe parameters defined above suppose a tennis ball with aterminal velocity of 30ms is served at 50ms at a 30∘ anglefrom the 381m high roof of the Empire State building intoa 10ms horizontal wind in 2D Then

0= [0 381] V

0=

[50 cos(30∘) 50 sin(30∘)] asymp [4330 25] 119896 = 01635 andVinfin= [minus10 minus30] The trajectory resulting from these values

is shown in Figure 1

32 Deriving the Trajectory Function In terms of the param-eters defined above the differential equation for the exactlinear drag model has the following analytic solution

linear (119905) =1

2119896(V0minus Vinfin) (1 minus 119890

minus2119896119905) + Vinfin119905 + 0 (3)

This function calculates the 2D or 3D position linear ona trajectory at time 119905 where 119905 ge 0 The above function isfar from new and will not be explained here in detail as ithas already been covered in many textbooks [4] occasionallyeven targeting game developers in particular [9] (albeit withslightly different notation and parameter definitions)

The function above will not be used directly in thispaper Instead it will be approximated by substituting itsexponential function 119890119909 with the first degree rational function(2 + 119909)(2 minus 119909) shown in Figure 2 One of the reasons forselecting this approximation over all possible other approx-imations to 119890119909 is that it has a value first derivative and secondderivative that match those of 119890119909 at 119909 = 0 This means that itapproximates 119890119909 near 119909 = 0 well and therefore will guaranteea good approximation of linear(119905) near 119905 = 0 Furthermore

Figure 1 Serving a tennis ball from the Empire State Buildingupwind

the first derivative of (2 + 119909)(2 minus 119909)monotonically decreasesfrom 1 to 0 as 119909 tends from 0 to minusinfin similar to thefirst derivative of 119890119909 itself When used to approximate 119890119909in linear(119905) this property will cause the initial velocity tomonotonically converge to the terminal velocity over timeNote that no polynomial approximation of 119890119909 has this specificproperty and of all possible rational functions that do possessthe above properties the proposed approximation is thesimplest and thus the most efficient Lastly its inverse is alsoa first degree rational function resulting in relatively simplealgebraic solutions for all (otherwise algebraic) equations thatuse it to approximate 119890119909

When the exponential function in linear(119905) is substitutedby the rational approximation the following function is theresult

(119905) =(V0+ 119896119905Vinfin) 119905

1 + 119896119905+ 0 (4)

Because of the aforementioned properties (119905) will notonly be more efficient to compute on modern computersbut it will also still share many of its characteristics withlinear(119905) and allow trajectory planning to be done withrelative ease The remainder of this paper mainly revolvesaround exploring these and other properties of (119905) togetherwith their implications

33 A Qualitative Comparison As (119905) is only an approxi-mation it will differ from the linear drag modelrsquos trajectoryfunction it is based on as well as from the results of othermodels For comparison purposes the trajectories that followfrom launching three different sport balls using four different

International Journal of Computer Games Technology 5

Figure 2 Approximating 119890119909 using a simple rational function

models are plotted side by side in Figure 3 All balls arelaunched at an 45∘ angle at 50ms on a windless earthly day(119892 = 981ms2) The different drag models are calibratedto respect the respective ballrsquos terminal velocities (except forthe dragless model which always has an infinite terminalvelocity)

Each of the alternating thick and thin segments in thetrajectories shown in Figure 3 (and in all other trajectoryplots in this paper for that matter) represents a projectilersquosmovement over a period of exactly one second making itpossible to not only compare the shapes of the trajectoriesbut also their local speeds The results from the novel (119905)function are plotted in black the results from the linear dragmodel linear(119905) are plotted in blue and the results of thephysically (most) correct quadratic drag model simulationquadratic(119905) are plotted in green Lastly the red paraboladragless(119905) represents the trajectory of each of the three ballsin a perfect vacuum (in other words when there is no dragand Vinfinrsquos length goes to infinite)

When comparing the trajectories for (119905) to the resultsof the two more accurate drag models they are certainlydifferent but they still reasonably mimic these in lookfeel and properties Consequently the proposed model isphysically at least quite plausible and is probably accurateenough for most computer game purposes Furthermorein some cases (119905) is actually closer to quadratic(119905) thanlinear(119905) making it in these cases arguably even physicallymore accurate than the model it is approximating to Lastlythe trajectories for all three drag models perfectly approachdragless(119905) when V

infinrsquos length goes to infinite

34 Exploring Some of p(t)rsquos Properties The function (119905)

given by (4) can be factored solved and parameterized inmany different ways For example basic algebra allows it tobe written as (119905) = 119886V

0+ as well where 119886 = 119905(1 + 119896119905) and

= Vinfin(119905minus119886)+

0 Note that in this form the initial velocity is

separated from all other factors and it becomes immediately

clear that (119905) is a linear function in terms of V0 This implies

that when launching multiple objects at some 119905 = 0 with allproperties equal except for the initial velocity each of theseobjects has the same value for 119886 and for This feature may beexploited in particle explosion systems on modern GPUs forexample requiring only one evaluation of 119886 and per frameper explosion (layer) on the CPU and one MAD (multiply-and-add) GPU instruction per particle per frame to calculateeach particlersquos position

The linearity of (119905) in terms of the initial velocity V0

can also be used for many other purposes For examplein Figure 4 (119905) is used to calculate the green and bluepositions for two different ldquoextremerdquo initial velocities whichare interpreted as the top-left and bottom-right positions ofa textured rectangle or quad Note that the (signed) size ofthe quad is thus simply green(119905) minus blue(119905) = (119886V

0green +

) minus (119886V0blue + ) = 119886 (V

0green minus V0blue) Furthermore all

the bilinearly interpolated texels within this quad includingthe red one willmove over (119905) trajectories themselves aswellby virtue of the linearity in terms of the initial velocities Inother words each texel will follow a (119905) trajectory with someinitial velocity that is interpolated bilinearly between thedifferent extreme initial velocities as if the individual texelsthemselves are under direct control of a physics simulationConsequently it should be physically plausible to use theabove to scale sprites and billboards of for example simplesmoke (for which V

infinwould typically be upwards to simulate

positive buoyancy) explosion debris and fireworksMany other useful properties can easily be derived from

(119905) as well For example the velocity V(119905) of (119905) is

V (119905) =120597 (119905)

120597119905=V0+ 119896119905 (2 + 119896119905) Vinfin(1 + 119896119905)

2 (5)

The nonnegative time 119905top 119899 at which the trajectory hitsits maximum in the direction of a given unit-length vector119899 can be found by solving V(119905) sdot 119899 = 0 for 119905 assuming that the

direction to find the maximum in is pointing away from Vinfin

(ie Vinfinsdot 119899 lt 0) If that assumption is false then the top will

be at time 119905 = 0 The solution to both cases is summarized bythe following formula

119905top 119899 =radic1 minusmin (0 (V

0sdot 119899) (V

infinsdot 119899)) minus 1

119896

(6)

This 119905top 119899 may be used with (4) to get the trajectoryrsquosmaximum position in the 119899 direction Note that when 119899 isaxis-aligned the dot products in (6) can be optimized awayFor example when 119899 is equal to the +119910 axis then 119905top 119899becomes

119905top119910 =radic1 minusmin (0 V

0119910Vinfin119910

) minus 1

119896

(7)

See Figure 5 for an example of V(119905) and (119905top119910)

6 International Journal of Computer Games Technology

Figure 3 The trajectories resulting from four models for three different ball types

Figure 4 The trajectory of a textured quad

4 Planning in World SpaceHitting a Target at a Given Time

When aprojectile needs to hit some given target position (119905)can be used to solve or ldquoplanrdquo the initial velocity that leads toprecisely hitting this target at some given future point in timeTo be more specific when trying to hit some position 119903 at thegiven time 119905

119903 the solution is found by solving (119905

119903) = 119903 for V

0

which results in the following formula

V0= 119896 ( 119903 minus

0minus Vinfin119905119903) +

119903 minus 0

119905119903

(8)

Figure 5 The velocity and 119910-top of a trajectory

In Figure 6 this formula is used to plan the trajectories tosix different target 119903 positions all taking exactly ten secondsto reach their target In other words 119905

119903= 10 which results in

having exactly five thick and five thin segments per trajectoryin this figure

One interesting property of this function is that the 119909and 119910 components (or the 119909 119910 and 119911 components in the3D case) of V

0are completely independent from each other

As a direct consequence similar projectiles that target the

International Journal of Computer Games Technology 7

Figure 6 Planning to hit all six different target positions in exactlyten seconds

same horizontal distance but a different height will alwaysmove at the same horizontal speed over the whole trajectoryand vice versa Also trajectories for targets at equal heightbut different horizontal distances will all have the same topheight as can be observed in Figure 6 as well

Note that the given time parameter 119905119903could be any

positive value including the one that is dependent on anotherfunction of 119903 One simple example of such a function is 119905

119903=

119903 minus 0Vstraight where Vstraight is a given average speed over

the straight line from 0to 119903 In Figure 7 this is illustrated

using Vstraight = 25msA function for 119905

119903could be made arbitrarily complex The

time planners that will be explored in Section 6 are examplesof moderately complex functions solving different additionalconstraints for 119905

119903given 119903 But even more complex planners

would be necessary if 119905119903and 119903 were to be dependent on

each other This can happen for example when a movingtarget needs to be hit while planning to launch at a fixedspeed making 119905

119903influence the prediction of the future target

position 119903 which influences 119905119903again These relationships are

not explored in detail in this paper but it is worthmentioningthat some of these problems may be solved iteratively bystarting with a rough estimate for 119905

119903and then letting it

converge to the right solution by repeatedly going from 119905119903to 119903

and from 119903 to an improved 119905119903 These iterations could possibly

even be spread over multiple frames to amortize costs forexample improving accuracy with each new frame

5 The Principal Frame of Referenceand Its Properties

Most planners for (119905) are still to be presented However asthese planners depend on a special frame of reference to keepthe required planner math as simple as possible this frame ofreference will be covered here first

Figure 7 Planning trajectories to six targets taking the exact sametime as travelling with 25ms over the straight line from initial totarget position

Inspecting (119905) reveals that the function always outputs0plus a linear combination (ie a weighted sum) of V

0and

Vinfin Geometrically this implies that all trajectories even with

wind coming from any 3D direction are guaranteed to lieon a plane spanned by V

0and Vinfin

which passes through 0

Consequently (119905)may be rewritten as

(119905) = 119909 (119905) + 119910 (119905) + 0 (9)

where and respectively describe an orthonormal tangentand bitangent direction in world space of the plane overwhich the projectile moves Within this planersquos 2D frameof reference the vector [119909(119905) 119910(119905)] describes the movementon the trajectory over time relative to

0and in terms of

this alternative 119909 axis (ie the tangent) and 119910 axis (ie thebitangent)

Put into terms perhaps more familiar to computer graph-ics and game developers the 2D function [119909(119905) 119910(119905)] is like aprocedural UV coordinate that defines a projectilersquos locationon an unwrapped plane which maps UV [0 0] to

0and

has an orthonormal tangent vector and bitangent vector All this is shown in Figure 8 where the trajectory (119905) isvisualized as the intersection between the described plane (onwhich is thus lies) and another curved surface

Although there is an infinite amount of ways to define the and vectors the following definitions are used in thispaper for their particularly useful properties

=

119889 minus ( 119889 sdot )

10038171003817100381710038171003817119889 minus ( 119889 sdot )

10038171003817100381710038171003817

=minusVinfin

Vinfin

(10)

8 International Journal of Computer Games Technology

Figure 8 A 3D trajectory with wind at an angle and its decompo-sition on the principal plane (in blue)

Here Vinfin

is used as a shorthand for Vinfin And 119889 = V

0

if V0is already known In the case that V

0is not (yet) known

any position relative to 0known to be lying on the trajectory

may be used for 119889 instead For example use 119889 = 119903 minus 0when

targeting the position 119903 Note that in the case that Vinfin

and 119889

are collinear the trajectory can be described by movementsolely in the direction To still get a valid 2D basis in thatcase an arbitrary vector that is noncollinear should be usedfor 119889 instead

The frame of reference defined by 0 and is what

will be called the trajectoryrsquos principal space It is called thatbecause this space allows the math describing the trajectoryto be decomposed into a particularly compact and well-behaved form In particular wind and gravity do not affectmovement over the principal axis at all but solely over theprincipal axis This allows the function 119909(119905) in (9) to besimplified as will be shown and put to good use soon

The second useful property of this principal space is thatit guarantees that V

119909ge 0 That is all initial and in-flight

velocities expressed in principal space are guaranteed to havenonnegative values on the 119909 axis causing ballistic objects tonever move to or be on the negative 119909 side of this space eventhough they obviously can stillmove in any direction inworldspace Similarly targets are never on the negative 119909 side inprincipal space either The advantage of this property is thatit once again will allow for further simplifications in some ofthe planner math that is still to be discussed

The third useful property of this particular space is thatit is easy to convert from world space to principal space and

back as and are orthonormal Converting from anyworldspace position to the position [119909 119910] in principal space andvice versa can simply be done using (11) and (12) respectivelyas follows

[119909 119910] = [( minus 0) sdot ( minus

0) sdot ] (11)

= 119909 + 119910 + 0 (12)

Similarly it is possible to efficiently convert from anyworld space velocity V to the principal velocity [V

119909 V119910] and

back using (13) and (14) respectively as follows

[V119909 V119910] = [V sdot V sdot ] (13)

V = V119909 + V

119910 (14)

Starting a new notational convention here for clarityvector names (ie variables decorated with a rarr symbol)are only used for variables in world space while variablesin principal space never use this decoration and alwaysrepresent individual scalar quantities So for example V

119909is

the 119909 component of the vector representing the world spacevelocity V while V

119909is a scalar representing a velocity in the 119909

direction in principal spaceNow that the frame of reference itself has been covered

it is possible to define the two scalar functions that make upthe principal space trajectory function [119909(119905) 119910(119905)]

119909 (119905) =V0119909119905

1 + 119896119905 (15)

119910 (119905) =(V0119910minus 119896119905Vinfin) 119905

1 + 119896119905 (16)

These functions are derived by transforming (119905) intothis space using (11) Note that gravity and wind do indeednot affect movement over the 119909 direction in this space And[119909(0) 119910(0)] is equal to [0 0] which means that trajectories inprincipal space always start at the origin (while starting at

0

in world space)The simpler formula for 119909(119905)makes it possible to uniquely

invert the function to get the time 119905 at which the 119909 componentof a certain position will be reached given the horizontalinitial velocity The solution is as follows

119905 =119909

V0119909minus 119896119909

(17)

Here 0 le 119909 le V0119909119896 as that is the valid range of 119909(119905)

for 119905 ge 0 as defined by (15) By plugging (17) into (16) thefollowing explicit 119910-for-119909 relationship is found

119910 (119909) =(119896Vinfin119909 (119896119909 minus V

0119909) + V0119910) 119909

V0119909

(18)

This function always has exactly one 119910 value for eachvalid 119909 value which would not necessarily be true foran explicit trajectory function in any other space This

International Journal of Computer Games Technology 9

property is demonstrated in Figure 9 showing a trajectorythat is equivalent to the trajectory shown in Figure 1 butwhich is now plotted using 119910(119909) in principal space perfectlyoverlaying the original trajectory when mapped back intoworld space

For completeness the principal space counterparts of theworld space properties described by (5) (6) and (7) are givenhere as well Consider

V119909(119905) =

V0119909

(1 + 119896119905)2

V119910(119905) =

V0119910minus 119896119905 (2 + 119896119905) V

infin

(1 + 119896119905)2

119905top 119899

=radic1 +max (0 [V

0119909 V0119910] sdot [119899119909 119899119910] (Vinfin119899119910)) minus 1

119896

119905top119910 =radic1 +max (0 V

0119910Vinfin119910

) minus 1

119896

(19)

Lastly the local slope in principal space in terms of time(ie V

119910(119905)V119909(119905)) and in terms of 119909 (ie 120597119910(119909)120597119909) is as

follows

V119910 (119905)

V119909(119905)

=V0119910minus 119896119905 (2 + 119896119905) Vinfin

V0119909

120597119910 (119909)

120597119909=V0119910+ Vinfin

V0119909

minusV0119909Vinfin

(119896119909 minus V0119909)2

(20)

6 Planning in Principal Space

As the planners in this section all depend on the properties oftrajectories in principal space the most relevant propertiesare briefly repeated here Per definition any ballistic objectin principal space is launched from the origin any targethas a nonnegative 119909 component and the combined effect ofgravity and wind results in a V

infinvalue that is exactly in the

minus119910 direction As the planners will expect their parameters tobe specified in principal space the parameters of any worldspace problem need to be converted to this space beforethey can be used To recap the necessary steps (assumingthe problem involves hitting some target position 119903) start bydefining the actual principal spacersquos and axes using (10)with 119889 = 119903 minus

0 Next convert 119903 (or any other requested

position) to principal space using (11) to get [119903119909 119903119910]

All planners covered here will return the exact time 119905119903

at which the target [119903119909 119903119910] must be hit to meet the plannerrsquos

given constraints To get the actual initial velocity in principalspace that leads to hitting [119903

119909 119903119910] at this 119905

119903 both 119901

119909(119905119903) = 119903119909

Figure 9 The same Empire State Building trajectory example asfrom Figure 1 but seen from the principal frame of reference

and 119901119910(119905119903) = 119903119910need to be solved for [V

0119909 V0119910] which can be

done using the following two formulas

V0119909= 119903119909(119896 +

1

119905119903

) (21)

V0119910= 119903119910(119896 +

1

119905119903

) + 119896Vinfin119905119903 (22)

To get the initial velocity in world space from these it ispossible to convert [V

0119909 V0119910] to V0using (14) But V

0may also

be directly calculated from 119905119903and 119903 through (8) Now that it is

clear how to make use of principal space planners in generalthe actual planners are presented

61 Hitting the Target Given Another Position to PassThroughA trajectory can be planned to pass through both position[119902119909 119902119910] and through target [119903

119909 119903119910] by solving 119910(119902

119909) = 119902

119910

and 119910(119903119909) = 119903

119910for V0119909 and using (17) on 119903

119909and V

0119909to

get 119905119903 This specific form of planning may be useful to shoot

through a hole or exactly over an object at [119902119909 119902119910] to hit

[119903119909 119903119910] example The solution to at what time the position

[119903119909 119903119910] needs to be hit is as follows

119905119903= 119904 + radic119904(119904 +

2119903119909

119896 (119903119909minus 119902119909)) (23)

where 119904 = (119903119909119902119910minus 119903119910119902119909)2Vinfin119902119909 Note that the line from the

origin to the target position with the smallest 119909 must be atleast as steep as the line from the origin to the position with

10 International Journal of Computer Games Technology

Figure 10 Planning trajectories through 119876 and six different 119877targets

the largest 119909 for a valid trajectory (and thus a real solution) toexist That is 119902

119910119902119909ge 119903119910119903119909if 119902119909lt 119903119909 and 119903

119910119903119909ge 119902119910119902119909if

119902119909gt 119903119909 In Figure 10 two of the six targets do not meet this

requirement explaining why there are only four trajectoriesthere

62 Hitting the Target While Touching a Line When lookingfor the time 119905

119903atwhich a trajectory passes through [119903

119909 119903119910] and

touches the line 119910 = 119886119909 + 119887 in principal space 120597119910(119909)120597119909 = 119886has to be solved for 119909 first which can then be used to solve119910(119909) = 119886119909+119887 for V

0119909 Both V

0119909and 119903119909can then be used again

with (17) to get 119905119903 The solution may be written as follows

119905119903=119904 + radic1199042 + 119896V

infin(119886119903119909minus 119903119910)

119896Vinfin

(24)

where 119904 = radic119887119896Vinfin+ (12)119896(119886119903

119909minus 119903119910+ 119887) Note that a real

solution can only exist when 119887 ge 0 and 119886119903119909+ 119887 ge 119903

119910 That is

the line must always pass through or be above the initial andthe target position

In the example presented in Figure 11 the line to betouched is chosen to be horizontal leading to a specificationof the trajectoriesrsquo vertical tops in principal space But it isalso possible to find the 119905

119903that leads to hitting a top defined

in another space For example to let a trajectoryrsquos top touchtheworld-space planewith normal 119899 and throughpoint 119902119910 =119886119909 + 119887 becomes the line in principal space that describes theintersection between this plane and the trajectoryrsquos principalplane In that case 119886 = minus( sdot 119899)( sdot 119899) and 119887 = (( 119902 minus

0) sdot

119899)( sdot 119899) As always when 119899 is axis-aligned the dot productscan be optimized away For example when only interestedin trajectories exactly hitting a world space height ℎ at theirtops (in the +119910 direction) this simplifies to 119886 = minus

119910119910and

119887 = (ℎ minus 0119910)119910

The principal space slope 119886 can also be calculated fromthe slope 119908 of a world-space elevation angle 120579world (ie

Figure 11 Planning trajectories through six different targets touch-ing a line at each top

119908 = tan(120579world)) by using the conversion formula 119886 =

(sign(119910)119908radic119904(2

119910+ 2119910) minus 1199082 minus 119904

119910119910)(1199042

119910minus 1199082) where

119904 = 1 + 1199082 and sign(119909) = [119909 ge 0] minus [119909 lt 0] This 119886 is only

valid if an equivalent elevationwith a positive119909 component inprincipal space exists which is the case if 119904(2

119910+2

119910)minus1199082ge 0

and [1 119908] sdot [radic1 minus 2119910 119910] gt 0 This world-space elevation

conversion may be particularly useful when used togetherwith the next two principal-space planners

63 Hitting the Target Given the Initial Slope This subsectionis about finding the time 119905

119903at which a projectile will hit

position [119903119909 119903119910]while being launched at slope 119886 Planning this

way may be useful when there is control over the projectilersquosinitial speed but not over its direction (eg for some weaponmounted on a fixed rig)

This problem is actually simply a special case of theprevious planner where 119887 = 0 meaning that the problemis equivalent to finding the trajectory that touches the line119910 = 119886119909 After substituting 119887 in (24) and applying somebasic algebra the solution may be written more compactly asfollows

119905119903=119904 + radic119904 (119904 + 2V

infin)

119896Vinfin

(25)

where 119904 = (12)119896(119886119903119909minus 119903119910) Obviously the slope 119886 has to be

steeper than the line from the origin to the target position(ie 119886 gt 119903

119910119903119909) for a solution to exist which is the case for all

but one target position in Figure 12

64 Hitting the Target Given the Target Slope Similarly it ispossible to hit [119903

119909 119903119910] given the exact slope 119886 at the target

position This type of planning allows for exact control overthe angle at which a target is hit Again this can be seen as a

International Journal of Computer Games Technology 11

special case of the planner from Section 62 using 119903119910minus 119886119903119909as

the value for 119887 When substituted and simplified this resultsin the following more direct formula

119905119903= radic

119903119910minus 119886119903119909

119896Vinfin

(26)

For this particular planner the slope 119886 needs to be lessthan the slope of the line from the origin to the target position(ie 119886 lt 119903

119910119903119909) Consequently only five of the six targets have

a valid trajectory in Figure 13

65 Hitting the Target Given the Arc Height or ldquoCurvinessrdquoThe time 119905

119903can also be calculated for a target position [119903

119909 119903119910]

and an ldquoarc heightrdquo 119887 Here 119887 is defined as the maximumdifference in the 119910 direction between the trajectory and thestraight line from origin to target Equivalently 119887 may beinterpreted as the height in principal space of the smallestparallelogram containing the whole trajectory as shown inFigure 14 This problem is another special case of the ldquolinetouchingrdquo problem and can be solved by substituting 119903

119910119903119909

for 119886 in (24) After applying some basic algebra the resultingformula may be written as follows

119905119903=

119887

Vinfin

+ 2radic119887

119896Vinfin

(27)

This function is particularly intuitive to plan with when

119887 = ℎradic1199032119909+ 1199032119910 (28)

where ℎ defines the ldquocurvinessrdquo of the trajectory For exampleℎ = 001 always leads to a low arc for any target positionwhileℎ = 05 always leads to a fairly high arc

66 Hitting the Target with (Almost)Minimal Effort A trajec-tory can also be planned to hit a target at [119903

119909 119903119910] with the

smallest initial speed (and thus the least amount of energy)possible Planning a trajectory this way requires finding thepositive time-to-target 119905

119903which solves 120597(V2

0119909+ V20119910)120597119905119903= 0

where V0119909

and V0119910

are defined by (21) and (22) respectivelyThis equation can be expanded into the following form

(1198962V2infin) 1199054

119903+ (1198962Vinfin119903119910) 1199053

119903minus 119896 (119903

2

119909+ 1199032

119910) 119905119903minus (1199032

119909+ 1199032

119910) = 0

(29)

Like all quartic equations solving this in a closed form ispossible but difficult to do robustly [10] In practice quarticequations are typically solved for any or all of their roots bygeneric iterative root solvers [11] But by exploiting domain-specific knowledge it is also possible to implement a special-ized iterative solver for (29) that is guaranteed to efficientlyconverge to the right root directly One possible implemen-tation is presented as a C++ function called GetTimeTo-TargetRWithMinimalInitialSpeed() in Algorithm 1 There theequation is first transformed into an equivalent but morewell-behaved strictly convex quartic function for which aconservative initial guess for 119905 (or rather 119906) is calculated

Figure 12 Planning trajectories through six different targets allstarting with the slope 34

Figure 13 Planning trajectories through six different targets allending at the slope minus34

which is then refined using multiple (but typically less thana total of six) modified or normal conservative Newtonrsquosmethod iterations This implementation has been carefullycrafted with both robustness and efficiency in mind As withany implementation numeric precision can become an issuewhen using extreme values but results for practical ranges aretypically within a few float epsilons of the exact value See thecomments in the implementation itself for more details

Alternatively when only a rough approximation of theminimal effort solution is needed the simpler ldquocurvinessrdquoplanner from (27) and (28) could be used with ℎ = 14 Thisapproximation is fairly accurate for larger values of V

infin as it

actually converges perfectly to the exact solution when Vinfin

goes to infinity But for high friction scenarios the difference

12 International Journal of Computer Games Technology

Figure 14 Planning trajectories through six different 119877s all with anarc height of 50

Figure 15 Planning trajectories through six different 119877s whileminimizing the initial velocity using the exact method (in black)and the approximate ℎ = 14 method (in red) in a medium-fictionscenario

between the exact method and the approximation becomesquite noticeable To get an idea of the size of the error for amedium friction scenario the trajectories resulting from theexact method and the approximation are shown side by sidein Figure 15 for the case of 119892 = 981ms2 and V

infin= 25ms

67 Hitting a Target Given the Initial Speed The last planningalgorithm covered in this paper solves for the time 119905

119903required

to hit the target [119903119909 119903119910] given the projectilersquos exact initial

speed 119904 The solution is found by solving V20119909

+ V20119910

= 1199042

for the positive time 119905119903to position [119903

119909 119903119910] where V

0119909and

V0119910

are once again defined by (21) and (22) respectively

Figure 16 Planning trajectories through six different119877s all startingat 100ms Each of the five reachable targets has a trajectory with a(red) low arc and a (black) high arc

This particular equation may be expanded into the followingquartic function

(1198962V2infin) 1199054

119903+ (21198962Vinfin119903119910) 1199053

119903+ (11989621199032

119909+ 11989621199032

119910+ 2119896Vinfin119903119910minus 1199042) 1199052

119903

+ 2119896 (1199032

119909+ 1199032

119910) 119905119903+ (1199032

119909+ 1199032

119910) = 0

(30)

Note that when 119904 is smaller than theminimal initial speedto hit [119903

119909 119903119910] (ie the sought solution of (29)) the problem

has no valid solutions But when 119904 is larger than that itwill always have exactly two valid solutions In that case thesmaller of the two 119905

119903values represents the time to hit the target

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

arc See Figure 16 for an exampleUsing a similar approach as in the previous section a spe-

cialized iterative solver can be implemented to solve this par-ticular quartic function The C++ function GetTimeToTar-getRGivenInitialSpeedS() in Algorithm 2 solves the equationfor either the high or low arc root and returns the resulting119905119903or returns 0 if no solution exists This implementation has

also beenwrittenwith robustness efficiency and accuracy fora wide range of parameters in mind Tests showed that theprocedure typically requires about six (modified) Newtonrsquosmethod iterations in total to converge to almost full floatprecision

7 Future work

As already hinted at in Section 4 planning to hit movingtargets can sometimes be done using a feedback loop betweena target position prediction formula and a planner for astatic target together converging to a solution over multipleiterations More research is necessary to explore the exact

International Journal of Computer Games Technology 13

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 thispaper can also be used for efficient exact collision detectionbetween a trajectory and an arbitrary polygonal mesh by test-ing the trajectory in principal space against the intersectionof the mesh and the principal plane This algorithm mighteven be combinedwith the planners from Sections 61 and 62to allow for efficient planning of the most optimal trajectoryabove or below a given polygonal mesh respectively Thesepossibilities have not been investigated in depth for this paperbut might be covered in future work

8 Conclusion

A novel analytic approximation of ballistic trajectories withair resistance has been presented that was designed to balancephysical accuracy and performance in a way that makes sensein the field of computer games

The approximationrsquos linearity in velocity has been used todefine a special principal frame of reference which makes itpossible to always work with these trajectories in a simplified2D space even though the original problem can be in 3Dwithwind coming from any directionThe combined result is thatthe proposed model is able to produce trajectories that arecomplex enough to be physically plausible while keeping themath simple enough to also allow for many different waysof efficient trajectory planning that otherwise might be tooimpractical for use in computer games

Conflict of Interests

The author declares that there is no conflict of interestsregarding the publication of this paper

References

[1] G M Gregorek Aerodynamic Drag of Model Rockets EstesIndustries Penrose Colo USA 1970

[2] R G Watts and R Ferrer ldquoThe lateral force on a spinningsphere aerodynamics of a curveballrdquo American Journal ofPhysics vol 55 no 1 pp 40ndash44 1987

[3] H D Curtis Orbital Mechanics for Engineering Students ch 1ndash5 Elsevier Butterworth-Heinemann BurlingtonMassUSA 1stedition 2005

[4] S T Thornton and J B Marion Classical Dynamics of Particlesand Systems BrooksCole Belmont Calif USA 2005

[5] P A Karkantzakos ldquoTime of flight and range of the motion of aprojectile in a constant gravitational field under the influenceof a retarding force proportional to the velocityrdquo Journal ofEngineering Science and Technology Review vol 2 no 1 pp 76ndash81 2009

[6] R D H Warburton J Wang and J Burgdofer ldquoAnalyticapproximations of projectile motion with quadratic air resis-tancerdquo Journal Service Science ampManagement no 3 pp 98ndash1052010

[7] P S Chudinov ldquoApproximate analytical investigation of projec-tile motion in a medium with quadratic drag forcerdquo Interna-tional Journal of Sports Science and Engineering vol 5 no 1 pp27ndash42 2011

[8] GW Parker ldquoProjectile motion with air resistance quadratic inthe speedrdquo American Journal of Physics vol 45 no 7 pp 606ndash610 1997

[9] DM BourgPhysics for GameDevelopers OrsquoReillyMedia 2002[10] D Herbison-Evans ldquoSolving quartics and cubics for graphicsrdquo

Tech Rep TR94-487 Basser Department of Computer ScienceUniversity of Sydney 1994

[11] WH Press S A TeukolskyW T Vetterling and B P FlanneryNumerical Recipes in C The Art of Scientific Computing Ch 9Cambridge University Press 2nd edition 1992

International Journal of

AerospaceEngineeringHindawi Publishing Corporationhttpwwwhindawicom Volume 2014

RoboticsJournal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Active and Passive Electronic Components

Control Scienceand Engineering

Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

International Journal of

RotatingMachinery

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporation httpwwwhindawicom

Journal ofEngineeringVolume 2014

Submit your manuscripts athttpwwwhindawicom

VLSI Design

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Shock and Vibration

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Civil EngineeringAdvances in

Acoustics and VibrationAdvances in

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Electrical and Computer Engineering

Journal of

Advances inOptoElectronics

Hindawi Publishing Corporation httpwwwhindawicom

Volume 2014

The Scientific World JournalHindawi Publishing Corporation httpwwwhindawicom Volume 2014

SensorsJournal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Modelling amp Simulation in EngineeringHindawi Publishing Corporation httpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Chemical EngineeringInternational Journal of Antennas and

Propagation

International Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Navigation and Observation

International Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

DistributedSensor Networks

International Journal of

Page 2: Research Article Analytical Ballistic Trajectories with ...downloads.hindawi.com/journals/ijcgt/2014/463489.pdf//a3 u + a4 = 0 for u where u = 1/t, but the latter is more well -behaved,

2 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) = a4lowasttand4 + a3lowasttand3

+ a1lowastt + a0 which is 0 at the sought time-to-target t Solving f(t) = 0

for t gt 0 is equivalent to solving e(u) = f(1u)lowastuand4 = a0lowastuand4 + a1lowastuand3 +

a3lowastu + a4 = 0 for u where u = 1 t but the latter is more well-behaved being a strictly concave function for u gt 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 lowast vInfinity rr = rX lowast rX + rY lowast rY the root and

double a0 = minusrr a1 = a0 lowast k a3 = k lowast kVInfinity lowast rY return 1u

double a4 = kVInfinity lowast kVInfinity

double maxInvRelError = 10E6 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 methodrsquos iteration at u = 0 if positive

double u = stdsqrt(kVInfinity stdsqrt(rr))

if (rY lt 0) u = stdmin(u minusvInfinity rY)

3 Let u monotonically converge to e(u)rsquos positive root using a modified

Newtonrsquos method that speeds up convergence for double roots but is likely

to overshoot eventually Here ldquoerdquo = e(u) and ldquoderdquo = de(u)dufor (int it = 0 it lt 10 ++it uDelta = e de u minus= 19 lowast uDelta)

de = a0 lowast u e = de + a1 de = de + e e = e lowast u

de = de lowast u + e e = e lowast u + a3 de = de lowast u + e e = e lowast u + a4

if ((e lt 0 ampamp de lt 0)) break Overshot the root

u += 09 lowast uDelta Trace back to the unmodified Newton methodrsquos output

4 Continue to converge monotonically from the overestimated u to e(u)rsquos only positive root using Newtonrsquos method

for (int it = 0 uDelta lowast maxInvRelError gt u ampamp it lt 10 ++it)

de = a0 lowast u e = de + a1 de = de + e e = e lowast u

de = de lowast u + e e = e lowast u + a3 de = de lowast u + e e = e lowast u + a4

uDelta = e de u minus= uDelta

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

return u gt 0 1 u 0

Algorithm 1 Specialized C++ Quartic Solver

Section 8 and the ReferencesThe included Algorithms 1 and2 contain C++ functions that efficiently solve the two mostcomplex planning problems

2 Previous Work

The motion of ballistic projectiles has been covered in manyphysics papers and textbooks and all of these use theirown set of assumptions to create an approximate model ofthe forces acting on a projectile Although some ballisticsresearch focuses on effects like shape and orientation [1]spin [2] or (sub)orbital flight [3] most works on ballistictrajectories assume a fixed gravitational pull and use asimplified drag model These drag models typically ignore alleffects of in-flight rotation and are only dependent on thelocal velocity relative to the medium and on a given fixedterminal velocity or drag coefficient

The used drag model influences both realism and com-putational complexity For example when no drag force isapplied the trajectory will always be a parabola which is

easy to work with and plan for If the drag force is chosento be linear in velocity an explicit function describing thetrajectory can be found by solving a set of linear differen-tial equations [4] This transcendental function is alreadycomputationally harder to calculate and even harder to planwith (ie solve for) [5] To approximate reality even betterthe drag force can be made quadratic in the objectrsquos velocityrelative to the medium But as no exact analytic solution forthe resulting trajectory exists calculating a trajectory requireseither crude approximation or numerical integration andplanning a trajectory requires reiteration [6ndash8]

The research in this paper is based on a novel approxi-mation of the trajectory function that follows from the lineardrag model sacrificing some of its moderate accuracy for afurther increase in both efficiency and flexibility

3 The Approximated Trajectory

31 Ballistic Parameters Before presenting the proposedtrajectory function and its properties the necessary ballistic

International Journal of Computer Games Technology 3

double GetTimeToTargetRGivenInitialSpeedS(double k double vInfinity double rX

double rY double s bool highArc)

1 Start by getting coefficients for the function f(t) = a4lowasttand4 + a3lowasttand3

+ a2lowasttand2 + a1lowastt + a0 which is 0 at the sought time-to-target t Solving

f(t) = 0 for t gt 0 is equivalent to solving e(u) = f(1u)lowastuand3 = a0lowastuand3 +

a1lowastuand2 + a2lowastu + a3 + a4u for u where u = 1 t but the latter is more

well-behaved being a strictly convex function for u gt 0 for any set of

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

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

double kRX = k lowast rX kRY = k lowast rY kRXSq = kRX lowast kRX sS = s lowast s

double twoKVInfinityRY = vInfinity lowast (kRY + kRY) kVInfinity = k lowast vInfinity

double a0 = rX lowast rX + rY lowast rY a1 = (k + k) lowast a0

double a2 = kRXSq + kRY lowast kRY + twoKVInfinityRY minus sS

double a3 = twoKVInfinityRY lowast k a4 = kVInfinity lowast kVInfinity

double maxInvRelError = 10E6 Use an achievable inverse error bound

double maxV0YSq = sS minus kRXSq maxV0YSq is the max squared ldquoV0yrdquo that leaves

double e de u uDelta = 0 enough ldquoV0xrdquo to reach rX horizontally

2 Set u to a lowerupper bound for the highlow arc respectively

if (highArc) Get smallest u vertically moving rY at max possible +v0y

double minusB = stdsqrt(maxV0YSq) minus kRY

double determ = minusB lowast minusB minus (twoKVInfinityRY + twoKVInfinityRY)

u = (kVInfinity + kVInfinity) (minusB + stdsqrt(determ))

maxInvRelError = minusmaxInvRelError Convergence over negative slopes

else if (rY lt 0) Get largest u vertically moving rY at most neg v0y

double minusB = minusstdsqrt(maxV0YSq) minus kRY

double determ = minusB lowast minusB minus (twoKVInfinityRY + twoKVInfinityRY)

u = (minusB minus stdsqrt(determ)) (rY + rY)

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

u = stdmin(s rX minus k u)

else u = s stdsqrt(a0) minus k Get the (largest) u hitting rX

horizontally asap while launching in the direction of [rXrY]

3 Let u monotonically converge to e(u)rsquos closest root using a modified

Newtonrsquos method almost scaling the delta as if the solution is a double

int it = 0 root Note that ldquoerdquo = e(u) lowast uand2 and ldquoderdquo = de(u)du lowast uand2

for ( it lt 12 ++it uDelta = e de u minus= 19 lowast uDelta)

de = a0 lowast u e = de + a1 de = de + e e = e lowast u + a2 de = de lowast u + e

e = e lowast u + a3 e = (e lowast u + a4) lowast u de = de lowast u lowast u minus a4

if ((u gt 0 ampamp de lowast maxInvRelError gt 0 ampamp e gt 0)) break Overshot

u += 09 lowast uDelta Trace back to unmodified Newton methodrsquos output

4 Continue to converge monotonically to e(u)rsquos closest root using

Newtonrsquos method from the last known conservative estimate on the convex

function (Note that in practice u will have converged enough in lt12

for ( u gt 0 ampamp it lt 12 ++it) iterations iff a solution does exists)

de = a0 lowast u e = de + a1 de = de + e e = e lowast u + a2 de = de lowast u + e

e = e lowast u + a3 e = (e lowast u + a4) lowast u de = de lowast u lowast u minus a4

uDelta = e de u minus= uDelta

if ((de lowast maxInvRelError gt 0)) break Wrong side of the convex ldquodiprdquoif (uDelta lowast maxInvRelError lt u ampamp u gt 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

Algorithm 2 Specialized C++ Quartic Solver

4 International Journal of Computer Games Technology

parameters will be defined here first Starting with a generalnote vector variables in this paper are always distinguishedfrom scalar variables by the rarr symbol above their namesAlso the length of any vector 119886 is denoted as 119886 which isequal toradic 119886 sdot 119886 where sdot is the dot product

A ballistic object is assumed to be launched from theinitial position

0with the initial velocity V

0at time 119905 =

0 Furthermore the object will be travelling through amedium (eg the air) which itself travels at the fixed (wind)velocity Vmedium It is also pulled by gravity at the fixedgravitational acceleration 119892 which is roughly 981ms2 forldquoearthlyrdquo applications The amount of drag 119896 while movingthrough the medium is defined as follows

119896 =1

2

1198921003817100381710038171003817Vterminal

1003817100381710038171003817 (1)

Here Vterminal is the invariant terminal velocity relative toVmedium that is reached eventually as the forces of gravity andair resistance finally cancel each other out On earth that isequivalent to saying that Vterminal is the fixed velocity that isapproached when the object is dropped from an enormousheight on awindless day Lastly the absolute terminal velocityVinfin being the absolute velocity approached when time 119905 goes

toinfin is therefore

Vinfin= Vterminal + Vmedium (2)

Together 0 V0 Vinfin and 119896 uniquely define a trajectory

in the proposed model To give a real-world example ofthe parameters defined above suppose a tennis ball with aterminal velocity of 30ms is served at 50ms at a 30∘ anglefrom the 381m high roof of the Empire State building intoa 10ms horizontal wind in 2D Then

0= [0 381] V

0=

[50 cos(30∘) 50 sin(30∘)] asymp [4330 25] 119896 = 01635 andVinfin= [minus10 minus30] The trajectory resulting from these values

is shown in Figure 1

32 Deriving the Trajectory Function In terms of the param-eters defined above the differential equation for the exactlinear drag model has the following analytic solution

linear (119905) =1

2119896(V0minus Vinfin) (1 minus 119890

minus2119896119905) + Vinfin119905 + 0 (3)

This function calculates the 2D or 3D position linear ona trajectory at time 119905 where 119905 ge 0 The above function isfar from new and will not be explained here in detail as ithas already been covered in many textbooks [4] occasionallyeven targeting game developers in particular [9] (albeit withslightly different notation and parameter definitions)

The function above will not be used directly in thispaper Instead it will be approximated by substituting itsexponential function 119890119909 with the first degree rational function(2 + 119909)(2 minus 119909) shown in Figure 2 One of the reasons forselecting this approximation over all possible other approx-imations to 119890119909 is that it has a value first derivative and secondderivative that match those of 119890119909 at 119909 = 0 This means that itapproximates 119890119909 near 119909 = 0 well and therefore will guaranteea good approximation of linear(119905) near 119905 = 0 Furthermore

Figure 1 Serving a tennis ball from the Empire State Buildingupwind

the first derivative of (2 + 119909)(2 minus 119909)monotonically decreasesfrom 1 to 0 as 119909 tends from 0 to minusinfin similar to thefirst derivative of 119890119909 itself When used to approximate 119890119909in linear(119905) this property will cause the initial velocity tomonotonically converge to the terminal velocity over timeNote that no polynomial approximation of 119890119909 has this specificproperty and of all possible rational functions that do possessthe above properties the proposed approximation is thesimplest and thus the most efficient Lastly its inverse is alsoa first degree rational function resulting in relatively simplealgebraic solutions for all (otherwise algebraic) equations thatuse it to approximate 119890119909

When the exponential function in linear(119905) is substitutedby the rational approximation the following function is theresult

(119905) =(V0+ 119896119905Vinfin) 119905

1 + 119896119905+ 0 (4)

Because of the aforementioned properties (119905) will notonly be more efficient to compute on modern computersbut it will also still share many of its characteristics withlinear(119905) and allow trajectory planning to be done withrelative ease The remainder of this paper mainly revolvesaround exploring these and other properties of (119905) togetherwith their implications

33 A Qualitative Comparison As (119905) is only an approxi-mation it will differ from the linear drag modelrsquos trajectoryfunction it is based on as well as from the results of othermodels For comparison purposes the trajectories that followfrom launching three different sport balls using four different

International Journal of Computer Games Technology 5

Figure 2 Approximating 119890119909 using a simple rational function

models are plotted side by side in Figure 3 All balls arelaunched at an 45∘ angle at 50ms on a windless earthly day(119892 = 981ms2) The different drag models are calibratedto respect the respective ballrsquos terminal velocities (except forthe dragless model which always has an infinite terminalvelocity)

Each of the alternating thick and thin segments in thetrajectories shown in Figure 3 (and in all other trajectoryplots in this paper for that matter) represents a projectilersquosmovement over a period of exactly one second making itpossible to not only compare the shapes of the trajectoriesbut also their local speeds The results from the novel (119905)function are plotted in black the results from the linear dragmodel linear(119905) are plotted in blue and the results of thephysically (most) correct quadratic drag model simulationquadratic(119905) are plotted in green Lastly the red paraboladragless(119905) represents the trajectory of each of the three ballsin a perfect vacuum (in other words when there is no dragand Vinfinrsquos length goes to infinite)

When comparing the trajectories for (119905) to the resultsof the two more accurate drag models they are certainlydifferent but they still reasonably mimic these in lookfeel and properties Consequently the proposed model isphysically at least quite plausible and is probably accurateenough for most computer game purposes Furthermorein some cases (119905) is actually closer to quadratic(119905) thanlinear(119905) making it in these cases arguably even physicallymore accurate than the model it is approximating to Lastlythe trajectories for all three drag models perfectly approachdragless(119905) when V

infinrsquos length goes to infinite

34 Exploring Some of p(t)rsquos Properties The function (119905)

given by (4) can be factored solved and parameterized inmany different ways For example basic algebra allows it tobe written as (119905) = 119886V

0+ as well where 119886 = 119905(1 + 119896119905) and

= Vinfin(119905minus119886)+

0 Note that in this form the initial velocity is

separated from all other factors and it becomes immediately

clear that (119905) is a linear function in terms of V0 This implies

that when launching multiple objects at some 119905 = 0 with allproperties equal except for the initial velocity each of theseobjects has the same value for 119886 and for This feature may beexploited in particle explosion systems on modern GPUs forexample requiring only one evaluation of 119886 and per frameper explosion (layer) on the CPU and one MAD (multiply-and-add) GPU instruction per particle per frame to calculateeach particlersquos position

The linearity of (119905) in terms of the initial velocity V0

can also be used for many other purposes For examplein Figure 4 (119905) is used to calculate the green and bluepositions for two different ldquoextremerdquo initial velocities whichare interpreted as the top-left and bottom-right positions ofa textured rectangle or quad Note that the (signed) size ofthe quad is thus simply green(119905) minus blue(119905) = (119886V

0green +

) minus (119886V0blue + ) = 119886 (V

0green minus V0blue) Furthermore all

the bilinearly interpolated texels within this quad includingthe red one willmove over (119905) trajectories themselves aswellby virtue of the linearity in terms of the initial velocities Inother words each texel will follow a (119905) trajectory with someinitial velocity that is interpolated bilinearly between thedifferent extreme initial velocities as if the individual texelsthemselves are under direct control of a physics simulationConsequently it should be physically plausible to use theabove to scale sprites and billboards of for example simplesmoke (for which V

infinwould typically be upwards to simulate

positive buoyancy) explosion debris and fireworksMany other useful properties can easily be derived from

(119905) as well For example the velocity V(119905) of (119905) is

V (119905) =120597 (119905)

120597119905=V0+ 119896119905 (2 + 119896119905) Vinfin(1 + 119896119905)

2 (5)

The nonnegative time 119905top 119899 at which the trajectory hitsits maximum in the direction of a given unit-length vector119899 can be found by solving V(119905) sdot 119899 = 0 for 119905 assuming that the

direction to find the maximum in is pointing away from Vinfin

(ie Vinfinsdot 119899 lt 0) If that assumption is false then the top will

be at time 119905 = 0 The solution to both cases is summarized bythe following formula

119905top 119899 =radic1 minusmin (0 (V

0sdot 119899) (V

infinsdot 119899)) minus 1

119896

(6)

This 119905top 119899 may be used with (4) to get the trajectoryrsquosmaximum position in the 119899 direction Note that when 119899 isaxis-aligned the dot products in (6) can be optimized awayFor example when 119899 is equal to the +119910 axis then 119905top 119899becomes

119905top119910 =radic1 minusmin (0 V

0119910Vinfin119910

) minus 1

119896

(7)

See Figure 5 for an example of V(119905) and (119905top119910)

6 International Journal of Computer Games Technology

Figure 3 The trajectories resulting from four models for three different ball types

Figure 4 The trajectory of a textured quad

4 Planning in World SpaceHitting a Target at a Given Time

When aprojectile needs to hit some given target position (119905)can be used to solve or ldquoplanrdquo the initial velocity that leads toprecisely hitting this target at some given future point in timeTo be more specific when trying to hit some position 119903 at thegiven time 119905

119903 the solution is found by solving (119905

119903) = 119903 for V

0

which results in the following formula

V0= 119896 ( 119903 minus

0minus Vinfin119905119903) +

119903 minus 0

119905119903

(8)

Figure 5 The velocity and 119910-top of a trajectory

In Figure 6 this formula is used to plan the trajectories tosix different target 119903 positions all taking exactly ten secondsto reach their target In other words 119905

119903= 10 which results in

having exactly five thick and five thin segments per trajectoryin this figure

One interesting property of this function is that the 119909and 119910 components (or the 119909 119910 and 119911 components in the3D case) of V

0are completely independent from each other

As a direct consequence similar projectiles that target the

International Journal of Computer Games Technology 7

Figure 6 Planning to hit all six different target positions in exactlyten seconds

same horizontal distance but a different height will alwaysmove at the same horizontal speed over the whole trajectoryand vice versa Also trajectories for targets at equal heightbut different horizontal distances will all have the same topheight as can be observed in Figure 6 as well

Note that the given time parameter 119905119903could be any

positive value including the one that is dependent on anotherfunction of 119903 One simple example of such a function is 119905

119903=

119903 minus 0Vstraight where Vstraight is a given average speed over

the straight line from 0to 119903 In Figure 7 this is illustrated

using Vstraight = 25msA function for 119905

119903could be made arbitrarily complex The

time planners that will be explored in Section 6 are examplesof moderately complex functions solving different additionalconstraints for 119905

119903given 119903 But even more complex planners

would be necessary if 119905119903and 119903 were to be dependent on

each other This can happen for example when a movingtarget needs to be hit while planning to launch at a fixedspeed making 119905

119903influence the prediction of the future target

position 119903 which influences 119905119903again These relationships are

not explored in detail in this paper but it is worthmentioningthat some of these problems may be solved iteratively bystarting with a rough estimate for 119905

119903and then letting it

converge to the right solution by repeatedly going from 119905119903to 119903

and from 119903 to an improved 119905119903 These iterations could possibly

even be spread over multiple frames to amortize costs forexample improving accuracy with each new frame

5 The Principal Frame of Referenceand Its Properties

Most planners for (119905) are still to be presented However asthese planners depend on a special frame of reference to keepthe required planner math as simple as possible this frame ofreference will be covered here first

Figure 7 Planning trajectories to six targets taking the exact sametime as travelling with 25ms over the straight line from initial totarget position

Inspecting (119905) reveals that the function always outputs0plus a linear combination (ie a weighted sum) of V

0and

Vinfin Geometrically this implies that all trajectories even with

wind coming from any 3D direction are guaranteed to lieon a plane spanned by V

0and Vinfin

which passes through 0

Consequently (119905)may be rewritten as

(119905) = 119909 (119905) + 119910 (119905) + 0 (9)

where and respectively describe an orthonormal tangentand bitangent direction in world space of the plane overwhich the projectile moves Within this planersquos 2D frameof reference the vector [119909(119905) 119910(119905)] describes the movementon the trajectory over time relative to

0and in terms of

this alternative 119909 axis (ie the tangent) and 119910 axis (ie thebitangent)

Put into terms perhaps more familiar to computer graph-ics and game developers the 2D function [119909(119905) 119910(119905)] is like aprocedural UV coordinate that defines a projectilersquos locationon an unwrapped plane which maps UV [0 0] to

0and

has an orthonormal tangent vector and bitangent vector All this is shown in Figure 8 where the trajectory (119905) isvisualized as the intersection between the described plane (onwhich is thus lies) and another curved surface

Although there is an infinite amount of ways to define the and vectors the following definitions are used in thispaper for their particularly useful properties

=

119889 minus ( 119889 sdot )

10038171003817100381710038171003817119889 minus ( 119889 sdot )

10038171003817100381710038171003817

=minusVinfin

Vinfin

(10)

8 International Journal of Computer Games Technology

Figure 8 A 3D trajectory with wind at an angle and its decompo-sition on the principal plane (in blue)

Here Vinfin

is used as a shorthand for Vinfin And 119889 = V

0

if V0is already known In the case that V

0is not (yet) known

any position relative to 0known to be lying on the trajectory

may be used for 119889 instead For example use 119889 = 119903 minus 0when

targeting the position 119903 Note that in the case that Vinfin

and 119889

are collinear the trajectory can be described by movementsolely in the direction To still get a valid 2D basis in thatcase an arbitrary vector that is noncollinear should be usedfor 119889 instead

The frame of reference defined by 0 and is what

will be called the trajectoryrsquos principal space It is called thatbecause this space allows the math describing the trajectoryto be decomposed into a particularly compact and well-behaved form In particular wind and gravity do not affectmovement over the principal axis at all but solely over theprincipal axis This allows the function 119909(119905) in (9) to besimplified as will be shown and put to good use soon

The second useful property of this principal space is thatit guarantees that V

119909ge 0 That is all initial and in-flight

velocities expressed in principal space are guaranteed to havenonnegative values on the 119909 axis causing ballistic objects tonever move to or be on the negative 119909 side of this space eventhough they obviously can stillmove in any direction inworldspace Similarly targets are never on the negative 119909 side inprincipal space either The advantage of this property is thatit once again will allow for further simplifications in some ofthe planner math that is still to be discussed

The third useful property of this particular space is thatit is easy to convert from world space to principal space and

back as and are orthonormal Converting from anyworldspace position to the position [119909 119910] in principal space andvice versa can simply be done using (11) and (12) respectivelyas follows

[119909 119910] = [( minus 0) sdot ( minus

0) sdot ] (11)

= 119909 + 119910 + 0 (12)

Similarly it is possible to efficiently convert from anyworld space velocity V to the principal velocity [V

119909 V119910] and

back using (13) and (14) respectively as follows

[V119909 V119910] = [V sdot V sdot ] (13)

V = V119909 + V

119910 (14)

Starting a new notational convention here for clarityvector names (ie variables decorated with a rarr symbol)are only used for variables in world space while variablesin principal space never use this decoration and alwaysrepresent individual scalar quantities So for example V

119909is

the 119909 component of the vector representing the world spacevelocity V while V

119909is a scalar representing a velocity in the 119909

direction in principal spaceNow that the frame of reference itself has been covered

it is possible to define the two scalar functions that make upthe principal space trajectory function [119909(119905) 119910(119905)]

119909 (119905) =V0119909119905

1 + 119896119905 (15)

119910 (119905) =(V0119910minus 119896119905Vinfin) 119905

1 + 119896119905 (16)

These functions are derived by transforming (119905) intothis space using (11) Note that gravity and wind do indeednot affect movement over the 119909 direction in this space And[119909(0) 119910(0)] is equal to [0 0] which means that trajectories inprincipal space always start at the origin (while starting at

0

in world space)The simpler formula for 119909(119905)makes it possible to uniquely

invert the function to get the time 119905 at which the 119909 componentof a certain position will be reached given the horizontalinitial velocity The solution is as follows

119905 =119909

V0119909minus 119896119909

(17)

Here 0 le 119909 le V0119909119896 as that is the valid range of 119909(119905)

for 119905 ge 0 as defined by (15) By plugging (17) into (16) thefollowing explicit 119910-for-119909 relationship is found

119910 (119909) =(119896Vinfin119909 (119896119909 minus V

0119909) + V0119910) 119909

V0119909

(18)

This function always has exactly one 119910 value for eachvalid 119909 value which would not necessarily be true foran explicit trajectory function in any other space This

International Journal of Computer Games Technology 9

property is demonstrated in Figure 9 showing a trajectorythat is equivalent to the trajectory shown in Figure 1 butwhich is now plotted using 119910(119909) in principal space perfectlyoverlaying the original trajectory when mapped back intoworld space

For completeness the principal space counterparts of theworld space properties described by (5) (6) and (7) are givenhere as well Consider

V119909(119905) =

V0119909

(1 + 119896119905)2

V119910(119905) =

V0119910minus 119896119905 (2 + 119896119905) V

infin

(1 + 119896119905)2

119905top 119899

=radic1 +max (0 [V

0119909 V0119910] sdot [119899119909 119899119910] (Vinfin119899119910)) minus 1

119896

119905top119910 =radic1 +max (0 V

0119910Vinfin119910

) minus 1

119896

(19)

Lastly the local slope in principal space in terms of time(ie V

119910(119905)V119909(119905)) and in terms of 119909 (ie 120597119910(119909)120597119909) is as

follows

V119910 (119905)

V119909(119905)

=V0119910minus 119896119905 (2 + 119896119905) Vinfin

V0119909

120597119910 (119909)

120597119909=V0119910+ Vinfin

V0119909

minusV0119909Vinfin

(119896119909 minus V0119909)2

(20)

6 Planning in Principal Space

As the planners in this section all depend on the properties oftrajectories in principal space the most relevant propertiesare briefly repeated here Per definition any ballistic objectin principal space is launched from the origin any targethas a nonnegative 119909 component and the combined effect ofgravity and wind results in a V

infinvalue that is exactly in the

minus119910 direction As the planners will expect their parameters tobe specified in principal space the parameters of any worldspace problem need to be converted to this space beforethey can be used To recap the necessary steps (assumingthe problem involves hitting some target position 119903) start bydefining the actual principal spacersquos and axes using (10)with 119889 = 119903 minus

0 Next convert 119903 (or any other requested

position) to principal space using (11) to get [119903119909 119903119910]

All planners covered here will return the exact time 119905119903

at which the target [119903119909 119903119910] must be hit to meet the plannerrsquos

given constraints To get the actual initial velocity in principalspace that leads to hitting [119903

119909 119903119910] at this 119905

119903 both 119901

119909(119905119903) = 119903119909

Figure 9 The same Empire State Building trajectory example asfrom Figure 1 but seen from the principal frame of reference

and 119901119910(119905119903) = 119903119910need to be solved for [V

0119909 V0119910] which can be

done using the following two formulas

V0119909= 119903119909(119896 +

1

119905119903

) (21)

V0119910= 119903119910(119896 +

1

119905119903

) + 119896Vinfin119905119903 (22)

To get the initial velocity in world space from these it ispossible to convert [V

0119909 V0119910] to V0using (14) But V

0may also

be directly calculated from 119905119903and 119903 through (8) Now that it is

clear how to make use of principal space planners in generalthe actual planners are presented

61 Hitting the Target Given Another Position to PassThroughA trajectory can be planned to pass through both position[119902119909 119902119910] and through target [119903

119909 119903119910] by solving 119910(119902

119909) = 119902

119910

and 119910(119903119909) = 119903

119910for V0119909 and using (17) on 119903

119909and V

0119909to

get 119905119903 This specific form of planning may be useful to shoot

through a hole or exactly over an object at [119902119909 119902119910] to hit

[119903119909 119903119910] example The solution to at what time the position

[119903119909 119903119910] needs to be hit is as follows

119905119903= 119904 + radic119904(119904 +

2119903119909

119896 (119903119909minus 119902119909)) (23)

where 119904 = (119903119909119902119910minus 119903119910119902119909)2Vinfin119902119909 Note that the line from the

origin to the target position with the smallest 119909 must be atleast as steep as the line from the origin to the position with

10 International Journal of Computer Games Technology

Figure 10 Planning trajectories through 119876 and six different 119877targets

the largest 119909 for a valid trajectory (and thus a real solution) toexist That is 119902

119910119902119909ge 119903119910119903119909if 119902119909lt 119903119909 and 119903

119910119903119909ge 119902119910119902119909if

119902119909gt 119903119909 In Figure 10 two of the six targets do not meet this

requirement explaining why there are only four trajectoriesthere

62 Hitting the Target While Touching a Line When lookingfor the time 119905

119903atwhich a trajectory passes through [119903

119909 119903119910] and

touches the line 119910 = 119886119909 + 119887 in principal space 120597119910(119909)120597119909 = 119886has to be solved for 119909 first which can then be used to solve119910(119909) = 119886119909+119887 for V

0119909 Both V

0119909and 119903119909can then be used again

with (17) to get 119905119903 The solution may be written as follows

119905119903=119904 + radic1199042 + 119896V

infin(119886119903119909minus 119903119910)

119896Vinfin

(24)

where 119904 = radic119887119896Vinfin+ (12)119896(119886119903

119909minus 119903119910+ 119887) Note that a real

solution can only exist when 119887 ge 0 and 119886119903119909+ 119887 ge 119903

119910 That is

the line must always pass through or be above the initial andthe target position

In the example presented in Figure 11 the line to betouched is chosen to be horizontal leading to a specificationof the trajectoriesrsquo vertical tops in principal space But it isalso possible to find the 119905

119903that leads to hitting a top defined

in another space For example to let a trajectoryrsquos top touchtheworld-space planewith normal 119899 and throughpoint 119902119910 =119886119909 + 119887 becomes the line in principal space that describes theintersection between this plane and the trajectoryrsquos principalplane In that case 119886 = minus( sdot 119899)( sdot 119899) and 119887 = (( 119902 minus

0) sdot

119899)( sdot 119899) As always when 119899 is axis-aligned the dot productscan be optimized away For example when only interestedin trajectories exactly hitting a world space height ℎ at theirtops (in the +119910 direction) this simplifies to 119886 = minus

119910119910and

119887 = (ℎ minus 0119910)119910

The principal space slope 119886 can also be calculated fromthe slope 119908 of a world-space elevation angle 120579world (ie

Figure 11 Planning trajectories through six different targets touch-ing a line at each top

119908 = tan(120579world)) by using the conversion formula 119886 =

(sign(119910)119908radic119904(2

119910+ 2119910) minus 1199082 minus 119904

119910119910)(1199042

119910minus 1199082) where

119904 = 1 + 1199082 and sign(119909) = [119909 ge 0] minus [119909 lt 0] This 119886 is only

valid if an equivalent elevationwith a positive119909 component inprincipal space exists which is the case if 119904(2

119910+2

119910)minus1199082ge 0

and [1 119908] sdot [radic1 minus 2119910 119910] gt 0 This world-space elevation

conversion may be particularly useful when used togetherwith the next two principal-space planners

63 Hitting the Target Given the Initial Slope This subsectionis about finding the time 119905

119903at which a projectile will hit

position [119903119909 119903119910]while being launched at slope 119886 Planning this

way may be useful when there is control over the projectilersquosinitial speed but not over its direction (eg for some weaponmounted on a fixed rig)

This problem is actually simply a special case of theprevious planner where 119887 = 0 meaning that the problemis equivalent to finding the trajectory that touches the line119910 = 119886119909 After substituting 119887 in (24) and applying somebasic algebra the solution may be written more compactly asfollows

119905119903=119904 + radic119904 (119904 + 2V

infin)

119896Vinfin

(25)

where 119904 = (12)119896(119886119903119909minus 119903119910) Obviously the slope 119886 has to be

steeper than the line from the origin to the target position(ie 119886 gt 119903

119910119903119909) for a solution to exist which is the case for all

but one target position in Figure 12

64 Hitting the Target Given the Target Slope Similarly it ispossible to hit [119903

119909 119903119910] given the exact slope 119886 at the target

position This type of planning allows for exact control overthe angle at which a target is hit Again this can be seen as a

International Journal of Computer Games Technology 11

special case of the planner from Section 62 using 119903119910minus 119886119903119909as

the value for 119887 When substituted and simplified this resultsin the following more direct formula

119905119903= radic

119903119910minus 119886119903119909

119896Vinfin

(26)

For this particular planner the slope 119886 needs to be lessthan the slope of the line from the origin to the target position(ie 119886 lt 119903

119910119903119909) Consequently only five of the six targets have

a valid trajectory in Figure 13

65 Hitting the Target Given the Arc Height or ldquoCurvinessrdquoThe time 119905

119903can also be calculated for a target position [119903

119909 119903119910]

and an ldquoarc heightrdquo 119887 Here 119887 is defined as the maximumdifference in the 119910 direction between the trajectory and thestraight line from origin to target Equivalently 119887 may beinterpreted as the height in principal space of the smallestparallelogram containing the whole trajectory as shown inFigure 14 This problem is another special case of the ldquolinetouchingrdquo problem and can be solved by substituting 119903

119910119903119909

for 119886 in (24) After applying some basic algebra the resultingformula may be written as follows

119905119903=

119887

Vinfin

+ 2radic119887

119896Vinfin

(27)

This function is particularly intuitive to plan with when

119887 = ℎradic1199032119909+ 1199032119910 (28)

where ℎ defines the ldquocurvinessrdquo of the trajectory For exampleℎ = 001 always leads to a low arc for any target positionwhileℎ = 05 always leads to a fairly high arc

66 Hitting the Target with (Almost)Minimal Effort A trajec-tory can also be planned to hit a target at [119903

119909 119903119910] with the

smallest initial speed (and thus the least amount of energy)possible Planning a trajectory this way requires finding thepositive time-to-target 119905

119903which solves 120597(V2

0119909+ V20119910)120597119905119903= 0

where V0119909

and V0119910

are defined by (21) and (22) respectivelyThis equation can be expanded into the following form

(1198962V2infin) 1199054

119903+ (1198962Vinfin119903119910) 1199053

119903minus 119896 (119903

2

119909+ 1199032

119910) 119905119903minus (1199032

119909+ 1199032

119910) = 0

(29)

Like all quartic equations solving this in a closed form ispossible but difficult to do robustly [10] In practice quarticequations are typically solved for any or all of their roots bygeneric iterative root solvers [11] But by exploiting domain-specific knowledge it is also possible to implement a special-ized iterative solver for (29) that is guaranteed to efficientlyconverge to the right root directly One possible implemen-tation is presented as a C++ function called GetTimeTo-TargetRWithMinimalInitialSpeed() in Algorithm 1 There theequation is first transformed into an equivalent but morewell-behaved strictly convex quartic function for which aconservative initial guess for 119905 (or rather 119906) is calculated

Figure 12 Planning trajectories through six different targets allstarting with the slope 34

Figure 13 Planning trajectories through six different targets allending at the slope minus34

which is then refined using multiple (but typically less thana total of six) modified or normal conservative Newtonrsquosmethod iterations This implementation has been carefullycrafted with both robustness and efficiency in mind As withany implementation numeric precision can become an issuewhen using extreme values but results for practical ranges aretypically within a few float epsilons of the exact value See thecomments in the implementation itself for more details

Alternatively when only a rough approximation of theminimal effort solution is needed the simpler ldquocurvinessrdquoplanner from (27) and (28) could be used with ℎ = 14 Thisapproximation is fairly accurate for larger values of V

infin as it

actually converges perfectly to the exact solution when Vinfin

goes to infinity But for high friction scenarios the difference

12 International Journal of Computer Games Technology

Figure 14 Planning trajectories through six different 119877s all with anarc height of 50

Figure 15 Planning trajectories through six different 119877s whileminimizing the initial velocity using the exact method (in black)and the approximate ℎ = 14 method (in red) in a medium-fictionscenario

between the exact method and the approximation becomesquite noticeable To get an idea of the size of the error for amedium friction scenario the trajectories resulting from theexact method and the approximation are shown side by sidein Figure 15 for the case of 119892 = 981ms2 and V

infin= 25ms

67 Hitting a Target Given the Initial Speed The last planningalgorithm covered in this paper solves for the time 119905

119903required

to hit the target [119903119909 119903119910] given the projectilersquos exact initial

speed 119904 The solution is found by solving V20119909

+ V20119910

= 1199042

for the positive time 119905119903to position [119903

119909 119903119910] where V

0119909and

V0119910

are once again defined by (21) and (22) respectively

Figure 16 Planning trajectories through six different119877s all startingat 100ms Each of the five reachable targets has a trajectory with a(red) low arc and a (black) high arc

This particular equation may be expanded into the followingquartic function

(1198962V2infin) 1199054

119903+ (21198962Vinfin119903119910) 1199053

119903+ (11989621199032

119909+ 11989621199032

119910+ 2119896Vinfin119903119910minus 1199042) 1199052

119903

+ 2119896 (1199032

119909+ 1199032

119910) 119905119903+ (1199032

119909+ 1199032

119910) = 0

(30)

Note that when 119904 is smaller than theminimal initial speedto hit [119903

119909 119903119910] (ie the sought solution of (29)) the problem

has no valid solutions But when 119904 is larger than that itwill always have exactly two valid solutions In that case thesmaller of the two 119905

119903values represents the time to hit the target

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

arc See Figure 16 for an exampleUsing a similar approach as in the previous section a spe-

cialized iterative solver can be implemented to solve this par-ticular quartic function The C++ function GetTimeToTar-getRGivenInitialSpeedS() in Algorithm 2 solves the equationfor either the high or low arc root and returns the resulting119905119903or returns 0 if no solution exists This implementation has

also beenwrittenwith robustness efficiency and accuracy fora wide range of parameters in mind Tests showed that theprocedure typically requires about six (modified) Newtonrsquosmethod iterations in total to converge to almost full floatprecision

7 Future work

As already hinted at in Section 4 planning to hit movingtargets can sometimes be done using a feedback loop betweena target position prediction formula and a planner for astatic target together converging to a solution over multipleiterations More research is necessary to explore the exact

International Journal of Computer Games Technology 13

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 thispaper can also be used for efficient exact collision detectionbetween a trajectory and an arbitrary polygonal mesh by test-ing the trajectory in principal space against the intersectionof the mesh and the principal plane This algorithm mighteven be combinedwith the planners from Sections 61 and 62to allow for efficient planning of the most optimal trajectoryabove or below a given polygonal mesh respectively Thesepossibilities have not been investigated in depth for this paperbut might be covered in future work

8 Conclusion

A novel analytic approximation of ballistic trajectories withair resistance has been presented that was designed to balancephysical accuracy and performance in a way that makes sensein the field of computer games

The approximationrsquos linearity in velocity has been used todefine a special principal frame of reference which makes itpossible to always work with these trajectories in a simplified2D space even though the original problem can be in 3Dwithwind coming from any directionThe combined result is thatthe proposed model is able to produce trajectories that arecomplex enough to be physically plausible while keeping themath simple enough to also allow for many different waysof efficient trajectory planning that otherwise might be tooimpractical for use in computer games

Conflict of Interests

The author declares that there is no conflict of interestsregarding the publication of this paper

References

[1] G M Gregorek Aerodynamic Drag of Model Rockets EstesIndustries Penrose Colo USA 1970

[2] R G Watts and R Ferrer ldquoThe lateral force on a spinningsphere aerodynamics of a curveballrdquo American Journal ofPhysics vol 55 no 1 pp 40ndash44 1987

[3] H D Curtis Orbital Mechanics for Engineering Students ch 1ndash5 Elsevier Butterworth-Heinemann BurlingtonMassUSA 1stedition 2005

[4] S T Thornton and J B Marion Classical Dynamics of Particlesand Systems BrooksCole Belmont Calif USA 2005

[5] P A Karkantzakos ldquoTime of flight and range of the motion of aprojectile in a constant gravitational field under the influenceof a retarding force proportional to the velocityrdquo Journal ofEngineering Science and Technology Review vol 2 no 1 pp 76ndash81 2009

[6] R D H Warburton J Wang and J Burgdofer ldquoAnalyticapproximations of projectile motion with quadratic air resis-tancerdquo Journal Service Science ampManagement no 3 pp 98ndash1052010

[7] P S Chudinov ldquoApproximate analytical investigation of projec-tile motion in a medium with quadratic drag forcerdquo Interna-tional Journal of Sports Science and Engineering vol 5 no 1 pp27ndash42 2011

[8] GW Parker ldquoProjectile motion with air resistance quadratic inthe speedrdquo American Journal of Physics vol 45 no 7 pp 606ndash610 1997

[9] DM BourgPhysics for GameDevelopers OrsquoReillyMedia 2002[10] D Herbison-Evans ldquoSolving quartics and cubics for graphicsrdquo

Tech Rep TR94-487 Basser Department of Computer ScienceUniversity of Sydney 1994

[11] WH Press S A TeukolskyW T Vetterling and B P FlanneryNumerical Recipes in C The Art of Scientific Computing Ch 9Cambridge University Press 2nd edition 1992

International Journal of

AerospaceEngineeringHindawi Publishing Corporationhttpwwwhindawicom Volume 2014

RoboticsJournal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Active and Passive Electronic Components

Control Scienceand Engineering

Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

International Journal of

RotatingMachinery

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporation httpwwwhindawicom

Journal ofEngineeringVolume 2014

Submit your manuscripts athttpwwwhindawicom

VLSI Design

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Shock and Vibration

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Civil EngineeringAdvances in

Acoustics and VibrationAdvances in

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Electrical and Computer Engineering

Journal of

Advances inOptoElectronics

Hindawi Publishing Corporation httpwwwhindawicom

Volume 2014

The Scientific World JournalHindawi Publishing Corporation httpwwwhindawicom Volume 2014

SensorsJournal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Modelling amp Simulation in EngineeringHindawi Publishing Corporation httpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Chemical EngineeringInternational Journal of Antennas and

Propagation

International Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Navigation and Observation

International Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

DistributedSensor Networks

International Journal of

Page 3: Research Article Analytical Ballistic Trajectories with ...downloads.hindawi.com/journals/ijcgt/2014/463489.pdf//a3 u + a4 = 0 for u where u = 1/t, but the latter is more well -behaved,

International Journal of Computer Games Technology 3

double GetTimeToTargetRGivenInitialSpeedS(double k double vInfinity double rX

double rY double s bool highArc)

1 Start by getting coefficients for the function f(t) = a4lowasttand4 + a3lowasttand3

+ a2lowasttand2 + a1lowastt + a0 which is 0 at the sought time-to-target t Solving

f(t) = 0 for t gt 0 is equivalent to solving e(u) = f(1u)lowastuand3 = a0lowastuand3 +

a1lowastuand2 + a2lowastu + a3 + a4u for u where u = 1 t but the latter is more

well-behaved being a strictly convex function for u gt 0 for any set of

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

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

double kRX = k lowast rX kRY = k lowast rY kRXSq = kRX lowast kRX sS = s lowast s

double twoKVInfinityRY = vInfinity lowast (kRY + kRY) kVInfinity = k lowast vInfinity

double a0 = rX lowast rX + rY lowast rY a1 = (k + k) lowast a0

double a2 = kRXSq + kRY lowast kRY + twoKVInfinityRY minus sS

double a3 = twoKVInfinityRY lowast k a4 = kVInfinity lowast kVInfinity

double maxInvRelError = 10E6 Use an achievable inverse error bound

double maxV0YSq = sS minus kRXSq maxV0YSq is the max squared ldquoV0yrdquo that leaves

double e de u uDelta = 0 enough ldquoV0xrdquo to reach rX horizontally

2 Set u to a lowerupper bound for the highlow arc respectively

if (highArc) Get smallest u vertically moving rY at max possible +v0y

double minusB = stdsqrt(maxV0YSq) minus kRY

double determ = minusB lowast minusB minus (twoKVInfinityRY + twoKVInfinityRY)

u = (kVInfinity + kVInfinity) (minusB + stdsqrt(determ))

maxInvRelError = minusmaxInvRelError Convergence over negative slopes

else if (rY lt 0) Get largest u vertically moving rY at most neg v0y

double minusB = minusstdsqrt(maxV0YSq) minus kRY

double determ = minusB lowast minusB minus (twoKVInfinityRY + twoKVInfinityRY)

u = (minusB minus stdsqrt(determ)) (rY + rY)

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

u = stdmin(s rX minus k u)

else u = s stdsqrt(a0) minus k Get the (largest) u hitting rX

horizontally asap while launching in the direction of [rXrY]

3 Let u monotonically converge to e(u)rsquos closest root using a modified

Newtonrsquos method almost scaling the delta as if the solution is a double

int it = 0 root Note that ldquoerdquo = e(u) lowast uand2 and ldquoderdquo = de(u)du lowast uand2

for ( it lt 12 ++it uDelta = e de u minus= 19 lowast uDelta)

de = a0 lowast u e = de + a1 de = de + e e = e lowast u + a2 de = de lowast u + e

e = e lowast u + a3 e = (e lowast u + a4) lowast u de = de lowast u lowast u minus a4

if ((u gt 0 ampamp de lowast maxInvRelError gt 0 ampamp e gt 0)) break Overshot

u += 09 lowast uDelta Trace back to unmodified Newton methodrsquos output

4 Continue to converge monotonically to e(u)rsquos closest root using

Newtonrsquos method from the last known conservative estimate on the convex

function (Note that in practice u will have converged enough in lt12

for ( u gt 0 ampamp it lt 12 ++it) iterations iff a solution does exists)

de = a0 lowast u e = de + a1 de = de + e e = e lowast u + a2 de = de lowast u + e

e = e lowast u + a3 e = (e lowast u + a4) lowast u de = de lowast u lowast u minus a4

uDelta = e de u minus= uDelta

if ((de lowast maxInvRelError gt 0)) break Wrong side of the convex ldquodiprdquoif (uDelta lowast maxInvRelError lt u ampamp u gt 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

Algorithm 2 Specialized C++ Quartic Solver

4 International Journal of Computer Games Technology

parameters will be defined here first Starting with a generalnote vector variables in this paper are always distinguishedfrom scalar variables by the rarr symbol above their namesAlso the length of any vector 119886 is denoted as 119886 which isequal toradic 119886 sdot 119886 where sdot is the dot product

A ballistic object is assumed to be launched from theinitial position

0with the initial velocity V

0at time 119905 =

0 Furthermore the object will be travelling through amedium (eg the air) which itself travels at the fixed (wind)velocity Vmedium It is also pulled by gravity at the fixedgravitational acceleration 119892 which is roughly 981ms2 forldquoearthlyrdquo applications The amount of drag 119896 while movingthrough the medium is defined as follows

119896 =1

2

1198921003817100381710038171003817Vterminal

1003817100381710038171003817 (1)

Here Vterminal is the invariant terminal velocity relative toVmedium that is reached eventually as the forces of gravity andair resistance finally cancel each other out On earth that isequivalent to saying that Vterminal is the fixed velocity that isapproached when the object is dropped from an enormousheight on awindless day Lastly the absolute terminal velocityVinfin being the absolute velocity approached when time 119905 goes

toinfin is therefore

Vinfin= Vterminal + Vmedium (2)

Together 0 V0 Vinfin and 119896 uniquely define a trajectory

in the proposed model To give a real-world example ofthe parameters defined above suppose a tennis ball with aterminal velocity of 30ms is served at 50ms at a 30∘ anglefrom the 381m high roof of the Empire State building intoa 10ms horizontal wind in 2D Then

0= [0 381] V

0=

[50 cos(30∘) 50 sin(30∘)] asymp [4330 25] 119896 = 01635 andVinfin= [minus10 minus30] The trajectory resulting from these values

is shown in Figure 1

32 Deriving the Trajectory Function In terms of the param-eters defined above the differential equation for the exactlinear drag model has the following analytic solution

linear (119905) =1

2119896(V0minus Vinfin) (1 minus 119890

minus2119896119905) + Vinfin119905 + 0 (3)

This function calculates the 2D or 3D position linear ona trajectory at time 119905 where 119905 ge 0 The above function isfar from new and will not be explained here in detail as ithas already been covered in many textbooks [4] occasionallyeven targeting game developers in particular [9] (albeit withslightly different notation and parameter definitions)

The function above will not be used directly in thispaper Instead it will be approximated by substituting itsexponential function 119890119909 with the first degree rational function(2 + 119909)(2 minus 119909) shown in Figure 2 One of the reasons forselecting this approximation over all possible other approx-imations to 119890119909 is that it has a value first derivative and secondderivative that match those of 119890119909 at 119909 = 0 This means that itapproximates 119890119909 near 119909 = 0 well and therefore will guaranteea good approximation of linear(119905) near 119905 = 0 Furthermore

Figure 1 Serving a tennis ball from the Empire State Buildingupwind

the first derivative of (2 + 119909)(2 minus 119909)monotonically decreasesfrom 1 to 0 as 119909 tends from 0 to minusinfin similar to thefirst derivative of 119890119909 itself When used to approximate 119890119909in linear(119905) this property will cause the initial velocity tomonotonically converge to the terminal velocity over timeNote that no polynomial approximation of 119890119909 has this specificproperty and of all possible rational functions that do possessthe above properties the proposed approximation is thesimplest and thus the most efficient Lastly its inverse is alsoa first degree rational function resulting in relatively simplealgebraic solutions for all (otherwise algebraic) equations thatuse it to approximate 119890119909

When the exponential function in linear(119905) is substitutedby the rational approximation the following function is theresult

(119905) =(V0+ 119896119905Vinfin) 119905

1 + 119896119905+ 0 (4)

Because of the aforementioned properties (119905) will notonly be more efficient to compute on modern computersbut it will also still share many of its characteristics withlinear(119905) and allow trajectory planning to be done withrelative ease The remainder of this paper mainly revolvesaround exploring these and other properties of (119905) togetherwith their implications

33 A Qualitative Comparison As (119905) is only an approxi-mation it will differ from the linear drag modelrsquos trajectoryfunction it is based on as well as from the results of othermodels For comparison purposes the trajectories that followfrom launching three different sport balls using four different

International Journal of Computer Games Technology 5

Figure 2 Approximating 119890119909 using a simple rational function

models are plotted side by side in Figure 3 All balls arelaunched at an 45∘ angle at 50ms on a windless earthly day(119892 = 981ms2) The different drag models are calibratedto respect the respective ballrsquos terminal velocities (except forthe dragless model which always has an infinite terminalvelocity)

Each of the alternating thick and thin segments in thetrajectories shown in Figure 3 (and in all other trajectoryplots in this paper for that matter) represents a projectilersquosmovement over a period of exactly one second making itpossible to not only compare the shapes of the trajectoriesbut also their local speeds The results from the novel (119905)function are plotted in black the results from the linear dragmodel linear(119905) are plotted in blue and the results of thephysically (most) correct quadratic drag model simulationquadratic(119905) are plotted in green Lastly the red paraboladragless(119905) represents the trajectory of each of the three ballsin a perfect vacuum (in other words when there is no dragand Vinfinrsquos length goes to infinite)

When comparing the trajectories for (119905) to the resultsof the two more accurate drag models they are certainlydifferent but they still reasonably mimic these in lookfeel and properties Consequently the proposed model isphysically at least quite plausible and is probably accurateenough for most computer game purposes Furthermorein some cases (119905) is actually closer to quadratic(119905) thanlinear(119905) making it in these cases arguably even physicallymore accurate than the model it is approximating to Lastlythe trajectories for all three drag models perfectly approachdragless(119905) when V

infinrsquos length goes to infinite

34 Exploring Some of p(t)rsquos Properties The function (119905)

given by (4) can be factored solved and parameterized inmany different ways For example basic algebra allows it tobe written as (119905) = 119886V

0+ as well where 119886 = 119905(1 + 119896119905) and

= Vinfin(119905minus119886)+

0 Note that in this form the initial velocity is

separated from all other factors and it becomes immediately

clear that (119905) is a linear function in terms of V0 This implies

that when launching multiple objects at some 119905 = 0 with allproperties equal except for the initial velocity each of theseobjects has the same value for 119886 and for This feature may beexploited in particle explosion systems on modern GPUs forexample requiring only one evaluation of 119886 and per frameper explosion (layer) on the CPU and one MAD (multiply-and-add) GPU instruction per particle per frame to calculateeach particlersquos position

The linearity of (119905) in terms of the initial velocity V0

can also be used for many other purposes For examplein Figure 4 (119905) is used to calculate the green and bluepositions for two different ldquoextremerdquo initial velocities whichare interpreted as the top-left and bottom-right positions ofa textured rectangle or quad Note that the (signed) size ofthe quad is thus simply green(119905) minus blue(119905) = (119886V

0green +

) minus (119886V0blue + ) = 119886 (V

0green minus V0blue) Furthermore all

the bilinearly interpolated texels within this quad includingthe red one willmove over (119905) trajectories themselves aswellby virtue of the linearity in terms of the initial velocities Inother words each texel will follow a (119905) trajectory with someinitial velocity that is interpolated bilinearly between thedifferent extreme initial velocities as if the individual texelsthemselves are under direct control of a physics simulationConsequently it should be physically plausible to use theabove to scale sprites and billboards of for example simplesmoke (for which V

infinwould typically be upwards to simulate

positive buoyancy) explosion debris and fireworksMany other useful properties can easily be derived from

(119905) as well For example the velocity V(119905) of (119905) is

V (119905) =120597 (119905)

120597119905=V0+ 119896119905 (2 + 119896119905) Vinfin(1 + 119896119905)

2 (5)

The nonnegative time 119905top 119899 at which the trajectory hitsits maximum in the direction of a given unit-length vector119899 can be found by solving V(119905) sdot 119899 = 0 for 119905 assuming that the

direction to find the maximum in is pointing away from Vinfin

(ie Vinfinsdot 119899 lt 0) If that assumption is false then the top will

be at time 119905 = 0 The solution to both cases is summarized bythe following formula

119905top 119899 =radic1 minusmin (0 (V

0sdot 119899) (V

infinsdot 119899)) minus 1

119896

(6)

This 119905top 119899 may be used with (4) to get the trajectoryrsquosmaximum position in the 119899 direction Note that when 119899 isaxis-aligned the dot products in (6) can be optimized awayFor example when 119899 is equal to the +119910 axis then 119905top 119899becomes

119905top119910 =radic1 minusmin (0 V

0119910Vinfin119910

) minus 1

119896

(7)

See Figure 5 for an example of V(119905) and (119905top119910)

6 International Journal of Computer Games Technology

Figure 3 The trajectories resulting from four models for three different ball types

Figure 4 The trajectory of a textured quad

4 Planning in World SpaceHitting a Target at a Given Time

When aprojectile needs to hit some given target position (119905)can be used to solve or ldquoplanrdquo the initial velocity that leads toprecisely hitting this target at some given future point in timeTo be more specific when trying to hit some position 119903 at thegiven time 119905

119903 the solution is found by solving (119905

119903) = 119903 for V

0

which results in the following formula

V0= 119896 ( 119903 minus

0minus Vinfin119905119903) +

119903 minus 0

119905119903

(8)

Figure 5 The velocity and 119910-top of a trajectory

In Figure 6 this formula is used to plan the trajectories tosix different target 119903 positions all taking exactly ten secondsto reach their target In other words 119905

119903= 10 which results in

having exactly five thick and five thin segments per trajectoryin this figure

One interesting property of this function is that the 119909and 119910 components (or the 119909 119910 and 119911 components in the3D case) of V

0are completely independent from each other

As a direct consequence similar projectiles that target the

International Journal of Computer Games Technology 7

Figure 6 Planning to hit all six different target positions in exactlyten seconds

same horizontal distance but a different height will alwaysmove at the same horizontal speed over the whole trajectoryand vice versa Also trajectories for targets at equal heightbut different horizontal distances will all have the same topheight as can be observed in Figure 6 as well

Note that the given time parameter 119905119903could be any

positive value including the one that is dependent on anotherfunction of 119903 One simple example of such a function is 119905

119903=

119903 minus 0Vstraight where Vstraight is a given average speed over

the straight line from 0to 119903 In Figure 7 this is illustrated

using Vstraight = 25msA function for 119905

119903could be made arbitrarily complex The

time planners that will be explored in Section 6 are examplesof moderately complex functions solving different additionalconstraints for 119905

119903given 119903 But even more complex planners

would be necessary if 119905119903and 119903 were to be dependent on

each other This can happen for example when a movingtarget needs to be hit while planning to launch at a fixedspeed making 119905

119903influence the prediction of the future target

position 119903 which influences 119905119903again These relationships are

not explored in detail in this paper but it is worthmentioningthat some of these problems may be solved iteratively bystarting with a rough estimate for 119905

119903and then letting it

converge to the right solution by repeatedly going from 119905119903to 119903

and from 119903 to an improved 119905119903 These iterations could possibly

even be spread over multiple frames to amortize costs forexample improving accuracy with each new frame

5 The Principal Frame of Referenceand Its Properties

Most planners for (119905) are still to be presented However asthese planners depend on a special frame of reference to keepthe required planner math as simple as possible this frame ofreference will be covered here first

Figure 7 Planning trajectories to six targets taking the exact sametime as travelling with 25ms over the straight line from initial totarget position

Inspecting (119905) reveals that the function always outputs0plus a linear combination (ie a weighted sum) of V

0and

Vinfin Geometrically this implies that all trajectories even with

wind coming from any 3D direction are guaranteed to lieon a plane spanned by V

0and Vinfin

which passes through 0

Consequently (119905)may be rewritten as

(119905) = 119909 (119905) + 119910 (119905) + 0 (9)

where and respectively describe an orthonormal tangentand bitangent direction in world space of the plane overwhich the projectile moves Within this planersquos 2D frameof reference the vector [119909(119905) 119910(119905)] describes the movementon the trajectory over time relative to

0and in terms of

this alternative 119909 axis (ie the tangent) and 119910 axis (ie thebitangent)

Put into terms perhaps more familiar to computer graph-ics and game developers the 2D function [119909(119905) 119910(119905)] is like aprocedural UV coordinate that defines a projectilersquos locationon an unwrapped plane which maps UV [0 0] to

0and

has an orthonormal tangent vector and bitangent vector All this is shown in Figure 8 where the trajectory (119905) isvisualized as the intersection between the described plane (onwhich is thus lies) and another curved surface

Although there is an infinite amount of ways to define the and vectors the following definitions are used in thispaper for their particularly useful properties

=

119889 minus ( 119889 sdot )

10038171003817100381710038171003817119889 minus ( 119889 sdot )

10038171003817100381710038171003817

=minusVinfin

Vinfin

(10)

8 International Journal of Computer Games Technology

Figure 8 A 3D trajectory with wind at an angle and its decompo-sition on the principal plane (in blue)

Here Vinfin

is used as a shorthand for Vinfin And 119889 = V

0

if V0is already known In the case that V

0is not (yet) known

any position relative to 0known to be lying on the trajectory

may be used for 119889 instead For example use 119889 = 119903 minus 0when

targeting the position 119903 Note that in the case that Vinfin

and 119889

are collinear the trajectory can be described by movementsolely in the direction To still get a valid 2D basis in thatcase an arbitrary vector that is noncollinear should be usedfor 119889 instead

The frame of reference defined by 0 and is what

will be called the trajectoryrsquos principal space It is called thatbecause this space allows the math describing the trajectoryto be decomposed into a particularly compact and well-behaved form In particular wind and gravity do not affectmovement over the principal axis at all but solely over theprincipal axis This allows the function 119909(119905) in (9) to besimplified as will be shown and put to good use soon

The second useful property of this principal space is thatit guarantees that V

119909ge 0 That is all initial and in-flight

velocities expressed in principal space are guaranteed to havenonnegative values on the 119909 axis causing ballistic objects tonever move to or be on the negative 119909 side of this space eventhough they obviously can stillmove in any direction inworldspace Similarly targets are never on the negative 119909 side inprincipal space either The advantage of this property is thatit once again will allow for further simplifications in some ofthe planner math that is still to be discussed

The third useful property of this particular space is thatit is easy to convert from world space to principal space and

back as and are orthonormal Converting from anyworldspace position to the position [119909 119910] in principal space andvice versa can simply be done using (11) and (12) respectivelyas follows

[119909 119910] = [( minus 0) sdot ( minus

0) sdot ] (11)

= 119909 + 119910 + 0 (12)

Similarly it is possible to efficiently convert from anyworld space velocity V to the principal velocity [V

119909 V119910] and

back using (13) and (14) respectively as follows

[V119909 V119910] = [V sdot V sdot ] (13)

V = V119909 + V

119910 (14)

Starting a new notational convention here for clarityvector names (ie variables decorated with a rarr symbol)are only used for variables in world space while variablesin principal space never use this decoration and alwaysrepresent individual scalar quantities So for example V

119909is

the 119909 component of the vector representing the world spacevelocity V while V

119909is a scalar representing a velocity in the 119909

direction in principal spaceNow that the frame of reference itself has been covered

it is possible to define the two scalar functions that make upthe principal space trajectory function [119909(119905) 119910(119905)]

119909 (119905) =V0119909119905

1 + 119896119905 (15)

119910 (119905) =(V0119910minus 119896119905Vinfin) 119905

1 + 119896119905 (16)

These functions are derived by transforming (119905) intothis space using (11) Note that gravity and wind do indeednot affect movement over the 119909 direction in this space And[119909(0) 119910(0)] is equal to [0 0] which means that trajectories inprincipal space always start at the origin (while starting at

0

in world space)The simpler formula for 119909(119905)makes it possible to uniquely

invert the function to get the time 119905 at which the 119909 componentof a certain position will be reached given the horizontalinitial velocity The solution is as follows

119905 =119909

V0119909minus 119896119909

(17)

Here 0 le 119909 le V0119909119896 as that is the valid range of 119909(119905)

for 119905 ge 0 as defined by (15) By plugging (17) into (16) thefollowing explicit 119910-for-119909 relationship is found

119910 (119909) =(119896Vinfin119909 (119896119909 minus V

0119909) + V0119910) 119909

V0119909

(18)

This function always has exactly one 119910 value for eachvalid 119909 value which would not necessarily be true foran explicit trajectory function in any other space This

International Journal of Computer Games Technology 9

property is demonstrated in Figure 9 showing a trajectorythat is equivalent to the trajectory shown in Figure 1 butwhich is now plotted using 119910(119909) in principal space perfectlyoverlaying the original trajectory when mapped back intoworld space

For completeness the principal space counterparts of theworld space properties described by (5) (6) and (7) are givenhere as well Consider

V119909(119905) =

V0119909

(1 + 119896119905)2

V119910(119905) =

V0119910minus 119896119905 (2 + 119896119905) V

infin

(1 + 119896119905)2

119905top 119899

=radic1 +max (0 [V

0119909 V0119910] sdot [119899119909 119899119910] (Vinfin119899119910)) minus 1

119896

119905top119910 =radic1 +max (0 V

0119910Vinfin119910

) minus 1

119896

(19)

Lastly the local slope in principal space in terms of time(ie V

119910(119905)V119909(119905)) and in terms of 119909 (ie 120597119910(119909)120597119909) is as

follows

V119910 (119905)

V119909(119905)

=V0119910minus 119896119905 (2 + 119896119905) Vinfin

V0119909

120597119910 (119909)

120597119909=V0119910+ Vinfin

V0119909

minusV0119909Vinfin

(119896119909 minus V0119909)2

(20)

6 Planning in Principal Space

As the planners in this section all depend on the properties oftrajectories in principal space the most relevant propertiesare briefly repeated here Per definition any ballistic objectin principal space is launched from the origin any targethas a nonnegative 119909 component and the combined effect ofgravity and wind results in a V

infinvalue that is exactly in the

minus119910 direction As the planners will expect their parameters tobe specified in principal space the parameters of any worldspace problem need to be converted to this space beforethey can be used To recap the necessary steps (assumingthe problem involves hitting some target position 119903) start bydefining the actual principal spacersquos and axes using (10)with 119889 = 119903 minus

0 Next convert 119903 (or any other requested

position) to principal space using (11) to get [119903119909 119903119910]

All planners covered here will return the exact time 119905119903

at which the target [119903119909 119903119910] must be hit to meet the plannerrsquos

given constraints To get the actual initial velocity in principalspace that leads to hitting [119903

119909 119903119910] at this 119905

119903 both 119901

119909(119905119903) = 119903119909

Figure 9 The same Empire State Building trajectory example asfrom Figure 1 but seen from the principal frame of reference

and 119901119910(119905119903) = 119903119910need to be solved for [V

0119909 V0119910] which can be

done using the following two formulas

V0119909= 119903119909(119896 +

1

119905119903

) (21)

V0119910= 119903119910(119896 +

1

119905119903

) + 119896Vinfin119905119903 (22)

To get the initial velocity in world space from these it ispossible to convert [V

0119909 V0119910] to V0using (14) But V

0may also

be directly calculated from 119905119903and 119903 through (8) Now that it is

clear how to make use of principal space planners in generalthe actual planners are presented

61 Hitting the Target Given Another Position to PassThroughA trajectory can be planned to pass through both position[119902119909 119902119910] and through target [119903

119909 119903119910] by solving 119910(119902

119909) = 119902

119910

and 119910(119903119909) = 119903

119910for V0119909 and using (17) on 119903

119909and V

0119909to

get 119905119903 This specific form of planning may be useful to shoot

through a hole or exactly over an object at [119902119909 119902119910] to hit

[119903119909 119903119910] example The solution to at what time the position

[119903119909 119903119910] needs to be hit is as follows

119905119903= 119904 + radic119904(119904 +

2119903119909

119896 (119903119909minus 119902119909)) (23)

where 119904 = (119903119909119902119910minus 119903119910119902119909)2Vinfin119902119909 Note that the line from the

origin to the target position with the smallest 119909 must be atleast as steep as the line from the origin to the position with

10 International Journal of Computer Games Technology

Figure 10 Planning trajectories through 119876 and six different 119877targets

the largest 119909 for a valid trajectory (and thus a real solution) toexist That is 119902

119910119902119909ge 119903119910119903119909if 119902119909lt 119903119909 and 119903

119910119903119909ge 119902119910119902119909if

119902119909gt 119903119909 In Figure 10 two of the six targets do not meet this

requirement explaining why there are only four trajectoriesthere

62 Hitting the Target While Touching a Line When lookingfor the time 119905

119903atwhich a trajectory passes through [119903

119909 119903119910] and

touches the line 119910 = 119886119909 + 119887 in principal space 120597119910(119909)120597119909 = 119886has to be solved for 119909 first which can then be used to solve119910(119909) = 119886119909+119887 for V

0119909 Both V

0119909and 119903119909can then be used again

with (17) to get 119905119903 The solution may be written as follows

119905119903=119904 + radic1199042 + 119896V

infin(119886119903119909minus 119903119910)

119896Vinfin

(24)

where 119904 = radic119887119896Vinfin+ (12)119896(119886119903

119909minus 119903119910+ 119887) Note that a real

solution can only exist when 119887 ge 0 and 119886119903119909+ 119887 ge 119903

119910 That is

the line must always pass through or be above the initial andthe target position

In the example presented in Figure 11 the line to betouched is chosen to be horizontal leading to a specificationof the trajectoriesrsquo vertical tops in principal space But it isalso possible to find the 119905

119903that leads to hitting a top defined

in another space For example to let a trajectoryrsquos top touchtheworld-space planewith normal 119899 and throughpoint 119902119910 =119886119909 + 119887 becomes the line in principal space that describes theintersection between this plane and the trajectoryrsquos principalplane In that case 119886 = minus( sdot 119899)( sdot 119899) and 119887 = (( 119902 minus

0) sdot

119899)( sdot 119899) As always when 119899 is axis-aligned the dot productscan be optimized away For example when only interestedin trajectories exactly hitting a world space height ℎ at theirtops (in the +119910 direction) this simplifies to 119886 = minus

119910119910and

119887 = (ℎ minus 0119910)119910

The principal space slope 119886 can also be calculated fromthe slope 119908 of a world-space elevation angle 120579world (ie

Figure 11 Planning trajectories through six different targets touch-ing a line at each top

119908 = tan(120579world)) by using the conversion formula 119886 =

(sign(119910)119908radic119904(2

119910+ 2119910) minus 1199082 minus 119904

119910119910)(1199042

119910minus 1199082) where

119904 = 1 + 1199082 and sign(119909) = [119909 ge 0] minus [119909 lt 0] This 119886 is only

valid if an equivalent elevationwith a positive119909 component inprincipal space exists which is the case if 119904(2

119910+2

119910)minus1199082ge 0

and [1 119908] sdot [radic1 minus 2119910 119910] gt 0 This world-space elevation

conversion may be particularly useful when used togetherwith the next two principal-space planners

63 Hitting the Target Given the Initial Slope This subsectionis about finding the time 119905

119903at which a projectile will hit

position [119903119909 119903119910]while being launched at slope 119886 Planning this

way may be useful when there is control over the projectilersquosinitial speed but not over its direction (eg for some weaponmounted on a fixed rig)

This problem is actually simply a special case of theprevious planner where 119887 = 0 meaning that the problemis equivalent to finding the trajectory that touches the line119910 = 119886119909 After substituting 119887 in (24) and applying somebasic algebra the solution may be written more compactly asfollows

119905119903=119904 + radic119904 (119904 + 2V

infin)

119896Vinfin

(25)

where 119904 = (12)119896(119886119903119909minus 119903119910) Obviously the slope 119886 has to be

steeper than the line from the origin to the target position(ie 119886 gt 119903

119910119903119909) for a solution to exist which is the case for all

but one target position in Figure 12

64 Hitting the Target Given the Target Slope Similarly it ispossible to hit [119903

119909 119903119910] given the exact slope 119886 at the target

position This type of planning allows for exact control overthe angle at which a target is hit Again this can be seen as a

International Journal of Computer Games Technology 11

special case of the planner from Section 62 using 119903119910minus 119886119903119909as

the value for 119887 When substituted and simplified this resultsin the following more direct formula

119905119903= radic

119903119910minus 119886119903119909

119896Vinfin

(26)

For this particular planner the slope 119886 needs to be lessthan the slope of the line from the origin to the target position(ie 119886 lt 119903

119910119903119909) Consequently only five of the six targets have

a valid trajectory in Figure 13

65 Hitting the Target Given the Arc Height or ldquoCurvinessrdquoThe time 119905

119903can also be calculated for a target position [119903

119909 119903119910]

and an ldquoarc heightrdquo 119887 Here 119887 is defined as the maximumdifference in the 119910 direction between the trajectory and thestraight line from origin to target Equivalently 119887 may beinterpreted as the height in principal space of the smallestparallelogram containing the whole trajectory as shown inFigure 14 This problem is another special case of the ldquolinetouchingrdquo problem and can be solved by substituting 119903

119910119903119909

for 119886 in (24) After applying some basic algebra the resultingformula may be written as follows

119905119903=

119887

Vinfin

+ 2radic119887

119896Vinfin

(27)

This function is particularly intuitive to plan with when

119887 = ℎradic1199032119909+ 1199032119910 (28)

where ℎ defines the ldquocurvinessrdquo of the trajectory For exampleℎ = 001 always leads to a low arc for any target positionwhileℎ = 05 always leads to a fairly high arc

66 Hitting the Target with (Almost)Minimal Effort A trajec-tory can also be planned to hit a target at [119903

119909 119903119910] with the

smallest initial speed (and thus the least amount of energy)possible Planning a trajectory this way requires finding thepositive time-to-target 119905

119903which solves 120597(V2

0119909+ V20119910)120597119905119903= 0

where V0119909

and V0119910

are defined by (21) and (22) respectivelyThis equation can be expanded into the following form

(1198962V2infin) 1199054

119903+ (1198962Vinfin119903119910) 1199053

119903minus 119896 (119903

2

119909+ 1199032

119910) 119905119903minus (1199032

119909+ 1199032

119910) = 0

(29)

Like all quartic equations solving this in a closed form ispossible but difficult to do robustly [10] In practice quarticequations are typically solved for any or all of their roots bygeneric iterative root solvers [11] But by exploiting domain-specific knowledge it is also possible to implement a special-ized iterative solver for (29) that is guaranteed to efficientlyconverge to the right root directly One possible implemen-tation is presented as a C++ function called GetTimeTo-TargetRWithMinimalInitialSpeed() in Algorithm 1 There theequation is first transformed into an equivalent but morewell-behaved strictly convex quartic function for which aconservative initial guess for 119905 (or rather 119906) is calculated

Figure 12 Planning trajectories through six different targets allstarting with the slope 34

Figure 13 Planning trajectories through six different targets allending at the slope minus34

which is then refined using multiple (but typically less thana total of six) modified or normal conservative Newtonrsquosmethod iterations This implementation has been carefullycrafted with both robustness and efficiency in mind As withany implementation numeric precision can become an issuewhen using extreme values but results for practical ranges aretypically within a few float epsilons of the exact value See thecomments in the implementation itself for more details

Alternatively when only a rough approximation of theminimal effort solution is needed the simpler ldquocurvinessrdquoplanner from (27) and (28) could be used with ℎ = 14 Thisapproximation is fairly accurate for larger values of V

infin as it

actually converges perfectly to the exact solution when Vinfin

goes to infinity But for high friction scenarios the difference

12 International Journal of Computer Games Technology

Figure 14 Planning trajectories through six different 119877s all with anarc height of 50

Figure 15 Planning trajectories through six different 119877s whileminimizing the initial velocity using the exact method (in black)and the approximate ℎ = 14 method (in red) in a medium-fictionscenario

between the exact method and the approximation becomesquite noticeable To get an idea of the size of the error for amedium friction scenario the trajectories resulting from theexact method and the approximation are shown side by sidein Figure 15 for the case of 119892 = 981ms2 and V

infin= 25ms

67 Hitting a Target Given the Initial Speed The last planningalgorithm covered in this paper solves for the time 119905

119903required

to hit the target [119903119909 119903119910] given the projectilersquos exact initial

speed 119904 The solution is found by solving V20119909

+ V20119910

= 1199042

for the positive time 119905119903to position [119903

119909 119903119910] where V

0119909and

V0119910

are once again defined by (21) and (22) respectively

Figure 16 Planning trajectories through six different119877s all startingat 100ms Each of the five reachable targets has a trajectory with a(red) low arc and a (black) high arc

This particular equation may be expanded into the followingquartic function

(1198962V2infin) 1199054

119903+ (21198962Vinfin119903119910) 1199053

119903+ (11989621199032

119909+ 11989621199032

119910+ 2119896Vinfin119903119910minus 1199042) 1199052

119903

+ 2119896 (1199032

119909+ 1199032

119910) 119905119903+ (1199032

119909+ 1199032

119910) = 0

(30)

Note that when 119904 is smaller than theminimal initial speedto hit [119903

119909 119903119910] (ie the sought solution of (29)) the problem

has no valid solutions But when 119904 is larger than that itwill always have exactly two valid solutions In that case thesmaller of the two 119905

119903values represents the time to hit the target

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

arc See Figure 16 for an exampleUsing a similar approach as in the previous section a spe-

cialized iterative solver can be implemented to solve this par-ticular quartic function The C++ function GetTimeToTar-getRGivenInitialSpeedS() in Algorithm 2 solves the equationfor either the high or low arc root and returns the resulting119905119903or returns 0 if no solution exists This implementation has

also beenwrittenwith robustness efficiency and accuracy fora wide range of parameters in mind Tests showed that theprocedure typically requires about six (modified) Newtonrsquosmethod iterations in total to converge to almost full floatprecision

7 Future work

As already hinted at in Section 4 planning to hit movingtargets can sometimes be done using a feedback loop betweena target position prediction formula and a planner for astatic target together converging to a solution over multipleiterations More research is necessary to explore the exact

International Journal of Computer Games Technology 13

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 thispaper can also be used for efficient exact collision detectionbetween a trajectory and an arbitrary polygonal mesh by test-ing the trajectory in principal space against the intersectionof the mesh and the principal plane This algorithm mighteven be combinedwith the planners from Sections 61 and 62to allow for efficient planning of the most optimal trajectoryabove or below a given polygonal mesh respectively Thesepossibilities have not been investigated in depth for this paperbut might be covered in future work

8 Conclusion

A novel analytic approximation of ballistic trajectories withair resistance has been presented that was designed to balancephysical accuracy and performance in a way that makes sensein the field of computer games

The approximationrsquos linearity in velocity has been used todefine a special principal frame of reference which makes itpossible to always work with these trajectories in a simplified2D space even though the original problem can be in 3Dwithwind coming from any directionThe combined result is thatthe proposed model is able to produce trajectories that arecomplex enough to be physically plausible while keeping themath simple enough to also allow for many different waysof efficient trajectory planning that otherwise might be tooimpractical for use in computer games

Conflict of Interests

The author declares that there is no conflict of interestsregarding the publication of this paper

References

[1] G M Gregorek Aerodynamic Drag of Model Rockets EstesIndustries Penrose Colo USA 1970

[2] R G Watts and R Ferrer ldquoThe lateral force on a spinningsphere aerodynamics of a curveballrdquo American Journal ofPhysics vol 55 no 1 pp 40ndash44 1987

[3] H D Curtis Orbital Mechanics for Engineering Students ch 1ndash5 Elsevier Butterworth-Heinemann BurlingtonMassUSA 1stedition 2005

[4] S T Thornton and J B Marion Classical Dynamics of Particlesand Systems BrooksCole Belmont Calif USA 2005

[5] P A Karkantzakos ldquoTime of flight and range of the motion of aprojectile in a constant gravitational field under the influenceof a retarding force proportional to the velocityrdquo Journal ofEngineering Science and Technology Review vol 2 no 1 pp 76ndash81 2009

[6] R D H Warburton J Wang and J Burgdofer ldquoAnalyticapproximations of projectile motion with quadratic air resis-tancerdquo Journal Service Science ampManagement no 3 pp 98ndash1052010

[7] P S Chudinov ldquoApproximate analytical investigation of projec-tile motion in a medium with quadratic drag forcerdquo Interna-tional Journal of Sports Science and Engineering vol 5 no 1 pp27ndash42 2011

[8] GW Parker ldquoProjectile motion with air resistance quadratic inthe speedrdquo American Journal of Physics vol 45 no 7 pp 606ndash610 1997

[9] DM BourgPhysics for GameDevelopers OrsquoReillyMedia 2002[10] D Herbison-Evans ldquoSolving quartics and cubics for graphicsrdquo

Tech Rep TR94-487 Basser Department of Computer ScienceUniversity of Sydney 1994

[11] WH Press S A TeukolskyW T Vetterling and B P FlanneryNumerical Recipes in C The Art of Scientific Computing Ch 9Cambridge University Press 2nd edition 1992

International Journal of

AerospaceEngineeringHindawi Publishing Corporationhttpwwwhindawicom Volume 2014

RoboticsJournal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Active and Passive Electronic Components

Control Scienceand Engineering

Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

International Journal of

RotatingMachinery

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporation httpwwwhindawicom

Journal ofEngineeringVolume 2014

Submit your manuscripts athttpwwwhindawicom

VLSI Design

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Shock and Vibration

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Civil EngineeringAdvances in

Acoustics and VibrationAdvances in

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Electrical and Computer Engineering

Journal of

Advances inOptoElectronics

Hindawi Publishing Corporation httpwwwhindawicom

Volume 2014

The Scientific World JournalHindawi Publishing Corporation httpwwwhindawicom Volume 2014

SensorsJournal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Modelling amp Simulation in EngineeringHindawi Publishing Corporation httpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Chemical EngineeringInternational Journal of Antennas and

Propagation

International Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Navigation and Observation

International Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

DistributedSensor Networks

International Journal of

Page 4: Research Article Analytical Ballistic Trajectories with ...downloads.hindawi.com/journals/ijcgt/2014/463489.pdf//a3 u + a4 = 0 for u where u = 1/t, but the latter is more well -behaved,

4 International Journal of Computer Games Technology

parameters will be defined here first Starting with a generalnote vector variables in this paper are always distinguishedfrom scalar variables by the rarr symbol above their namesAlso the length of any vector 119886 is denoted as 119886 which isequal toradic 119886 sdot 119886 where sdot is the dot product

A ballistic object is assumed to be launched from theinitial position

0with the initial velocity V

0at time 119905 =

0 Furthermore the object will be travelling through amedium (eg the air) which itself travels at the fixed (wind)velocity Vmedium It is also pulled by gravity at the fixedgravitational acceleration 119892 which is roughly 981ms2 forldquoearthlyrdquo applications The amount of drag 119896 while movingthrough the medium is defined as follows

119896 =1

2

1198921003817100381710038171003817Vterminal

1003817100381710038171003817 (1)

Here Vterminal is the invariant terminal velocity relative toVmedium that is reached eventually as the forces of gravity andair resistance finally cancel each other out On earth that isequivalent to saying that Vterminal is the fixed velocity that isapproached when the object is dropped from an enormousheight on awindless day Lastly the absolute terminal velocityVinfin being the absolute velocity approached when time 119905 goes

toinfin is therefore

Vinfin= Vterminal + Vmedium (2)

Together 0 V0 Vinfin and 119896 uniquely define a trajectory

in the proposed model To give a real-world example ofthe parameters defined above suppose a tennis ball with aterminal velocity of 30ms is served at 50ms at a 30∘ anglefrom the 381m high roof of the Empire State building intoa 10ms horizontal wind in 2D Then

0= [0 381] V

0=

[50 cos(30∘) 50 sin(30∘)] asymp [4330 25] 119896 = 01635 andVinfin= [minus10 minus30] The trajectory resulting from these values

is shown in Figure 1

32 Deriving the Trajectory Function In terms of the param-eters defined above the differential equation for the exactlinear drag model has the following analytic solution

linear (119905) =1

2119896(V0minus Vinfin) (1 minus 119890

minus2119896119905) + Vinfin119905 + 0 (3)

This function calculates the 2D or 3D position linear ona trajectory at time 119905 where 119905 ge 0 The above function isfar from new and will not be explained here in detail as ithas already been covered in many textbooks [4] occasionallyeven targeting game developers in particular [9] (albeit withslightly different notation and parameter definitions)

The function above will not be used directly in thispaper Instead it will be approximated by substituting itsexponential function 119890119909 with the first degree rational function(2 + 119909)(2 minus 119909) shown in Figure 2 One of the reasons forselecting this approximation over all possible other approx-imations to 119890119909 is that it has a value first derivative and secondderivative that match those of 119890119909 at 119909 = 0 This means that itapproximates 119890119909 near 119909 = 0 well and therefore will guaranteea good approximation of linear(119905) near 119905 = 0 Furthermore

Figure 1 Serving a tennis ball from the Empire State Buildingupwind

the first derivative of (2 + 119909)(2 minus 119909)monotonically decreasesfrom 1 to 0 as 119909 tends from 0 to minusinfin similar to thefirst derivative of 119890119909 itself When used to approximate 119890119909in linear(119905) this property will cause the initial velocity tomonotonically converge to the terminal velocity over timeNote that no polynomial approximation of 119890119909 has this specificproperty and of all possible rational functions that do possessthe above properties the proposed approximation is thesimplest and thus the most efficient Lastly its inverse is alsoa first degree rational function resulting in relatively simplealgebraic solutions for all (otherwise algebraic) equations thatuse it to approximate 119890119909

When the exponential function in linear(119905) is substitutedby the rational approximation the following function is theresult

(119905) =(V0+ 119896119905Vinfin) 119905

1 + 119896119905+ 0 (4)

Because of the aforementioned properties (119905) will notonly be more efficient to compute on modern computersbut it will also still share many of its characteristics withlinear(119905) and allow trajectory planning to be done withrelative ease The remainder of this paper mainly revolvesaround exploring these and other properties of (119905) togetherwith their implications

33 A Qualitative Comparison As (119905) is only an approxi-mation it will differ from the linear drag modelrsquos trajectoryfunction it is based on as well as from the results of othermodels For comparison purposes the trajectories that followfrom launching three different sport balls using four different

International Journal of Computer Games Technology 5

Figure 2 Approximating 119890119909 using a simple rational function

models are plotted side by side in Figure 3 All balls arelaunched at an 45∘ angle at 50ms on a windless earthly day(119892 = 981ms2) The different drag models are calibratedto respect the respective ballrsquos terminal velocities (except forthe dragless model which always has an infinite terminalvelocity)

Each of the alternating thick and thin segments in thetrajectories shown in Figure 3 (and in all other trajectoryplots in this paper for that matter) represents a projectilersquosmovement over a period of exactly one second making itpossible to not only compare the shapes of the trajectoriesbut also their local speeds The results from the novel (119905)function are plotted in black the results from the linear dragmodel linear(119905) are plotted in blue and the results of thephysically (most) correct quadratic drag model simulationquadratic(119905) are plotted in green Lastly the red paraboladragless(119905) represents the trajectory of each of the three ballsin a perfect vacuum (in other words when there is no dragand Vinfinrsquos length goes to infinite)

When comparing the trajectories for (119905) to the resultsof the two more accurate drag models they are certainlydifferent but they still reasonably mimic these in lookfeel and properties Consequently the proposed model isphysically at least quite plausible and is probably accurateenough for most computer game purposes Furthermorein some cases (119905) is actually closer to quadratic(119905) thanlinear(119905) making it in these cases arguably even physicallymore accurate than the model it is approximating to Lastlythe trajectories for all three drag models perfectly approachdragless(119905) when V

infinrsquos length goes to infinite

34 Exploring Some of p(t)rsquos Properties The function (119905)

given by (4) can be factored solved and parameterized inmany different ways For example basic algebra allows it tobe written as (119905) = 119886V

0+ as well where 119886 = 119905(1 + 119896119905) and

= Vinfin(119905minus119886)+

0 Note that in this form the initial velocity is

separated from all other factors and it becomes immediately

clear that (119905) is a linear function in terms of V0 This implies

that when launching multiple objects at some 119905 = 0 with allproperties equal except for the initial velocity each of theseobjects has the same value for 119886 and for This feature may beexploited in particle explosion systems on modern GPUs forexample requiring only one evaluation of 119886 and per frameper explosion (layer) on the CPU and one MAD (multiply-and-add) GPU instruction per particle per frame to calculateeach particlersquos position

The linearity of (119905) in terms of the initial velocity V0

can also be used for many other purposes For examplein Figure 4 (119905) is used to calculate the green and bluepositions for two different ldquoextremerdquo initial velocities whichare interpreted as the top-left and bottom-right positions ofa textured rectangle or quad Note that the (signed) size ofthe quad is thus simply green(119905) minus blue(119905) = (119886V

0green +

) minus (119886V0blue + ) = 119886 (V

0green minus V0blue) Furthermore all

the bilinearly interpolated texels within this quad includingthe red one willmove over (119905) trajectories themselves aswellby virtue of the linearity in terms of the initial velocities Inother words each texel will follow a (119905) trajectory with someinitial velocity that is interpolated bilinearly between thedifferent extreme initial velocities as if the individual texelsthemselves are under direct control of a physics simulationConsequently it should be physically plausible to use theabove to scale sprites and billboards of for example simplesmoke (for which V

infinwould typically be upwards to simulate

positive buoyancy) explosion debris and fireworksMany other useful properties can easily be derived from

(119905) as well For example the velocity V(119905) of (119905) is

V (119905) =120597 (119905)

120597119905=V0+ 119896119905 (2 + 119896119905) Vinfin(1 + 119896119905)

2 (5)

The nonnegative time 119905top 119899 at which the trajectory hitsits maximum in the direction of a given unit-length vector119899 can be found by solving V(119905) sdot 119899 = 0 for 119905 assuming that the

direction to find the maximum in is pointing away from Vinfin

(ie Vinfinsdot 119899 lt 0) If that assumption is false then the top will

be at time 119905 = 0 The solution to both cases is summarized bythe following formula

119905top 119899 =radic1 minusmin (0 (V

0sdot 119899) (V

infinsdot 119899)) minus 1

119896

(6)

This 119905top 119899 may be used with (4) to get the trajectoryrsquosmaximum position in the 119899 direction Note that when 119899 isaxis-aligned the dot products in (6) can be optimized awayFor example when 119899 is equal to the +119910 axis then 119905top 119899becomes

119905top119910 =radic1 minusmin (0 V

0119910Vinfin119910

) minus 1

119896

(7)

See Figure 5 for an example of V(119905) and (119905top119910)

6 International Journal of Computer Games Technology

Figure 3 The trajectories resulting from four models for three different ball types

Figure 4 The trajectory of a textured quad

4 Planning in World SpaceHitting a Target at a Given Time

When aprojectile needs to hit some given target position (119905)can be used to solve or ldquoplanrdquo the initial velocity that leads toprecisely hitting this target at some given future point in timeTo be more specific when trying to hit some position 119903 at thegiven time 119905

119903 the solution is found by solving (119905

119903) = 119903 for V

0

which results in the following formula

V0= 119896 ( 119903 minus

0minus Vinfin119905119903) +

119903 minus 0

119905119903

(8)

Figure 5 The velocity and 119910-top of a trajectory

In Figure 6 this formula is used to plan the trajectories tosix different target 119903 positions all taking exactly ten secondsto reach their target In other words 119905

119903= 10 which results in

having exactly five thick and five thin segments per trajectoryin this figure

One interesting property of this function is that the 119909and 119910 components (or the 119909 119910 and 119911 components in the3D case) of V

0are completely independent from each other

As a direct consequence similar projectiles that target the

International Journal of Computer Games Technology 7

Figure 6 Planning to hit all six different target positions in exactlyten seconds

same horizontal distance but a different height will alwaysmove at the same horizontal speed over the whole trajectoryand vice versa Also trajectories for targets at equal heightbut different horizontal distances will all have the same topheight as can be observed in Figure 6 as well

Note that the given time parameter 119905119903could be any

positive value including the one that is dependent on anotherfunction of 119903 One simple example of such a function is 119905

119903=

119903 minus 0Vstraight where Vstraight is a given average speed over

the straight line from 0to 119903 In Figure 7 this is illustrated

using Vstraight = 25msA function for 119905

119903could be made arbitrarily complex The

time planners that will be explored in Section 6 are examplesof moderately complex functions solving different additionalconstraints for 119905

119903given 119903 But even more complex planners

would be necessary if 119905119903and 119903 were to be dependent on

each other This can happen for example when a movingtarget needs to be hit while planning to launch at a fixedspeed making 119905

119903influence the prediction of the future target

position 119903 which influences 119905119903again These relationships are

not explored in detail in this paper but it is worthmentioningthat some of these problems may be solved iteratively bystarting with a rough estimate for 119905

119903and then letting it

converge to the right solution by repeatedly going from 119905119903to 119903

and from 119903 to an improved 119905119903 These iterations could possibly

even be spread over multiple frames to amortize costs forexample improving accuracy with each new frame

5 The Principal Frame of Referenceand Its Properties

Most planners for (119905) are still to be presented However asthese planners depend on a special frame of reference to keepthe required planner math as simple as possible this frame ofreference will be covered here first

Figure 7 Planning trajectories to six targets taking the exact sametime as travelling with 25ms over the straight line from initial totarget position

Inspecting (119905) reveals that the function always outputs0plus a linear combination (ie a weighted sum) of V

0and

Vinfin Geometrically this implies that all trajectories even with

wind coming from any 3D direction are guaranteed to lieon a plane spanned by V

0and Vinfin

which passes through 0

Consequently (119905)may be rewritten as

(119905) = 119909 (119905) + 119910 (119905) + 0 (9)

where and respectively describe an orthonormal tangentand bitangent direction in world space of the plane overwhich the projectile moves Within this planersquos 2D frameof reference the vector [119909(119905) 119910(119905)] describes the movementon the trajectory over time relative to

0and in terms of

this alternative 119909 axis (ie the tangent) and 119910 axis (ie thebitangent)

Put into terms perhaps more familiar to computer graph-ics and game developers the 2D function [119909(119905) 119910(119905)] is like aprocedural UV coordinate that defines a projectilersquos locationon an unwrapped plane which maps UV [0 0] to

0and

has an orthonormal tangent vector and bitangent vector All this is shown in Figure 8 where the trajectory (119905) isvisualized as the intersection between the described plane (onwhich is thus lies) and another curved surface

Although there is an infinite amount of ways to define the and vectors the following definitions are used in thispaper for their particularly useful properties

=

119889 minus ( 119889 sdot )

10038171003817100381710038171003817119889 minus ( 119889 sdot )

10038171003817100381710038171003817

=minusVinfin

Vinfin

(10)

8 International Journal of Computer Games Technology

Figure 8 A 3D trajectory with wind at an angle and its decompo-sition on the principal plane (in blue)

Here Vinfin

is used as a shorthand for Vinfin And 119889 = V

0

if V0is already known In the case that V

0is not (yet) known

any position relative to 0known to be lying on the trajectory

may be used for 119889 instead For example use 119889 = 119903 minus 0when

targeting the position 119903 Note that in the case that Vinfin

and 119889

are collinear the trajectory can be described by movementsolely in the direction To still get a valid 2D basis in thatcase an arbitrary vector that is noncollinear should be usedfor 119889 instead

The frame of reference defined by 0 and is what

will be called the trajectoryrsquos principal space It is called thatbecause this space allows the math describing the trajectoryto be decomposed into a particularly compact and well-behaved form In particular wind and gravity do not affectmovement over the principal axis at all but solely over theprincipal axis This allows the function 119909(119905) in (9) to besimplified as will be shown and put to good use soon

The second useful property of this principal space is thatit guarantees that V

119909ge 0 That is all initial and in-flight

velocities expressed in principal space are guaranteed to havenonnegative values on the 119909 axis causing ballistic objects tonever move to or be on the negative 119909 side of this space eventhough they obviously can stillmove in any direction inworldspace Similarly targets are never on the negative 119909 side inprincipal space either The advantage of this property is thatit once again will allow for further simplifications in some ofthe planner math that is still to be discussed

The third useful property of this particular space is thatit is easy to convert from world space to principal space and

back as and are orthonormal Converting from anyworldspace position to the position [119909 119910] in principal space andvice versa can simply be done using (11) and (12) respectivelyas follows

[119909 119910] = [( minus 0) sdot ( minus

0) sdot ] (11)

= 119909 + 119910 + 0 (12)

Similarly it is possible to efficiently convert from anyworld space velocity V to the principal velocity [V

119909 V119910] and

back using (13) and (14) respectively as follows

[V119909 V119910] = [V sdot V sdot ] (13)

V = V119909 + V

119910 (14)

Starting a new notational convention here for clarityvector names (ie variables decorated with a rarr symbol)are only used for variables in world space while variablesin principal space never use this decoration and alwaysrepresent individual scalar quantities So for example V

119909is

the 119909 component of the vector representing the world spacevelocity V while V

119909is a scalar representing a velocity in the 119909

direction in principal spaceNow that the frame of reference itself has been covered

it is possible to define the two scalar functions that make upthe principal space trajectory function [119909(119905) 119910(119905)]

119909 (119905) =V0119909119905

1 + 119896119905 (15)

119910 (119905) =(V0119910minus 119896119905Vinfin) 119905

1 + 119896119905 (16)

These functions are derived by transforming (119905) intothis space using (11) Note that gravity and wind do indeednot affect movement over the 119909 direction in this space And[119909(0) 119910(0)] is equal to [0 0] which means that trajectories inprincipal space always start at the origin (while starting at

0

in world space)The simpler formula for 119909(119905)makes it possible to uniquely

invert the function to get the time 119905 at which the 119909 componentof a certain position will be reached given the horizontalinitial velocity The solution is as follows

119905 =119909

V0119909minus 119896119909

(17)

Here 0 le 119909 le V0119909119896 as that is the valid range of 119909(119905)

for 119905 ge 0 as defined by (15) By plugging (17) into (16) thefollowing explicit 119910-for-119909 relationship is found

119910 (119909) =(119896Vinfin119909 (119896119909 minus V

0119909) + V0119910) 119909

V0119909

(18)

This function always has exactly one 119910 value for eachvalid 119909 value which would not necessarily be true foran explicit trajectory function in any other space This

International Journal of Computer Games Technology 9

property is demonstrated in Figure 9 showing a trajectorythat is equivalent to the trajectory shown in Figure 1 butwhich is now plotted using 119910(119909) in principal space perfectlyoverlaying the original trajectory when mapped back intoworld space

For completeness the principal space counterparts of theworld space properties described by (5) (6) and (7) are givenhere as well Consider

V119909(119905) =

V0119909

(1 + 119896119905)2

V119910(119905) =

V0119910minus 119896119905 (2 + 119896119905) V

infin

(1 + 119896119905)2

119905top 119899

=radic1 +max (0 [V

0119909 V0119910] sdot [119899119909 119899119910] (Vinfin119899119910)) minus 1

119896

119905top119910 =radic1 +max (0 V

0119910Vinfin119910

) minus 1

119896

(19)

Lastly the local slope in principal space in terms of time(ie V

119910(119905)V119909(119905)) and in terms of 119909 (ie 120597119910(119909)120597119909) is as

follows

V119910 (119905)

V119909(119905)

=V0119910minus 119896119905 (2 + 119896119905) Vinfin

V0119909

120597119910 (119909)

120597119909=V0119910+ Vinfin

V0119909

minusV0119909Vinfin

(119896119909 minus V0119909)2

(20)

6 Planning in Principal Space

As the planners in this section all depend on the properties oftrajectories in principal space the most relevant propertiesare briefly repeated here Per definition any ballistic objectin principal space is launched from the origin any targethas a nonnegative 119909 component and the combined effect ofgravity and wind results in a V

infinvalue that is exactly in the

minus119910 direction As the planners will expect their parameters tobe specified in principal space the parameters of any worldspace problem need to be converted to this space beforethey can be used To recap the necessary steps (assumingthe problem involves hitting some target position 119903) start bydefining the actual principal spacersquos and axes using (10)with 119889 = 119903 minus

0 Next convert 119903 (or any other requested

position) to principal space using (11) to get [119903119909 119903119910]

All planners covered here will return the exact time 119905119903

at which the target [119903119909 119903119910] must be hit to meet the plannerrsquos

given constraints To get the actual initial velocity in principalspace that leads to hitting [119903

119909 119903119910] at this 119905

119903 both 119901

119909(119905119903) = 119903119909

Figure 9 The same Empire State Building trajectory example asfrom Figure 1 but seen from the principal frame of reference

and 119901119910(119905119903) = 119903119910need to be solved for [V

0119909 V0119910] which can be

done using the following two formulas

V0119909= 119903119909(119896 +

1

119905119903

) (21)

V0119910= 119903119910(119896 +

1

119905119903

) + 119896Vinfin119905119903 (22)

To get the initial velocity in world space from these it ispossible to convert [V

0119909 V0119910] to V0using (14) But V

0may also

be directly calculated from 119905119903and 119903 through (8) Now that it is

clear how to make use of principal space planners in generalthe actual planners are presented

61 Hitting the Target Given Another Position to PassThroughA trajectory can be planned to pass through both position[119902119909 119902119910] and through target [119903

119909 119903119910] by solving 119910(119902

119909) = 119902

119910

and 119910(119903119909) = 119903

119910for V0119909 and using (17) on 119903

119909and V

0119909to

get 119905119903 This specific form of planning may be useful to shoot

through a hole or exactly over an object at [119902119909 119902119910] to hit

[119903119909 119903119910] example The solution to at what time the position

[119903119909 119903119910] needs to be hit is as follows

119905119903= 119904 + radic119904(119904 +

2119903119909

119896 (119903119909minus 119902119909)) (23)

where 119904 = (119903119909119902119910minus 119903119910119902119909)2Vinfin119902119909 Note that the line from the

origin to the target position with the smallest 119909 must be atleast as steep as the line from the origin to the position with

10 International Journal of Computer Games Technology

Figure 10 Planning trajectories through 119876 and six different 119877targets

the largest 119909 for a valid trajectory (and thus a real solution) toexist That is 119902

119910119902119909ge 119903119910119903119909if 119902119909lt 119903119909 and 119903

119910119903119909ge 119902119910119902119909if

119902119909gt 119903119909 In Figure 10 two of the six targets do not meet this

requirement explaining why there are only four trajectoriesthere

62 Hitting the Target While Touching a Line When lookingfor the time 119905

119903atwhich a trajectory passes through [119903

119909 119903119910] and

touches the line 119910 = 119886119909 + 119887 in principal space 120597119910(119909)120597119909 = 119886has to be solved for 119909 first which can then be used to solve119910(119909) = 119886119909+119887 for V

0119909 Both V

0119909and 119903119909can then be used again

with (17) to get 119905119903 The solution may be written as follows

119905119903=119904 + radic1199042 + 119896V

infin(119886119903119909minus 119903119910)

119896Vinfin

(24)

where 119904 = radic119887119896Vinfin+ (12)119896(119886119903

119909minus 119903119910+ 119887) Note that a real

solution can only exist when 119887 ge 0 and 119886119903119909+ 119887 ge 119903

119910 That is

the line must always pass through or be above the initial andthe target position

In the example presented in Figure 11 the line to betouched is chosen to be horizontal leading to a specificationof the trajectoriesrsquo vertical tops in principal space But it isalso possible to find the 119905

119903that leads to hitting a top defined

in another space For example to let a trajectoryrsquos top touchtheworld-space planewith normal 119899 and throughpoint 119902119910 =119886119909 + 119887 becomes the line in principal space that describes theintersection between this plane and the trajectoryrsquos principalplane In that case 119886 = minus( sdot 119899)( sdot 119899) and 119887 = (( 119902 minus

0) sdot

119899)( sdot 119899) As always when 119899 is axis-aligned the dot productscan be optimized away For example when only interestedin trajectories exactly hitting a world space height ℎ at theirtops (in the +119910 direction) this simplifies to 119886 = minus

119910119910and

119887 = (ℎ minus 0119910)119910

The principal space slope 119886 can also be calculated fromthe slope 119908 of a world-space elevation angle 120579world (ie

Figure 11 Planning trajectories through six different targets touch-ing a line at each top

119908 = tan(120579world)) by using the conversion formula 119886 =

(sign(119910)119908radic119904(2

119910+ 2119910) minus 1199082 minus 119904

119910119910)(1199042

119910minus 1199082) where

119904 = 1 + 1199082 and sign(119909) = [119909 ge 0] minus [119909 lt 0] This 119886 is only

valid if an equivalent elevationwith a positive119909 component inprincipal space exists which is the case if 119904(2

119910+2

119910)minus1199082ge 0

and [1 119908] sdot [radic1 minus 2119910 119910] gt 0 This world-space elevation

conversion may be particularly useful when used togetherwith the next two principal-space planners

63 Hitting the Target Given the Initial Slope This subsectionis about finding the time 119905

119903at which a projectile will hit

position [119903119909 119903119910]while being launched at slope 119886 Planning this

way may be useful when there is control over the projectilersquosinitial speed but not over its direction (eg for some weaponmounted on a fixed rig)

This problem is actually simply a special case of theprevious planner where 119887 = 0 meaning that the problemis equivalent to finding the trajectory that touches the line119910 = 119886119909 After substituting 119887 in (24) and applying somebasic algebra the solution may be written more compactly asfollows

119905119903=119904 + radic119904 (119904 + 2V

infin)

119896Vinfin

(25)

where 119904 = (12)119896(119886119903119909minus 119903119910) Obviously the slope 119886 has to be

steeper than the line from the origin to the target position(ie 119886 gt 119903

119910119903119909) for a solution to exist which is the case for all

but one target position in Figure 12

64 Hitting the Target Given the Target Slope Similarly it ispossible to hit [119903

119909 119903119910] given the exact slope 119886 at the target

position This type of planning allows for exact control overthe angle at which a target is hit Again this can be seen as a

International Journal of Computer Games Technology 11

special case of the planner from Section 62 using 119903119910minus 119886119903119909as

the value for 119887 When substituted and simplified this resultsin the following more direct formula

119905119903= radic

119903119910minus 119886119903119909

119896Vinfin

(26)

For this particular planner the slope 119886 needs to be lessthan the slope of the line from the origin to the target position(ie 119886 lt 119903

119910119903119909) Consequently only five of the six targets have

a valid trajectory in Figure 13

65 Hitting the Target Given the Arc Height or ldquoCurvinessrdquoThe time 119905

119903can also be calculated for a target position [119903

119909 119903119910]

and an ldquoarc heightrdquo 119887 Here 119887 is defined as the maximumdifference in the 119910 direction between the trajectory and thestraight line from origin to target Equivalently 119887 may beinterpreted as the height in principal space of the smallestparallelogram containing the whole trajectory as shown inFigure 14 This problem is another special case of the ldquolinetouchingrdquo problem and can be solved by substituting 119903

119910119903119909

for 119886 in (24) After applying some basic algebra the resultingformula may be written as follows

119905119903=

119887

Vinfin

+ 2radic119887

119896Vinfin

(27)

This function is particularly intuitive to plan with when

119887 = ℎradic1199032119909+ 1199032119910 (28)

where ℎ defines the ldquocurvinessrdquo of the trajectory For exampleℎ = 001 always leads to a low arc for any target positionwhileℎ = 05 always leads to a fairly high arc

66 Hitting the Target with (Almost)Minimal Effort A trajec-tory can also be planned to hit a target at [119903

119909 119903119910] with the

smallest initial speed (and thus the least amount of energy)possible Planning a trajectory this way requires finding thepositive time-to-target 119905

119903which solves 120597(V2

0119909+ V20119910)120597119905119903= 0

where V0119909

and V0119910

are defined by (21) and (22) respectivelyThis equation can be expanded into the following form

(1198962V2infin) 1199054

119903+ (1198962Vinfin119903119910) 1199053

119903minus 119896 (119903

2

119909+ 1199032

119910) 119905119903minus (1199032

119909+ 1199032

119910) = 0

(29)

Like all quartic equations solving this in a closed form ispossible but difficult to do robustly [10] In practice quarticequations are typically solved for any or all of their roots bygeneric iterative root solvers [11] But by exploiting domain-specific knowledge it is also possible to implement a special-ized iterative solver for (29) that is guaranteed to efficientlyconverge to the right root directly One possible implemen-tation is presented as a C++ function called GetTimeTo-TargetRWithMinimalInitialSpeed() in Algorithm 1 There theequation is first transformed into an equivalent but morewell-behaved strictly convex quartic function for which aconservative initial guess for 119905 (or rather 119906) is calculated

Figure 12 Planning trajectories through six different targets allstarting with the slope 34

Figure 13 Planning trajectories through six different targets allending at the slope minus34

which is then refined using multiple (but typically less thana total of six) modified or normal conservative Newtonrsquosmethod iterations This implementation has been carefullycrafted with both robustness and efficiency in mind As withany implementation numeric precision can become an issuewhen using extreme values but results for practical ranges aretypically within a few float epsilons of the exact value See thecomments in the implementation itself for more details

Alternatively when only a rough approximation of theminimal effort solution is needed the simpler ldquocurvinessrdquoplanner from (27) and (28) could be used with ℎ = 14 Thisapproximation is fairly accurate for larger values of V

infin as it

actually converges perfectly to the exact solution when Vinfin

goes to infinity But for high friction scenarios the difference

12 International Journal of Computer Games Technology

Figure 14 Planning trajectories through six different 119877s all with anarc height of 50

Figure 15 Planning trajectories through six different 119877s whileminimizing the initial velocity using the exact method (in black)and the approximate ℎ = 14 method (in red) in a medium-fictionscenario

between the exact method and the approximation becomesquite noticeable To get an idea of the size of the error for amedium friction scenario the trajectories resulting from theexact method and the approximation are shown side by sidein Figure 15 for the case of 119892 = 981ms2 and V

infin= 25ms

67 Hitting a Target Given the Initial Speed The last planningalgorithm covered in this paper solves for the time 119905

119903required

to hit the target [119903119909 119903119910] given the projectilersquos exact initial

speed 119904 The solution is found by solving V20119909

+ V20119910

= 1199042

for the positive time 119905119903to position [119903

119909 119903119910] where V

0119909and

V0119910

are once again defined by (21) and (22) respectively

Figure 16 Planning trajectories through six different119877s all startingat 100ms Each of the five reachable targets has a trajectory with a(red) low arc and a (black) high arc

This particular equation may be expanded into the followingquartic function

(1198962V2infin) 1199054

119903+ (21198962Vinfin119903119910) 1199053

119903+ (11989621199032

119909+ 11989621199032

119910+ 2119896Vinfin119903119910minus 1199042) 1199052

119903

+ 2119896 (1199032

119909+ 1199032

119910) 119905119903+ (1199032

119909+ 1199032

119910) = 0

(30)

Note that when 119904 is smaller than theminimal initial speedto hit [119903

119909 119903119910] (ie the sought solution of (29)) the problem

has no valid solutions But when 119904 is larger than that itwill always have exactly two valid solutions In that case thesmaller of the two 119905

119903values represents the time to hit the target

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

arc See Figure 16 for an exampleUsing a similar approach as in the previous section a spe-

cialized iterative solver can be implemented to solve this par-ticular quartic function The C++ function GetTimeToTar-getRGivenInitialSpeedS() in Algorithm 2 solves the equationfor either the high or low arc root and returns the resulting119905119903or returns 0 if no solution exists This implementation has

also beenwrittenwith robustness efficiency and accuracy fora wide range of parameters in mind Tests showed that theprocedure typically requires about six (modified) Newtonrsquosmethod iterations in total to converge to almost full floatprecision

7 Future work

As already hinted at in Section 4 planning to hit movingtargets can sometimes be done using a feedback loop betweena target position prediction formula and a planner for astatic target together converging to a solution over multipleiterations More research is necessary to explore the exact

International Journal of Computer Games Technology 13

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 thispaper can also be used for efficient exact collision detectionbetween a trajectory and an arbitrary polygonal mesh by test-ing the trajectory in principal space against the intersectionof the mesh and the principal plane This algorithm mighteven be combinedwith the planners from Sections 61 and 62to allow for efficient planning of the most optimal trajectoryabove or below a given polygonal mesh respectively Thesepossibilities have not been investigated in depth for this paperbut might be covered in future work

8 Conclusion

A novel analytic approximation of ballistic trajectories withair resistance has been presented that was designed to balancephysical accuracy and performance in a way that makes sensein the field of computer games

The approximationrsquos linearity in velocity has been used todefine a special principal frame of reference which makes itpossible to always work with these trajectories in a simplified2D space even though the original problem can be in 3Dwithwind coming from any directionThe combined result is thatthe proposed model is able to produce trajectories that arecomplex enough to be physically plausible while keeping themath simple enough to also allow for many different waysof efficient trajectory planning that otherwise might be tooimpractical for use in computer games

Conflict of Interests

The author declares that there is no conflict of interestsregarding the publication of this paper

References

[1] G M Gregorek Aerodynamic Drag of Model Rockets EstesIndustries Penrose Colo USA 1970

[2] R G Watts and R Ferrer ldquoThe lateral force on a spinningsphere aerodynamics of a curveballrdquo American Journal ofPhysics vol 55 no 1 pp 40ndash44 1987

[3] H D Curtis Orbital Mechanics for Engineering Students ch 1ndash5 Elsevier Butterworth-Heinemann BurlingtonMassUSA 1stedition 2005

[4] S T Thornton and J B Marion Classical Dynamics of Particlesand Systems BrooksCole Belmont Calif USA 2005

[5] P A Karkantzakos ldquoTime of flight and range of the motion of aprojectile in a constant gravitational field under the influenceof a retarding force proportional to the velocityrdquo Journal ofEngineering Science and Technology Review vol 2 no 1 pp 76ndash81 2009

[6] R D H Warburton J Wang and J Burgdofer ldquoAnalyticapproximations of projectile motion with quadratic air resis-tancerdquo Journal Service Science ampManagement no 3 pp 98ndash1052010

[7] P S Chudinov ldquoApproximate analytical investigation of projec-tile motion in a medium with quadratic drag forcerdquo Interna-tional Journal of Sports Science and Engineering vol 5 no 1 pp27ndash42 2011

[8] GW Parker ldquoProjectile motion with air resistance quadratic inthe speedrdquo American Journal of Physics vol 45 no 7 pp 606ndash610 1997

[9] DM BourgPhysics for GameDevelopers OrsquoReillyMedia 2002[10] D Herbison-Evans ldquoSolving quartics and cubics for graphicsrdquo

Tech Rep TR94-487 Basser Department of Computer ScienceUniversity of Sydney 1994

[11] WH Press S A TeukolskyW T Vetterling and B P FlanneryNumerical Recipes in C The Art of Scientific Computing Ch 9Cambridge University Press 2nd edition 1992

International Journal of

AerospaceEngineeringHindawi Publishing Corporationhttpwwwhindawicom Volume 2014

RoboticsJournal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Active and Passive Electronic Components

Control Scienceand Engineering

Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

International Journal of

RotatingMachinery

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporation httpwwwhindawicom

Journal ofEngineeringVolume 2014

Submit your manuscripts athttpwwwhindawicom

VLSI Design

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Shock and Vibration

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Civil EngineeringAdvances in

Acoustics and VibrationAdvances in

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Electrical and Computer Engineering

Journal of

Advances inOptoElectronics

Hindawi Publishing Corporation httpwwwhindawicom

Volume 2014

The Scientific World JournalHindawi Publishing Corporation httpwwwhindawicom Volume 2014

SensorsJournal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Modelling amp Simulation in EngineeringHindawi Publishing Corporation httpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Chemical EngineeringInternational Journal of Antennas and

Propagation

International Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Navigation and Observation

International Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

DistributedSensor Networks

International Journal of

Page 5: Research Article Analytical Ballistic Trajectories with ...downloads.hindawi.com/journals/ijcgt/2014/463489.pdf//a3 u + a4 = 0 for u where u = 1/t, but the latter is more well -behaved,

International Journal of Computer Games Technology 5

Figure 2 Approximating 119890119909 using a simple rational function

models are plotted side by side in Figure 3 All balls arelaunched at an 45∘ angle at 50ms on a windless earthly day(119892 = 981ms2) The different drag models are calibratedto respect the respective ballrsquos terminal velocities (except forthe dragless model which always has an infinite terminalvelocity)

Each of the alternating thick and thin segments in thetrajectories shown in Figure 3 (and in all other trajectoryplots in this paper for that matter) represents a projectilersquosmovement over a period of exactly one second making itpossible to not only compare the shapes of the trajectoriesbut also their local speeds The results from the novel (119905)function are plotted in black the results from the linear dragmodel linear(119905) are plotted in blue and the results of thephysically (most) correct quadratic drag model simulationquadratic(119905) are plotted in green Lastly the red paraboladragless(119905) represents the trajectory of each of the three ballsin a perfect vacuum (in other words when there is no dragand Vinfinrsquos length goes to infinite)

When comparing the trajectories for (119905) to the resultsof the two more accurate drag models they are certainlydifferent but they still reasonably mimic these in lookfeel and properties Consequently the proposed model isphysically at least quite plausible and is probably accurateenough for most computer game purposes Furthermorein some cases (119905) is actually closer to quadratic(119905) thanlinear(119905) making it in these cases arguably even physicallymore accurate than the model it is approximating to Lastlythe trajectories for all three drag models perfectly approachdragless(119905) when V

infinrsquos length goes to infinite

34 Exploring Some of p(t)rsquos Properties The function (119905)

given by (4) can be factored solved and parameterized inmany different ways For example basic algebra allows it tobe written as (119905) = 119886V

0+ as well where 119886 = 119905(1 + 119896119905) and

= Vinfin(119905minus119886)+

0 Note that in this form the initial velocity is

separated from all other factors and it becomes immediately

clear that (119905) is a linear function in terms of V0 This implies

that when launching multiple objects at some 119905 = 0 with allproperties equal except for the initial velocity each of theseobjects has the same value for 119886 and for This feature may beexploited in particle explosion systems on modern GPUs forexample requiring only one evaluation of 119886 and per frameper explosion (layer) on the CPU and one MAD (multiply-and-add) GPU instruction per particle per frame to calculateeach particlersquos position

The linearity of (119905) in terms of the initial velocity V0

can also be used for many other purposes For examplein Figure 4 (119905) is used to calculate the green and bluepositions for two different ldquoextremerdquo initial velocities whichare interpreted as the top-left and bottom-right positions ofa textured rectangle or quad Note that the (signed) size ofthe quad is thus simply green(119905) minus blue(119905) = (119886V

0green +

) minus (119886V0blue + ) = 119886 (V

0green minus V0blue) Furthermore all

the bilinearly interpolated texels within this quad includingthe red one willmove over (119905) trajectories themselves aswellby virtue of the linearity in terms of the initial velocities Inother words each texel will follow a (119905) trajectory with someinitial velocity that is interpolated bilinearly between thedifferent extreme initial velocities as if the individual texelsthemselves are under direct control of a physics simulationConsequently it should be physically plausible to use theabove to scale sprites and billboards of for example simplesmoke (for which V

infinwould typically be upwards to simulate

positive buoyancy) explosion debris and fireworksMany other useful properties can easily be derived from

(119905) as well For example the velocity V(119905) of (119905) is

V (119905) =120597 (119905)

120597119905=V0+ 119896119905 (2 + 119896119905) Vinfin(1 + 119896119905)

2 (5)

The nonnegative time 119905top 119899 at which the trajectory hitsits maximum in the direction of a given unit-length vector119899 can be found by solving V(119905) sdot 119899 = 0 for 119905 assuming that the

direction to find the maximum in is pointing away from Vinfin

(ie Vinfinsdot 119899 lt 0) If that assumption is false then the top will

be at time 119905 = 0 The solution to both cases is summarized bythe following formula

119905top 119899 =radic1 minusmin (0 (V

0sdot 119899) (V

infinsdot 119899)) minus 1

119896

(6)

This 119905top 119899 may be used with (4) to get the trajectoryrsquosmaximum position in the 119899 direction Note that when 119899 isaxis-aligned the dot products in (6) can be optimized awayFor example when 119899 is equal to the +119910 axis then 119905top 119899becomes

119905top119910 =radic1 minusmin (0 V

0119910Vinfin119910

) minus 1

119896

(7)

See Figure 5 for an example of V(119905) and (119905top119910)

6 International Journal of Computer Games Technology

Figure 3 The trajectories resulting from four models for three different ball types

Figure 4 The trajectory of a textured quad

4 Planning in World SpaceHitting a Target at a Given Time

When aprojectile needs to hit some given target position (119905)can be used to solve or ldquoplanrdquo the initial velocity that leads toprecisely hitting this target at some given future point in timeTo be more specific when trying to hit some position 119903 at thegiven time 119905

119903 the solution is found by solving (119905

119903) = 119903 for V

0

which results in the following formula

V0= 119896 ( 119903 minus

0minus Vinfin119905119903) +

119903 minus 0

119905119903

(8)

Figure 5 The velocity and 119910-top of a trajectory

In Figure 6 this formula is used to plan the trajectories tosix different target 119903 positions all taking exactly ten secondsto reach their target In other words 119905

119903= 10 which results in

having exactly five thick and five thin segments per trajectoryin this figure

One interesting property of this function is that the 119909and 119910 components (or the 119909 119910 and 119911 components in the3D case) of V

0are completely independent from each other

As a direct consequence similar projectiles that target the

International Journal of Computer Games Technology 7

Figure 6 Planning to hit all six different target positions in exactlyten seconds

same horizontal distance but a different height will alwaysmove at the same horizontal speed over the whole trajectoryand vice versa Also trajectories for targets at equal heightbut different horizontal distances will all have the same topheight as can be observed in Figure 6 as well

Note that the given time parameter 119905119903could be any

positive value including the one that is dependent on anotherfunction of 119903 One simple example of such a function is 119905

119903=

119903 minus 0Vstraight where Vstraight is a given average speed over

the straight line from 0to 119903 In Figure 7 this is illustrated

using Vstraight = 25msA function for 119905

119903could be made arbitrarily complex The

time planners that will be explored in Section 6 are examplesof moderately complex functions solving different additionalconstraints for 119905

119903given 119903 But even more complex planners

would be necessary if 119905119903and 119903 were to be dependent on

each other This can happen for example when a movingtarget needs to be hit while planning to launch at a fixedspeed making 119905

119903influence the prediction of the future target

position 119903 which influences 119905119903again These relationships are

not explored in detail in this paper but it is worthmentioningthat some of these problems may be solved iteratively bystarting with a rough estimate for 119905

119903and then letting it

converge to the right solution by repeatedly going from 119905119903to 119903

and from 119903 to an improved 119905119903 These iterations could possibly

even be spread over multiple frames to amortize costs forexample improving accuracy with each new frame

5 The Principal Frame of Referenceand Its Properties

Most planners for (119905) are still to be presented However asthese planners depend on a special frame of reference to keepthe required planner math as simple as possible this frame ofreference will be covered here first

Figure 7 Planning trajectories to six targets taking the exact sametime as travelling with 25ms over the straight line from initial totarget position

Inspecting (119905) reveals that the function always outputs0plus a linear combination (ie a weighted sum) of V

0and

Vinfin Geometrically this implies that all trajectories even with

wind coming from any 3D direction are guaranteed to lieon a plane spanned by V

0and Vinfin

which passes through 0

Consequently (119905)may be rewritten as

(119905) = 119909 (119905) + 119910 (119905) + 0 (9)

where and respectively describe an orthonormal tangentand bitangent direction in world space of the plane overwhich the projectile moves Within this planersquos 2D frameof reference the vector [119909(119905) 119910(119905)] describes the movementon the trajectory over time relative to

0and in terms of

this alternative 119909 axis (ie the tangent) and 119910 axis (ie thebitangent)

Put into terms perhaps more familiar to computer graph-ics and game developers the 2D function [119909(119905) 119910(119905)] is like aprocedural UV coordinate that defines a projectilersquos locationon an unwrapped plane which maps UV [0 0] to

0and

has an orthonormal tangent vector and bitangent vector All this is shown in Figure 8 where the trajectory (119905) isvisualized as the intersection between the described plane (onwhich is thus lies) and another curved surface

Although there is an infinite amount of ways to define the and vectors the following definitions are used in thispaper for their particularly useful properties

=

119889 minus ( 119889 sdot )

10038171003817100381710038171003817119889 minus ( 119889 sdot )

10038171003817100381710038171003817

=minusVinfin

Vinfin

(10)

8 International Journal of Computer Games Technology

Figure 8 A 3D trajectory with wind at an angle and its decompo-sition on the principal plane (in blue)

Here Vinfin

is used as a shorthand for Vinfin And 119889 = V

0

if V0is already known In the case that V

0is not (yet) known

any position relative to 0known to be lying on the trajectory

may be used for 119889 instead For example use 119889 = 119903 minus 0when

targeting the position 119903 Note that in the case that Vinfin

and 119889

are collinear the trajectory can be described by movementsolely in the direction To still get a valid 2D basis in thatcase an arbitrary vector that is noncollinear should be usedfor 119889 instead

The frame of reference defined by 0 and is what

will be called the trajectoryrsquos principal space It is called thatbecause this space allows the math describing the trajectoryto be decomposed into a particularly compact and well-behaved form In particular wind and gravity do not affectmovement over the principal axis at all but solely over theprincipal axis This allows the function 119909(119905) in (9) to besimplified as will be shown and put to good use soon

The second useful property of this principal space is thatit guarantees that V

119909ge 0 That is all initial and in-flight

velocities expressed in principal space are guaranteed to havenonnegative values on the 119909 axis causing ballistic objects tonever move to or be on the negative 119909 side of this space eventhough they obviously can stillmove in any direction inworldspace Similarly targets are never on the negative 119909 side inprincipal space either The advantage of this property is thatit once again will allow for further simplifications in some ofthe planner math that is still to be discussed

The third useful property of this particular space is thatit is easy to convert from world space to principal space and

back as and are orthonormal Converting from anyworldspace position to the position [119909 119910] in principal space andvice versa can simply be done using (11) and (12) respectivelyas follows

[119909 119910] = [( minus 0) sdot ( minus

0) sdot ] (11)

= 119909 + 119910 + 0 (12)

Similarly it is possible to efficiently convert from anyworld space velocity V to the principal velocity [V

119909 V119910] and

back using (13) and (14) respectively as follows

[V119909 V119910] = [V sdot V sdot ] (13)

V = V119909 + V

119910 (14)

Starting a new notational convention here for clarityvector names (ie variables decorated with a rarr symbol)are only used for variables in world space while variablesin principal space never use this decoration and alwaysrepresent individual scalar quantities So for example V

119909is

the 119909 component of the vector representing the world spacevelocity V while V

119909is a scalar representing a velocity in the 119909

direction in principal spaceNow that the frame of reference itself has been covered

it is possible to define the two scalar functions that make upthe principal space trajectory function [119909(119905) 119910(119905)]

119909 (119905) =V0119909119905

1 + 119896119905 (15)

119910 (119905) =(V0119910minus 119896119905Vinfin) 119905

1 + 119896119905 (16)

These functions are derived by transforming (119905) intothis space using (11) Note that gravity and wind do indeednot affect movement over the 119909 direction in this space And[119909(0) 119910(0)] is equal to [0 0] which means that trajectories inprincipal space always start at the origin (while starting at

0

in world space)The simpler formula for 119909(119905)makes it possible to uniquely

invert the function to get the time 119905 at which the 119909 componentof a certain position will be reached given the horizontalinitial velocity The solution is as follows

119905 =119909

V0119909minus 119896119909

(17)

Here 0 le 119909 le V0119909119896 as that is the valid range of 119909(119905)

for 119905 ge 0 as defined by (15) By plugging (17) into (16) thefollowing explicit 119910-for-119909 relationship is found

119910 (119909) =(119896Vinfin119909 (119896119909 minus V

0119909) + V0119910) 119909

V0119909

(18)

This function always has exactly one 119910 value for eachvalid 119909 value which would not necessarily be true foran explicit trajectory function in any other space This

International Journal of Computer Games Technology 9

property is demonstrated in Figure 9 showing a trajectorythat is equivalent to the trajectory shown in Figure 1 butwhich is now plotted using 119910(119909) in principal space perfectlyoverlaying the original trajectory when mapped back intoworld space

For completeness the principal space counterparts of theworld space properties described by (5) (6) and (7) are givenhere as well Consider

V119909(119905) =

V0119909

(1 + 119896119905)2

V119910(119905) =

V0119910minus 119896119905 (2 + 119896119905) V

infin

(1 + 119896119905)2

119905top 119899

=radic1 +max (0 [V

0119909 V0119910] sdot [119899119909 119899119910] (Vinfin119899119910)) minus 1

119896

119905top119910 =radic1 +max (0 V

0119910Vinfin119910

) minus 1

119896

(19)

Lastly the local slope in principal space in terms of time(ie V

119910(119905)V119909(119905)) and in terms of 119909 (ie 120597119910(119909)120597119909) is as

follows

V119910 (119905)

V119909(119905)

=V0119910minus 119896119905 (2 + 119896119905) Vinfin

V0119909

120597119910 (119909)

120597119909=V0119910+ Vinfin

V0119909

minusV0119909Vinfin

(119896119909 minus V0119909)2

(20)

6 Planning in Principal Space

As the planners in this section all depend on the properties oftrajectories in principal space the most relevant propertiesare briefly repeated here Per definition any ballistic objectin principal space is launched from the origin any targethas a nonnegative 119909 component and the combined effect ofgravity and wind results in a V

infinvalue that is exactly in the

minus119910 direction As the planners will expect their parameters tobe specified in principal space the parameters of any worldspace problem need to be converted to this space beforethey can be used To recap the necessary steps (assumingthe problem involves hitting some target position 119903) start bydefining the actual principal spacersquos and axes using (10)with 119889 = 119903 minus

0 Next convert 119903 (or any other requested

position) to principal space using (11) to get [119903119909 119903119910]

All planners covered here will return the exact time 119905119903

at which the target [119903119909 119903119910] must be hit to meet the plannerrsquos

given constraints To get the actual initial velocity in principalspace that leads to hitting [119903

119909 119903119910] at this 119905

119903 both 119901

119909(119905119903) = 119903119909

Figure 9 The same Empire State Building trajectory example asfrom Figure 1 but seen from the principal frame of reference

and 119901119910(119905119903) = 119903119910need to be solved for [V

0119909 V0119910] which can be

done using the following two formulas

V0119909= 119903119909(119896 +

1

119905119903

) (21)

V0119910= 119903119910(119896 +

1

119905119903

) + 119896Vinfin119905119903 (22)

To get the initial velocity in world space from these it ispossible to convert [V

0119909 V0119910] to V0using (14) But V

0may also

be directly calculated from 119905119903and 119903 through (8) Now that it is

clear how to make use of principal space planners in generalthe actual planners are presented

61 Hitting the Target Given Another Position to PassThroughA trajectory can be planned to pass through both position[119902119909 119902119910] and through target [119903

119909 119903119910] by solving 119910(119902

119909) = 119902

119910

and 119910(119903119909) = 119903

119910for V0119909 and using (17) on 119903

119909and V

0119909to

get 119905119903 This specific form of planning may be useful to shoot

through a hole or exactly over an object at [119902119909 119902119910] to hit

[119903119909 119903119910] example The solution to at what time the position

[119903119909 119903119910] needs to be hit is as follows

119905119903= 119904 + radic119904(119904 +

2119903119909

119896 (119903119909minus 119902119909)) (23)

where 119904 = (119903119909119902119910minus 119903119910119902119909)2Vinfin119902119909 Note that the line from the

origin to the target position with the smallest 119909 must be atleast as steep as the line from the origin to the position with

10 International Journal of Computer Games Technology

Figure 10 Planning trajectories through 119876 and six different 119877targets

the largest 119909 for a valid trajectory (and thus a real solution) toexist That is 119902

119910119902119909ge 119903119910119903119909if 119902119909lt 119903119909 and 119903

119910119903119909ge 119902119910119902119909if

119902119909gt 119903119909 In Figure 10 two of the six targets do not meet this

requirement explaining why there are only four trajectoriesthere

62 Hitting the Target While Touching a Line When lookingfor the time 119905

119903atwhich a trajectory passes through [119903

119909 119903119910] and

touches the line 119910 = 119886119909 + 119887 in principal space 120597119910(119909)120597119909 = 119886has to be solved for 119909 first which can then be used to solve119910(119909) = 119886119909+119887 for V

0119909 Both V

0119909and 119903119909can then be used again

with (17) to get 119905119903 The solution may be written as follows

119905119903=119904 + radic1199042 + 119896V

infin(119886119903119909minus 119903119910)

119896Vinfin

(24)

where 119904 = radic119887119896Vinfin+ (12)119896(119886119903

119909minus 119903119910+ 119887) Note that a real

solution can only exist when 119887 ge 0 and 119886119903119909+ 119887 ge 119903

119910 That is

the line must always pass through or be above the initial andthe target position

In the example presented in Figure 11 the line to betouched is chosen to be horizontal leading to a specificationof the trajectoriesrsquo vertical tops in principal space But it isalso possible to find the 119905

119903that leads to hitting a top defined

in another space For example to let a trajectoryrsquos top touchtheworld-space planewith normal 119899 and throughpoint 119902119910 =119886119909 + 119887 becomes the line in principal space that describes theintersection between this plane and the trajectoryrsquos principalplane In that case 119886 = minus( sdot 119899)( sdot 119899) and 119887 = (( 119902 minus

0) sdot

119899)( sdot 119899) As always when 119899 is axis-aligned the dot productscan be optimized away For example when only interestedin trajectories exactly hitting a world space height ℎ at theirtops (in the +119910 direction) this simplifies to 119886 = minus

119910119910and

119887 = (ℎ minus 0119910)119910

The principal space slope 119886 can also be calculated fromthe slope 119908 of a world-space elevation angle 120579world (ie

Figure 11 Planning trajectories through six different targets touch-ing a line at each top

119908 = tan(120579world)) by using the conversion formula 119886 =

(sign(119910)119908radic119904(2

119910+ 2119910) minus 1199082 minus 119904

119910119910)(1199042

119910minus 1199082) where

119904 = 1 + 1199082 and sign(119909) = [119909 ge 0] minus [119909 lt 0] This 119886 is only

valid if an equivalent elevationwith a positive119909 component inprincipal space exists which is the case if 119904(2

119910+2

119910)minus1199082ge 0

and [1 119908] sdot [radic1 minus 2119910 119910] gt 0 This world-space elevation

conversion may be particularly useful when used togetherwith the next two principal-space planners

63 Hitting the Target Given the Initial Slope This subsectionis about finding the time 119905

119903at which a projectile will hit

position [119903119909 119903119910]while being launched at slope 119886 Planning this

way may be useful when there is control over the projectilersquosinitial speed but not over its direction (eg for some weaponmounted on a fixed rig)

This problem is actually simply a special case of theprevious planner where 119887 = 0 meaning that the problemis equivalent to finding the trajectory that touches the line119910 = 119886119909 After substituting 119887 in (24) and applying somebasic algebra the solution may be written more compactly asfollows

119905119903=119904 + radic119904 (119904 + 2V

infin)

119896Vinfin

(25)

where 119904 = (12)119896(119886119903119909minus 119903119910) Obviously the slope 119886 has to be

steeper than the line from the origin to the target position(ie 119886 gt 119903

119910119903119909) for a solution to exist which is the case for all

but one target position in Figure 12

64 Hitting the Target Given the Target Slope Similarly it ispossible to hit [119903

119909 119903119910] given the exact slope 119886 at the target

position This type of planning allows for exact control overthe angle at which a target is hit Again this can be seen as a

International Journal of Computer Games Technology 11

special case of the planner from Section 62 using 119903119910minus 119886119903119909as

the value for 119887 When substituted and simplified this resultsin the following more direct formula

119905119903= radic

119903119910minus 119886119903119909

119896Vinfin

(26)

For this particular planner the slope 119886 needs to be lessthan the slope of the line from the origin to the target position(ie 119886 lt 119903

119910119903119909) Consequently only five of the six targets have

a valid trajectory in Figure 13

65 Hitting the Target Given the Arc Height or ldquoCurvinessrdquoThe time 119905

119903can also be calculated for a target position [119903

119909 119903119910]

and an ldquoarc heightrdquo 119887 Here 119887 is defined as the maximumdifference in the 119910 direction between the trajectory and thestraight line from origin to target Equivalently 119887 may beinterpreted as the height in principal space of the smallestparallelogram containing the whole trajectory as shown inFigure 14 This problem is another special case of the ldquolinetouchingrdquo problem and can be solved by substituting 119903

119910119903119909

for 119886 in (24) After applying some basic algebra the resultingformula may be written as follows

119905119903=

119887

Vinfin

+ 2radic119887

119896Vinfin

(27)

This function is particularly intuitive to plan with when

119887 = ℎradic1199032119909+ 1199032119910 (28)

where ℎ defines the ldquocurvinessrdquo of the trajectory For exampleℎ = 001 always leads to a low arc for any target positionwhileℎ = 05 always leads to a fairly high arc

66 Hitting the Target with (Almost)Minimal Effort A trajec-tory can also be planned to hit a target at [119903

119909 119903119910] with the

smallest initial speed (and thus the least amount of energy)possible Planning a trajectory this way requires finding thepositive time-to-target 119905

119903which solves 120597(V2

0119909+ V20119910)120597119905119903= 0

where V0119909

and V0119910

are defined by (21) and (22) respectivelyThis equation can be expanded into the following form

(1198962V2infin) 1199054

119903+ (1198962Vinfin119903119910) 1199053

119903minus 119896 (119903

2

119909+ 1199032

119910) 119905119903minus (1199032

119909+ 1199032

119910) = 0

(29)

Like all quartic equations solving this in a closed form ispossible but difficult to do robustly [10] In practice quarticequations are typically solved for any or all of their roots bygeneric iterative root solvers [11] But by exploiting domain-specific knowledge it is also possible to implement a special-ized iterative solver for (29) that is guaranteed to efficientlyconverge to the right root directly One possible implemen-tation is presented as a C++ function called GetTimeTo-TargetRWithMinimalInitialSpeed() in Algorithm 1 There theequation is first transformed into an equivalent but morewell-behaved strictly convex quartic function for which aconservative initial guess for 119905 (or rather 119906) is calculated

Figure 12 Planning trajectories through six different targets allstarting with the slope 34

Figure 13 Planning trajectories through six different targets allending at the slope minus34

which is then refined using multiple (but typically less thana total of six) modified or normal conservative Newtonrsquosmethod iterations This implementation has been carefullycrafted with both robustness and efficiency in mind As withany implementation numeric precision can become an issuewhen using extreme values but results for practical ranges aretypically within a few float epsilons of the exact value See thecomments in the implementation itself for more details

Alternatively when only a rough approximation of theminimal effort solution is needed the simpler ldquocurvinessrdquoplanner from (27) and (28) could be used with ℎ = 14 Thisapproximation is fairly accurate for larger values of V

infin as it

actually converges perfectly to the exact solution when Vinfin

goes to infinity But for high friction scenarios the difference

12 International Journal of Computer Games Technology

Figure 14 Planning trajectories through six different 119877s all with anarc height of 50

Figure 15 Planning trajectories through six different 119877s whileminimizing the initial velocity using the exact method (in black)and the approximate ℎ = 14 method (in red) in a medium-fictionscenario

between the exact method and the approximation becomesquite noticeable To get an idea of the size of the error for amedium friction scenario the trajectories resulting from theexact method and the approximation are shown side by sidein Figure 15 for the case of 119892 = 981ms2 and V

infin= 25ms

67 Hitting a Target Given the Initial Speed The last planningalgorithm covered in this paper solves for the time 119905

119903required

to hit the target [119903119909 119903119910] given the projectilersquos exact initial

speed 119904 The solution is found by solving V20119909

+ V20119910

= 1199042

for the positive time 119905119903to position [119903

119909 119903119910] where V

0119909and

V0119910

are once again defined by (21) and (22) respectively

Figure 16 Planning trajectories through six different119877s all startingat 100ms Each of the five reachable targets has a trajectory with a(red) low arc and a (black) high arc

This particular equation may be expanded into the followingquartic function

(1198962V2infin) 1199054

119903+ (21198962Vinfin119903119910) 1199053

119903+ (11989621199032

119909+ 11989621199032

119910+ 2119896Vinfin119903119910minus 1199042) 1199052

119903

+ 2119896 (1199032

119909+ 1199032

119910) 119905119903+ (1199032

119909+ 1199032

119910) = 0

(30)

Note that when 119904 is smaller than theminimal initial speedto hit [119903

119909 119903119910] (ie the sought solution of (29)) the problem

has no valid solutions But when 119904 is larger than that itwill always have exactly two valid solutions In that case thesmaller of the two 119905

119903values represents the time to hit the target

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

arc See Figure 16 for an exampleUsing a similar approach as in the previous section a spe-

cialized iterative solver can be implemented to solve this par-ticular quartic function The C++ function GetTimeToTar-getRGivenInitialSpeedS() in Algorithm 2 solves the equationfor either the high or low arc root and returns the resulting119905119903or returns 0 if no solution exists This implementation has

also beenwrittenwith robustness efficiency and accuracy fora wide range of parameters in mind Tests showed that theprocedure typically requires about six (modified) Newtonrsquosmethod iterations in total to converge to almost full floatprecision

7 Future work

As already hinted at in Section 4 planning to hit movingtargets can sometimes be done using a feedback loop betweena target position prediction formula and a planner for astatic target together converging to a solution over multipleiterations More research is necessary to explore the exact

International Journal of Computer Games Technology 13

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 thispaper can also be used for efficient exact collision detectionbetween a trajectory and an arbitrary polygonal mesh by test-ing the trajectory in principal space against the intersectionof the mesh and the principal plane This algorithm mighteven be combinedwith the planners from Sections 61 and 62to allow for efficient planning of the most optimal trajectoryabove or below a given polygonal mesh respectively Thesepossibilities have not been investigated in depth for this paperbut might be covered in future work

8 Conclusion

A novel analytic approximation of ballistic trajectories withair resistance has been presented that was designed to balancephysical accuracy and performance in a way that makes sensein the field of computer games

The approximationrsquos linearity in velocity has been used todefine a special principal frame of reference which makes itpossible to always work with these trajectories in a simplified2D space even though the original problem can be in 3Dwithwind coming from any directionThe combined result is thatthe proposed model is able to produce trajectories that arecomplex enough to be physically plausible while keeping themath simple enough to also allow for many different waysof efficient trajectory planning that otherwise might be tooimpractical for use in computer games

Conflict of Interests

The author declares that there is no conflict of interestsregarding the publication of this paper

References

[1] G M Gregorek Aerodynamic Drag of Model Rockets EstesIndustries Penrose Colo USA 1970

[2] R G Watts and R Ferrer ldquoThe lateral force on a spinningsphere aerodynamics of a curveballrdquo American Journal ofPhysics vol 55 no 1 pp 40ndash44 1987

[3] H D Curtis Orbital Mechanics for Engineering Students ch 1ndash5 Elsevier Butterworth-Heinemann BurlingtonMassUSA 1stedition 2005

[4] S T Thornton and J B Marion Classical Dynamics of Particlesand Systems BrooksCole Belmont Calif USA 2005

[5] P A Karkantzakos ldquoTime of flight and range of the motion of aprojectile in a constant gravitational field under the influenceof a retarding force proportional to the velocityrdquo Journal ofEngineering Science and Technology Review vol 2 no 1 pp 76ndash81 2009

[6] R D H Warburton J Wang and J Burgdofer ldquoAnalyticapproximations of projectile motion with quadratic air resis-tancerdquo Journal Service Science ampManagement no 3 pp 98ndash1052010

[7] P S Chudinov ldquoApproximate analytical investigation of projec-tile motion in a medium with quadratic drag forcerdquo Interna-tional Journal of Sports Science and Engineering vol 5 no 1 pp27ndash42 2011

[8] GW Parker ldquoProjectile motion with air resistance quadratic inthe speedrdquo American Journal of Physics vol 45 no 7 pp 606ndash610 1997

[9] DM BourgPhysics for GameDevelopers OrsquoReillyMedia 2002[10] D Herbison-Evans ldquoSolving quartics and cubics for graphicsrdquo

Tech Rep TR94-487 Basser Department of Computer ScienceUniversity of Sydney 1994

[11] WH Press S A TeukolskyW T Vetterling and B P FlanneryNumerical Recipes in C The Art of Scientific Computing Ch 9Cambridge University Press 2nd edition 1992

International Journal of

AerospaceEngineeringHindawi Publishing Corporationhttpwwwhindawicom Volume 2014

RoboticsJournal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Active and Passive Electronic Components

Control Scienceand Engineering

Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

International Journal of

RotatingMachinery

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporation httpwwwhindawicom

Journal ofEngineeringVolume 2014

Submit your manuscripts athttpwwwhindawicom

VLSI Design

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Shock and Vibration

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Civil EngineeringAdvances in

Acoustics and VibrationAdvances in

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Electrical and Computer Engineering

Journal of

Advances inOptoElectronics

Hindawi Publishing Corporation httpwwwhindawicom

Volume 2014

The Scientific World JournalHindawi Publishing Corporation httpwwwhindawicom Volume 2014

SensorsJournal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Modelling amp Simulation in EngineeringHindawi Publishing Corporation httpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Chemical EngineeringInternational Journal of Antennas and

Propagation

International Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Navigation and Observation

International Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

DistributedSensor Networks

International Journal of

Page 6: Research Article Analytical Ballistic Trajectories with ...downloads.hindawi.com/journals/ijcgt/2014/463489.pdf//a3 u + a4 = 0 for u where u = 1/t, but the latter is more well -behaved,

6 International Journal of Computer Games Technology

Figure 3 The trajectories resulting from four models for three different ball types

Figure 4 The trajectory of a textured quad

4 Planning in World SpaceHitting a Target at a Given Time

When aprojectile needs to hit some given target position (119905)can be used to solve or ldquoplanrdquo the initial velocity that leads toprecisely hitting this target at some given future point in timeTo be more specific when trying to hit some position 119903 at thegiven time 119905

119903 the solution is found by solving (119905

119903) = 119903 for V

0

which results in the following formula

V0= 119896 ( 119903 minus

0minus Vinfin119905119903) +

119903 minus 0

119905119903

(8)

Figure 5 The velocity and 119910-top of a trajectory

In Figure 6 this formula is used to plan the trajectories tosix different target 119903 positions all taking exactly ten secondsto reach their target In other words 119905

119903= 10 which results in

having exactly five thick and five thin segments per trajectoryin this figure

One interesting property of this function is that the 119909and 119910 components (or the 119909 119910 and 119911 components in the3D case) of V

0are completely independent from each other

As a direct consequence similar projectiles that target the

International Journal of Computer Games Technology 7

Figure 6 Planning to hit all six different target positions in exactlyten seconds

same horizontal distance but a different height will alwaysmove at the same horizontal speed over the whole trajectoryand vice versa Also trajectories for targets at equal heightbut different horizontal distances will all have the same topheight as can be observed in Figure 6 as well

Note that the given time parameter 119905119903could be any

positive value including the one that is dependent on anotherfunction of 119903 One simple example of such a function is 119905

119903=

119903 minus 0Vstraight where Vstraight is a given average speed over

the straight line from 0to 119903 In Figure 7 this is illustrated

using Vstraight = 25msA function for 119905

119903could be made arbitrarily complex The

time planners that will be explored in Section 6 are examplesof moderately complex functions solving different additionalconstraints for 119905

119903given 119903 But even more complex planners

would be necessary if 119905119903and 119903 were to be dependent on

each other This can happen for example when a movingtarget needs to be hit while planning to launch at a fixedspeed making 119905

119903influence the prediction of the future target

position 119903 which influences 119905119903again These relationships are

not explored in detail in this paper but it is worthmentioningthat some of these problems may be solved iteratively bystarting with a rough estimate for 119905

119903and then letting it

converge to the right solution by repeatedly going from 119905119903to 119903

and from 119903 to an improved 119905119903 These iterations could possibly

even be spread over multiple frames to amortize costs forexample improving accuracy with each new frame

5 The Principal Frame of Referenceand Its Properties

Most planners for (119905) are still to be presented However asthese planners depend on a special frame of reference to keepthe required planner math as simple as possible this frame ofreference will be covered here first

Figure 7 Planning trajectories to six targets taking the exact sametime as travelling with 25ms over the straight line from initial totarget position

Inspecting (119905) reveals that the function always outputs0plus a linear combination (ie a weighted sum) of V

0and

Vinfin Geometrically this implies that all trajectories even with

wind coming from any 3D direction are guaranteed to lieon a plane spanned by V

0and Vinfin

which passes through 0

Consequently (119905)may be rewritten as

(119905) = 119909 (119905) + 119910 (119905) + 0 (9)

where and respectively describe an orthonormal tangentand bitangent direction in world space of the plane overwhich the projectile moves Within this planersquos 2D frameof reference the vector [119909(119905) 119910(119905)] describes the movementon the trajectory over time relative to

0and in terms of

this alternative 119909 axis (ie the tangent) and 119910 axis (ie thebitangent)

Put into terms perhaps more familiar to computer graph-ics and game developers the 2D function [119909(119905) 119910(119905)] is like aprocedural UV coordinate that defines a projectilersquos locationon an unwrapped plane which maps UV [0 0] to

0and

has an orthonormal tangent vector and bitangent vector All this is shown in Figure 8 where the trajectory (119905) isvisualized as the intersection between the described plane (onwhich is thus lies) and another curved surface

Although there is an infinite amount of ways to define the and vectors the following definitions are used in thispaper for their particularly useful properties

=

119889 minus ( 119889 sdot )

10038171003817100381710038171003817119889 minus ( 119889 sdot )

10038171003817100381710038171003817

=minusVinfin

Vinfin

(10)

8 International Journal of Computer Games Technology

Figure 8 A 3D trajectory with wind at an angle and its decompo-sition on the principal plane (in blue)

Here Vinfin

is used as a shorthand for Vinfin And 119889 = V

0

if V0is already known In the case that V

0is not (yet) known

any position relative to 0known to be lying on the trajectory

may be used for 119889 instead For example use 119889 = 119903 minus 0when

targeting the position 119903 Note that in the case that Vinfin

and 119889

are collinear the trajectory can be described by movementsolely in the direction To still get a valid 2D basis in thatcase an arbitrary vector that is noncollinear should be usedfor 119889 instead

The frame of reference defined by 0 and is what

will be called the trajectoryrsquos principal space It is called thatbecause this space allows the math describing the trajectoryto be decomposed into a particularly compact and well-behaved form In particular wind and gravity do not affectmovement over the principal axis at all but solely over theprincipal axis This allows the function 119909(119905) in (9) to besimplified as will be shown and put to good use soon

The second useful property of this principal space is thatit guarantees that V

119909ge 0 That is all initial and in-flight

velocities expressed in principal space are guaranteed to havenonnegative values on the 119909 axis causing ballistic objects tonever move to or be on the negative 119909 side of this space eventhough they obviously can stillmove in any direction inworldspace Similarly targets are never on the negative 119909 side inprincipal space either The advantage of this property is thatit once again will allow for further simplifications in some ofthe planner math that is still to be discussed

The third useful property of this particular space is thatit is easy to convert from world space to principal space and

back as and are orthonormal Converting from anyworldspace position to the position [119909 119910] in principal space andvice versa can simply be done using (11) and (12) respectivelyas follows

[119909 119910] = [( minus 0) sdot ( minus

0) sdot ] (11)

= 119909 + 119910 + 0 (12)

Similarly it is possible to efficiently convert from anyworld space velocity V to the principal velocity [V

119909 V119910] and

back using (13) and (14) respectively as follows

[V119909 V119910] = [V sdot V sdot ] (13)

V = V119909 + V

119910 (14)

Starting a new notational convention here for clarityvector names (ie variables decorated with a rarr symbol)are only used for variables in world space while variablesin principal space never use this decoration and alwaysrepresent individual scalar quantities So for example V

119909is

the 119909 component of the vector representing the world spacevelocity V while V

119909is a scalar representing a velocity in the 119909

direction in principal spaceNow that the frame of reference itself has been covered

it is possible to define the two scalar functions that make upthe principal space trajectory function [119909(119905) 119910(119905)]

119909 (119905) =V0119909119905

1 + 119896119905 (15)

119910 (119905) =(V0119910minus 119896119905Vinfin) 119905

1 + 119896119905 (16)

These functions are derived by transforming (119905) intothis space using (11) Note that gravity and wind do indeednot affect movement over the 119909 direction in this space And[119909(0) 119910(0)] is equal to [0 0] which means that trajectories inprincipal space always start at the origin (while starting at

0

in world space)The simpler formula for 119909(119905)makes it possible to uniquely

invert the function to get the time 119905 at which the 119909 componentof a certain position will be reached given the horizontalinitial velocity The solution is as follows

119905 =119909

V0119909minus 119896119909

(17)

Here 0 le 119909 le V0119909119896 as that is the valid range of 119909(119905)

for 119905 ge 0 as defined by (15) By plugging (17) into (16) thefollowing explicit 119910-for-119909 relationship is found

119910 (119909) =(119896Vinfin119909 (119896119909 minus V

0119909) + V0119910) 119909

V0119909

(18)

This function always has exactly one 119910 value for eachvalid 119909 value which would not necessarily be true foran explicit trajectory function in any other space This

International Journal of Computer Games Technology 9

property is demonstrated in Figure 9 showing a trajectorythat is equivalent to the trajectory shown in Figure 1 butwhich is now plotted using 119910(119909) in principal space perfectlyoverlaying the original trajectory when mapped back intoworld space

For completeness the principal space counterparts of theworld space properties described by (5) (6) and (7) are givenhere as well Consider

V119909(119905) =

V0119909

(1 + 119896119905)2

V119910(119905) =

V0119910minus 119896119905 (2 + 119896119905) V

infin

(1 + 119896119905)2

119905top 119899

=radic1 +max (0 [V

0119909 V0119910] sdot [119899119909 119899119910] (Vinfin119899119910)) minus 1

119896

119905top119910 =radic1 +max (0 V

0119910Vinfin119910

) minus 1

119896

(19)

Lastly the local slope in principal space in terms of time(ie V

119910(119905)V119909(119905)) and in terms of 119909 (ie 120597119910(119909)120597119909) is as

follows

V119910 (119905)

V119909(119905)

=V0119910minus 119896119905 (2 + 119896119905) Vinfin

V0119909

120597119910 (119909)

120597119909=V0119910+ Vinfin

V0119909

minusV0119909Vinfin

(119896119909 minus V0119909)2

(20)

6 Planning in Principal Space

As the planners in this section all depend on the properties oftrajectories in principal space the most relevant propertiesare briefly repeated here Per definition any ballistic objectin principal space is launched from the origin any targethas a nonnegative 119909 component and the combined effect ofgravity and wind results in a V

infinvalue that is exactly in the

minus119910 direction As the planners will expect their parameters tobe specified in principal space the parameters of any worldspace problem need to be converted to this space beforethey can be used To recap the necessary steps (assumingthe problem involves hitting some target position 119903) start bydefining the actual principal spacersquos and axes using (10)with 119889 = 119903 minus

0 Next convert 119903 (or any other requested

position) to principal space using (11) to get [119903119909 119903119910]

All planners covered here will return the exact time 119905119903

at which the target [119903119909 119903119910] must be hit to meet the plannerrsquos

given constraints To get the actual initial velocity in principalspace that leads to hitting [119903

119909 119903119910] at this 119905

119903 both 119901

119909(119905119903) = 119903119909

Figure 9 The same Empire State Building trajectory example asfrom Figure 1 but seen from the principal frame of reference

and 119901119910(119905119903) = 119903119910need to be solved for [V

0119909 V0119910] which can be

done using the following two formulas

V0119909= 119903119909(119896 +

1

119905119903

) (21)

V0119910= 119903119910(119896 +

1

119905119903

) + 119896Vinfin119905119903 (22)

To get the initial velocity in world space from these it ispossible to convert [V

0119909 V0119910] to V0using (14) But V

0may also

be directly calculated from 119905119903and 119903 through (8) Now that it is

clear how to make use of principal space planners in generalthe actual planners are presented

61 Hitting the Target Given Another Position to PassThroughA trajectory can be planned to pass through both position[119902119909 119902119910] and through target [119903

119909 119903119910] by solving 119910(119902

119909) = 119902

119910

and 119910(119903119909) = 119903

119910for V0119909 and using (17) on 119903

119909and V

0119909to

get 119905119903 This specific form of planning may be useful to shoot

through a hole or exactly over an object at [119902119909 119902119910] to hit

[119903119909 119903119910] example The solution to at what time the position

[119903119909 119903119910] needs to be hit is as follows

119905119903= 119904 + radic119904(119904 +

2119903119909

119896 (119903119909minus 119902119909)) (23)

where 119904 = (119903119909119902119910minus 119903119910119902119909)2Vinfin119902119909 Note that the line from the

origin to the target position with the smallest 119909 must be atleast as steep as the line from the origin to the position with

10 International Journal of Computer Games Technology

Figure 10 Planning trajectories through 119876 and six different 119877targets

the largest 119909 for a valid trajectory (and thus a real solution) toexist That is 119902

119910119902119909ge 119903119910119903119909if 119902119909lt 119903119909 and 119903

119910119903119909ge 119902119910119902119909if

119902119909gt 119903119909 In Figure 10 two of the six targets do not meet this

requirement explaining why there are only four trajectoriesthere

62 Hitting the Target While Touching a Line When lookingfor the time 119905

119903atwhich a trajectory passes through [119903

119909 119903119910] and

touches the line 119910 = 119886119909 + 119887 in principal space 120597119910(119909)120597119909 = 119886has to be solved for 119909 first which can then be used to solve119910(119909) = 119886119909+119887 for V

0119909 Both V

0119909and 119903119909can then be used again

with (17) to get 119905119903 The solution may be written as follows

119905119903=119904 + radic1199042 + 119896V

infin(119886119903119909minus 119903119910)

119896Vinfin

(24)

where 119904 = radic119887119896Vinfin+ (12)119896(119886119903

119909minus 119903119910+ 119887) Note that a real

solution can only exist when 119887 ge 0 and 119886119903119909+ 119887 ge 119903

119910 That is

the line must always pass through or be above the initial andthe target position

In the example presented in Figure 11 the line to betouched is chosen to be horizontal leading to a specificationof the trajectoriesrsquo vertical tops in principal space But it isalso possible to find the 119905

119903that leads to hitting a top defined

in another space For example to let a trajectoryrsquos top touchtheworld-space planewith normal 119899 and throughpoint 119902119910 =119886119909 + 119887 becomes the line in principal space that describes theintersection between this plane and the trajectoryrsquos principalplane In that case 119886 = minus( sdot 119899)( sdot 119899) and 119887 = (( 119902 minus

0) sdot

119899)( sdot 119899) As always when 119899 is axis-aligned the dot productscan be optimized away For example when only interestedin trajectories exactly hitting a world space height ℎ at theirtops (in the +119910 direction) this simplifies to 119886 = minus

119910119910and

119887 = (ℎ minus 0119910)119910

The principal space slope 119886 can also be calculated fromthe slope 119908 of a world-space elevation angle 120579world (ie

Figure 11 Planning trajectories through six different targets touch-ing a line at each top

119908 = tan(120579world)) by using the conversion formula 119886 =

(sign(119910)119908radic119904(2

119910+ 2119910) minus 1199082 minus 119904

119910119910)(1199042

119910minus 1199082) where

119904 = 1 + 1199082 and sign(119909) = [119909 ge 0] minus [119909 lt 0] This 119886 is only

valid if an equivalent elevationwith a positive119909 component inprincipal space exists which is the case if 119904(2

119910+2

119910)minus1199082ge 0

and [1 119908] sdot [radic1 minus 2119910 119910] gt 0 This world-space elevation

conversion may be particularly useful when used togetherwith the next two principal-space planners

63 Hitting the Target Given the Initial Slope This subsectionis about finding the time 119905

119903at which a projectile will hit

position [119903119909 119903119910]while being launched at slope 119886 Planning this

way may be useful when there is control over the projectilersquosinitial speed but not over its direction (eg for some weaponmounted on a fixed rig)

This problem is actually simply a special case of theprevious planner where 119887 = 0 meaning that the problemis equivalent to finding the trajectory that touches the line119910 = 119886119909 After substituting 119887 in (24) and applying somebasic algebra the solution may be written more compactly asfollows

119905119903=119904 + radic119904 (119904 + 2V

infin)

119896Vinfin

(25)

where 119904 = (12)119896(119886119903119909minus 119903119910) Obviously the slope 119886 has to be

steeper than the line from the origin to the target position(ie 119886 gt 119903

119910119903119909) for a solution to exist which is the case for all

but one target position in Figure 12

64 Hitting the Target Given the Target Slope Similarly it ispossible to hit [119903

119909 119903119910] given the exact slope 119886 at the target

position This type of planning allows for exact control overthe angle at which a target is hit Again this can be seen as a

International Journal of Computer Games Technology 11

special case of the planner from Section 62 using 119903119910minus 119886119903119909as

the value for 119887 When substituted and simplified this resultsin the following more direct formula

119905119903= radic

119903119910minus 119886119903119909

119896Vinfin

(26)

For this particular planner the slope 119886 needs to be lessthan the slope of the line from the origin to the target position(ie 119886 lt 119903

119910119903119909) Consequently only five of the six targets have

a valid trajectory in Figure 13

65 Hitting the Target Given the Arc Height or ldquoCurvinessrdquoThe time 119905

119903can also be calculated for a target position [119903

119909 119903119910]

and an ldquoarc heightrdquo 119887 Here 119887 is defined as the maximumdifference in the 119910 direction between the trajectory and thestraight line from origin to target Equivalently 119887 may beinterpreted as the height in principal space of the smallestparallelogram containing the whole trajectory as shown inFigure 14 This problem is another special case of the ldquolinetouchingrdquo problem and can be solved by substituting 119903

119910119903119909

for 119886 in (24) After applying some basic algebra the resultingformula may be written as follows

119905119903=

119887

Vinfin

+ 2radic119887

119896Vinfin

(27)

This function is particularly intuitive to plan with when

119887 = ℎradic1199032119909+ 1199032119910 (28)

where ℎ defines the ldquocurvinessrdquo of the trajectory For exampleℎ = 001 always leads to a low arc for any target positionwhileℎ = 05 always leads to a fairly high arc

66 Hitting the Target with (Almost)Minimal Effort A trajec-tory can also be planned to hit a target at [119903

119909 119903119910] with the

smallest initial speed (and thus the least amount of energy)possible Planning a trajectory this way requires finding thepositive time-to-target 119905

119903which solves 120597(V2

0119909+ V20119910)120597119905119903= 0

where V0119909

and V0119910

are defined by (21) and (22) respectivelyThis equation can be expanded into the following form

(1198962V2infin) 1199054

119903+ (1198962Vinfin119903119910) 1199053

119903minus 119896 (119903

2

119909+ 1199032

119910) 119905119903minus (1199032

119909+ 1199032

119910) = 0

(29)

Like all quartic equations solving this in a closed form ispossible but difficult to do robustly [10] In practice quarticequations are typically solved for any or all of their roots bygeneric iterative root solvers [11] But by exploiting domain-specific knowledge it is also possible to implement a special-ized iterative solver for (29) that is guaranteed to efficientlyconverge to the right root directly One possible implemen-tation is presented as a C++ function called GetTimeTo-TargetRWithMinimalInitialSpeed() in Algorithm 1 There theequation is first transformed into an equivalent but morewell-behaved strictly convex quartic function for which aconservative initial guess for 119905 (or rather 119906) is calculated

Figure 12 Planning trajectories through six different targets allstarting with the slope 34

Figure 13 Planning trajectories through six different targets allending at the slope minus34

which is then refined using multiple (but typically less thana total of six) modified or normal conservative Newtonrsquosmethod iterations This implementation has been carefullycrafted with both robustness and efficiency in mind As withany implementation numeric precision can become an issuewhen using extreme values but results for practical ranges aretypically within a few float epsilons of the exact value See thecomments in the implementation itself for more details

Alternatively when only a rough approximation of theminimal effort solution is needed the simpler ldquocurvinessrdquoplanner from (27) and (28) could be used with ℎ = 14 Thisapproximation is fairly accurate for larger values of V

infin as it

actually converges perfectly to the exact solution when Vinfin

goes to infinity But for high friction scenarios the difference

12 International Journal of Computer Games Technology

Figure 14 Planning trajectories through six different 119877s all with anarc height of 50

Figure 15 Planning trajectories through six different 119877s whileminimizing the initial velocity using the exact method (in black)and the approximate ℎ = 14 method (in red) in a medium-fictionscenario

between the exact method and the approximation becomesquite noticeable To get an idea of the size of the error for amedium friction scenario the trajectories resulting from theexact method and the approximation are shown side by sidein Figure 15 for the case of 119892 = 981ms2 and V

infin= 25ms

67 Hitting a Target Given the Initial Speed The last planningalgorithm covered in this paper solves for the time 119905

119903required

to hit the target [119903119909 119903119910] given the projectilersquos exact initial

speed 119904 The solution is found by solving V20119909

+ V20119910

= 1199042

for the positive time 119905119903to position [119903

119909 119903119910] where V

0119909and

V0119910

are once again defined by (21) and (22) respectively

Figure 16 Planning trajectories through six different119877s all startingat 100ms Each of the five reachable targets has a trajectory with a(red) low arc and a (black) high arc

This particular equation may be expanded into the followingquartic function

(1198962V2infin) 1199054

119903+ (21198962Vinfin119903119910) 1199053

119903+ (11989621199032

119909+ 11989621199032

119910+ 2119896Vinfin119903119910minus 1199042) 1199052

119903

+ 2119896 (1199032

119909+ 1199032

119910) 119905119903+ (1199032

119909+ 1199032

119910) = 0

(30)

Note that when 119904 is smaller than theminimal initial speedto hit [119903

119909 119903119910] (ie the sought solution of (29)) the problem

has no valid solutions But when 119904 is larger than that itwill always have exactly two valid solutions In that case thesmaller of the two 119905

119903values represents the time to hit the target

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

arc See Figure 16 for an exampleUsing a similar approach as in the previous section a spe-

cialized iterative solver can be implemented to solve this par-ticular quartic function The C++ function GetTimeToTar-getRGivenInitialSpeedS() in Algorithm 2 solves the equationfor either the high or low arc root and returns the resulting119905119903or returns 0 if no solution exists This implementation has

also beenwrittenwith robustness efficiency and accuracy fora wide range of parameters in mind Tests showed that theprocedure typically requires about six (modified) Newtonrsquosmethod iterations in total to converge to almost full floatprecision

7 Future work

As already hinted at in Section 4 planning to hit movingtargets can sometimes be done using a feedback loop betweena target position prediction formula and a planner for astatic target together converging to a solution over multipleiterations More research is necessary to explore the exact

International Journal of Computer Games Technology 13

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 thispaper can also be used for efficient exact collision detectionbetween a trajectory and an arbitrary polygonal mesh by test-ing the trajectory in principal space against the intersectionof the mesh and the principal plane This algorithm mighteven be combinedwith the planners from Sections 61 and 62to allow for efficient planning of the most optimal trajectoryabove or below a given polygonal mesh respectively Thesepossibilities have not been investigated in depth for this paperbut might be covered in future work

8 Conclusion

A novel analytic approximation of ballistic trajectories withair resistance has been presented that was designed to balancephysical accuracy and performance in a way that makes sensein the field of computer games

The approximationrsquos linearity in velocity has been used todefine a special principal frame of reference which makes itpossible to always work with these trajectories in a simplified2D space even though the original problem can be in 3Dwithwind coming from any directionThe combined result is thatthe proposed model is able to produce trajectories that arecomplex enough to be physically plausible while keeping themath simple enough to also allow for many different waysof efficient trajectory planning that otherwise might be tooimpractical for use in computer games

Conflict of Interests

The author declares that there is no conflict of interestsregarding the publication of this paper

References

[1] G M Gregorek Aerodynamic Drag of Model Rockets EstesIndustries Penrose Colo USA 1970

[2] R G Watts and R Ferrer ldquoThe lateral force on a spinningsphere aerodynamics of a curveballrdquo American Journal ofPhysics vol 55 no 1 pp 40ndash44 1987

[3] H D Curtis Orbital Mechanics for Engineering Students ch 1ndash5 Elsevier Butterworth-Heinemann BurlingtonMassUSA 1stedition 2005

[4] S T Thornton and J B Marion Classical Dynamics of Particlesand Systems BrooksCole Belmont Calif USA 2005

[5] P A Karkantzakos ldquoTime of flight and range of the motion of aprojectile in a constant gravitational field under the influenceof a retarding force proportional to the velocityrdquo Journal ofEngineering Science and Technology Review vol 2 no 1 pp 76ndash81 2009

[6] R D H Warburton J Wang and J Burgdofer ldquoAnalyticapproximations of projectile motion with quadratic air resis-tancerdquo Journal Service Science ampManagement no 3 pp 98ndash1052010

[7] P S Chudinov ldquoApproximate analytical investigation of projec-tile motion in a medium with quadratic drag forcerdquo Interna-tional Journal of Sports Science and Engineering vol 5 no 1 pp27ndash42 2011

[8] GW Parker ldquoProjectile motion with air resistance quadratic inthe speedrdquo American Journal of Physics vol 45 no 7 pp 606ndash610 1997

[9] DM BourgPhysics for GameDevelopers OrsquoReillyMedia 2002[10] D Herbison-Evans ldquoSolving quartics and cubics for graphicsrdquo

Tech Rep TR94-487 Basser Department of Computer ScienceUniversity of Sydney 1994

[11] WH Press S A TeukolskyW T Vetterling and B P FlanneryNumerical Recipes in C The Art of Scientific Computing Ch 9Cambridge University Press 2nd edition 1992

International Journal of

AerospaceEngineeringHindawi Publishing Corporationhttpwwwhindawicom Volume 2014

RoboticsJournal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Active and Passive Electronic Components

Control Scienceand Engineering

Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

International Journal of

RotatingMachinery

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporation httpwwwhindawicom

Journal ofEngineeringVolume 2014

Submit your manuscripts athttpwwwhindawicom

VLSI Design

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Shock and Vibration

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Civil EngineeringAdvances in

Acoustics and VibrationAdvances in

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Electrical and Computer Engineering

Journal of

Advances inOptoElectronics

Hindawi Publishing Corporation httpwwwhindawicom

Volume 2014

The Scientific World JournalHindawi Publishing Corporation httpwwwhindawicom Volume 2014

SensorsJournal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Modelling amp Simulation in EngineeringHindawi Publishing Corporation httpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Chemical EngineeringInternational Journal of Antennas and

Propagation

International Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Navigation and Observation

International Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

DistributedSensor Networks

International Journal of

Page 7: Research Article Analytical Ballistic Trajectories with ...downloads.hindawi.com/journals/ijcgt/2014/463489.pdf//a3 u + a4 = 0 for u where u = 1/t, but the latter is more well -behaved,

International Journal of Computer Games Technology 7

Figure 6 Planning to hit all six different target positions in exactlyten seconds

same horizontal distance but a different height will alwaysmove at the same horizontal speed over the whole trajectoryand vice versa Also trajectories for targets at equal heightbut different horizontal distances will all have the same topheight as can be observed in Figure 6 as well

Note that the given time parameter 119905119903could be any

positive value including the one that is dependent on anotherfunction of 119903 One simple example of such a function is 119905

119903=

119903 minus 0Vstraight where Vstraight is a given average speed over

the straight line from 0to 119903 In Figure 7 this is illustrated

using Vstraight = 25msA function for 119905

119903could be made arbitrarily complex The

time planners that will be explored in Section 6 are examplesof moderately complex functions solving different additionalconstraints for 119905

119903given 119903 But even more complex planners

would be necessary if 119905119903and 119903 were to be dependent on

each other This can happen for example when a movingtarget needs to be hit while planning to launch at a fixedspeed making 119905

119903influence the prediction of the future target

position 119903 which influences 119905119903again These relationships are

not explored in detail in this paper but it is worthmentioningthat some of these problems may be solved iteratively bystarting with a rough estimate for 119905

119903and then letting it

converge to the right solution by repeatedly going from 119905119903to 119903

and from 119903 to an improved 119905119903 These iterations could possibly

even be spread over multiple frames to amortize costs forexample improving accuracy with each new frame

5 The Principal Frame of Referenceand Its Properties

Most planners for (119905) are still to be presented However asthese planners depend on a special frame of reference to keepthe required planner math as simple as possible this frame ofreference will be covered here first

Figure 7 Planning trajectories to six targets taking the exact sametime as travelling with 25ms over the straight line from initial totarget position

Inspecting (119905) reveals that the function always outputs0plus a linear combination (ie a weighted sum) of V

0and

Vinfin Geometrically this implies that all trajectories even with

wind coming from any 3D direction are guaranteed to lieon a plane spanned by V

0and Vinfin

which passes through 0

Consequently (119905)may be rewritten as

(119905) = 119909 (119905) + 119910 (119905) + 0 (9)

where and respectively describe an orthonormal tangentand bitangent direction in world space of the plane overwhich the projectile moves Within this planersquos 2D frameof reference the vector [119909(119905) 119910(119905)] describes the movementon the trajectory over time relative to

0and in terms of

this alternative 119909 axis (ie the tangent) and 119910 axis (ie thebitangent)

Put into terms perhaps more familiar to computer graph-ics and game developers the 2D function [119909(119905) 119910(119905)] is like aprocedural UV coordinate that defines a projectilersquos locationon an unwrapped plane which maps UV [0 0] to

0and

has an orthonormal tangent vector and bitangent vector All this is shown in Figure 8 where the trajectory (119905) isvisualized as the intersection between the described plane (onwhich is thus lies) and another curved surface

Although there is an infinite amount of ways to define the and vectors the following definitions are used in thispaper for their particularly useful properties

=

119889 minus ( 119889 sdot )

10038171003817100381710038171003817119889 minus ( 119889 sdot )

10038171003817100381710038171003817

=minusVinfin

Vinfin

(10)

8 International Journal of Computer Games Technology

Figure 8 A 3D trajectory with wind at an angle and its decompo-sition on the principal plane (in blue)

Here Vinfin

is used as a shorthand for Vinfin And 119889 = V

0

if V0is already known In the case that V

0is not (yet) known

any position relative to 0known to be lying on the trajectory

may be used for 119889 instead For example use 119889 = 119903 minus 0when

targeting the position 119903 Note that in the case that Vinfin

and 119889

are collinear the trajectory can be described by movementsolely in the direction To still get a valid 2D basis in thatcase an arbitrary vector that is noncollinear should be usedfor 119889 instead

The frame of reference defined by 0 and is what

will be called the trajectoryrsquos principal space It is called thatbecause this space allows the math describing the trajectoryto be decomposed into a particularly compact and well-behaved form In particular wind and gravity do not affectmovement over the principal axis at all but solely over theprincipal axis This allows the function 119909(119905) in (9) to besimplified as will be shown and put to good use soon

The second useful property of this principal space is thatit guarantees that V

119909ge 0 That is all initial and in-flight

velocities expressed in principal space are guaranteed to havenonnegative values on the 119909 axis causing ballistic objects tonever move to or be on the negative 119909 side of this space eventhough they obviously can stillmove in any direction inworldspace Similarly targets are never on the negative 119909 side inprincipal space either The advantage of this property is thatit once again will allow for further simplifications in some ofthe planner math that is still to be discussed

The third useful property of this particular space is thatit is easy to convert from world space to principal space and

back as and are orthonormal Converting from anyworldspace position to the position [119909 119910] in principal space andvice versa can simply be done using (11) and (12) respectivelyas follows

[119909 119910] = [( minus 0) sdot ( minus

0) sdot ] (11)

= 119909 + 119910 + 0 (12)

Similarly it is possible to efficiently convert from anyworld space velocity V to the principal velocity [V

119909 V119910] and

back using (13) and (14) respectively as follows

[V119909 V119910] = [V sdot V sdot ] (13)

V = V119909 + V

119910 (14)

Starting a new notational convention here for clarityvector names (ie variables decorated with a rarr symbol)are only used for variables in world space while variablesin principal space never use this decoration and alwaysrepresent individual scalar quantities So for example V

119909is

the 119909 component of the vector representing the world spacevelocity V while V

119909is a scalar representing a velocity in the 119909

direction in principal spaceNow that the frame of reference itself has been covered

it is possible to define the two scalar functions that make upthe principal space trajectory function [119909(119905) 119910(119905)]

119909 (119905) =V0119909119905

1 + 119896119905 (15)

119910 (119905) =(V0119910minus 119896119905Vinfin) 119905

1 + 119896119905 (16)

These functions are derived by transforming (119905) intothis space using (11) Note that gravity and wind do indeednot affect movement over the 119909 direction in this space And[119909(0) 119910(0)] is equal to [0 0] which means that trajectories inprincipal space always start at the origin (while starting at

0

in world space)The simpler formula for 119909(119905)makes it possible to uniquely

invert the function to get the time 119905 at which the 119909 componentof a certain position will be reached given the horizontalinitial velocity The solution is as follows

119905 =119909

V0119909minus 119896119909

(17)

Here 0 le 119909 le V0119909119896 as that is the valid range of 119909(119905)

for 119905 ge 0 as defined by (15) By plugging (17) into (16) thefollowing explicit 119910-for-119909 relationship is found

119910 (119909) =(119896Vinfin119909 (119896119909 minus V

0119909) + V0119910) 119909

V0119909

(18)

This function always has exactly one 119910 value for eachvalid 119909 value which would not necessarily be true foran explicit trajectory function in any other space This

International Journal of Computer Games Technology 9

property is demonstrated in Figure 9 showing a trajectorythat is equivalent to the trajectory shown in Figure 1 butwhich is now plotted using 119910(119909) in principal space perfectlyoverlaying the original trajectory when mapped back intoworld space

For completeness the principal space counterparts of theworld space properties described by (5) (6) and (7) are givenhere as well Consider

V119909(119905) =

V0119909

(1 + 119896119905)2

V119910(119905) =

V0119910minus 119896119905 (2 + 119896119905) V

infin

(1 + 119896119905)2

119905top 119899

=radic1 +max (0 [V

0119909 V0119910] sdot [119899119909 119899119910] (Vinfin119899119910)) minus 1

119896

119905top119910 =radic1 +max (0 V

0119910Vinfin119910

) minus 1

119896

(19)

Lastly the local slope in principal space in terms of time(ie V

119910(119905)V119909(119905)) and in terms of 119909 (ie 120597119910(119909)120597119909) is as

follows

V119910 (119905)

V119909(119905)

=V0119910minus 119896119905 (2 + 119896119905) Vinfin

V0119909

120597119910 (119909)

120597119909=V0119910+ Vinfin

V0119909

minusV0119909Vinfin

(119896119909 minus V0119909)2

(20)

6 Planning in Principal Space

As the planners in this section all depend on the properties oftrajectories in principal space the most relevant propertiesare briefly repeated here Per definition any ballistic objectin principal space is launched from the origin any targethas a nonnegative 119909 component and the combined effect ofgravity and wind results in a V

infinvalue that is exactly in the

minus119910 direction As the planners will expect their parameters tobe specified in principal space the parameters of any worldspace problem need to be converted to this space beforethey can be used To recap the necessary steps (assumingthe problem involves hitting some target position 119903) start bydefining the actual principal spacersquos and axes using (10)with 119889 = 119903 minus

0 Next convert 119903 (or any other requested

position) to principal space using (11) to get [119903119909 119903119910]

All planners covered here will return the exact time 119905119903

at which the target [119903119909 119903119910] must be hit to meet the plannerrsquos

given constraints To get the actual initial velocity in principalspace that leads to hitting [119903

119909 119903119910] at this 119905

119903 both 119901

119909(119905119903) = 119903119909

Figure 9 The same Empire State Building trajectory example asfrom Figure 1 but seen from the principal frame of reference

and 119901119910(119905119903) = 119903119910need to be solved for [V

0119909 V0119910] which can be

done using the following two formulas

V0119909= 119903119909(119896 +

1

119905119903

) (21)

V0119910= 119903119910(119896 +

1

119905119903

) + 119896Vinfin119905119903 (22)

To get the initial velocity in world space from these it ispossible to convert [V

0119909 V0119910] to V0using (14) But V

0may also

be directly calculated from 119905119903and 119903 through (8) Now that it is

clear how to make use of principal space planners in generalthe actual planners are presented

61 Hitting the Target Given Another Position to PassThroughA trajectory can be planned to pass through both position[119902119909 119902119910] and through target [119903

119909 119903119910] by solving 119910(119902

119909) = 119902

119910

and 119910(119903119909) = 119903

119910for V0119909 and using (17) on 119903

119909and V

0119909to

get 119905119903 This specific form of planning may be useful to shoot

through a hole or exactly over an object at [119902119909 119902119910] to hit

[119903119909 119903119910] example The solution to at what time the position

[119903119909 119903119910] needs to be hit is as follows

119905119903= 119904 + radic119904(119904 +

2119903119909

119896 (119903119909minus 119902119909)) (23)

where 119904 = (119903119909119902119910minus 119903119910119902119909)2Vinfin119902119909 Note that the line from the

origin to the target position with the smallest 119909 must be atleast as steep as the line from the origin to the position with

10 International Journal of Computer Games Technology

Figure 10 Planning trajectories through 119876 and six different 119877targets

the largest 119909 for a valid trajectory (and thus a real solution) toexist That is 119902

119910119902119909ge 119903119910119903119909if 119902119909lt 119903119909 and 119903

119910119903119909ge 119902119910119902119909if

119902119909gt 119903119909 In Figure 10 two of the six targets do not meet this

requirement explaining why there are only four trajectoriesthere

62 Hitting the Target While Touching a Line When lookingfor the time 119905

119903atwhich a trajectory passes through [119903

119909 119903119910] and

touches the line 119910 = 119886119909 + 119887 in principal space 120597119910(119909)120597119909 = 119886has to be solved for 119909 first which can then be used to solve119910(119909) = 119886119909+119887 for V

0119909 Both V

0119909and 119903119909can then be used again

with (17) to get 119905119903 The solution may be written as follows

119905119903=119904 + radic1199042 + 119896V

infin(119886119903119909minus 119903119910)

119896Vinfin

(24)

where 119904 = radic119887119896Vinfin+ (12)119896(119886119903

119909minus 119903119910+ 119887) Note that a real

solution can only exist when 119887 ge 0 and 119886119903119909+ 119887 ge 119903

119910 That is

the line must always pass through or be above the initial andthe target position

In the example presented in Figure 11 the line to betouched is chosen to be horizontal leading to a specificationof the trajectoriesrsquo vertical tops in principal space But it isalso possible to find the 119905

119903that leads to hitting a top defined

in another space For example to let a trajectoryrsquos top touchtheworld-space planewith normal 119899 and throughpoint 119902119910 =119886119909 + 119887 becomes the line in principal space that describes theintersection between this plane and the trajectoryrsquos principalplane In that case 119886 = minus( sdot 119899)( sdot 119899) and 119887 = (( 119902 minus

0) sdot

119899)( sdot 119899) As always when 119899 is axis-aligned the dot productscan be optimized away For example when only interestedin trajectories exactly hitting a world space height ℎ at theirtops (in the +119910 direction) this simplifies to 119886 = minus

119910119910and

119887 = (ℎ minus 0119910)119910

The principal space slope 119886 can also be calculated fromthe slope 119908 of a world-space elevation angle 120579world (ie

Figure 11 Planning trajectories through six different targets touch-ing a line at each top

119908 = tan(120579world)) by using the conversion formula 119886 =

(sign(119910)119908radic119904(2

119910+ 2119910) minus 1199082 minus 119904

119910119910)(1199042

119910minus 1199082) where

119904 = 1 + 1199082 and sign(119909) = [119909 ge 0] minus [119909 lt 0] This 119886 is only

valid if an equivalent elevationwith a positive119909 component inprincipal space exists which is the case if 119904(2

119910+2

119910)minus1199082ge 0

and [1 119908] sdot [radic1 minus 2119910 119910] gt 0 This world-space elevation

conversion may be particularly useful when used togetherwith the next two principal-space planners

63 Hitting the Target Given the Initial Slope This subsectionis about finding the time 119905

119903at which a projectile will hit

position [119903119909 119903119910]while being launched at slope 119886 Planning this

way may be useful when there is control over the projectilersquosinitial speed but not over its direction (eg for some weaponmounted on a fixed rig)

This problem is actually simply a special case of theprevious planner where 119887 = 0 meaning that the problemis equivalent to finding the trajectory that touches the line119910 = 119886119909 After substituting 119887 in (24) and applying somebasic algebra the solution may be written more compactly asfollows

119905119903=119904 + radic119904 (119904 + 2V

infin)

119896Vinfin

(25)

where 119904 = (12)119896(119886119903119909minus 119903119910) Obviously the slope 119886 has to be

steeper than the line from the origin to the target position(ie 119886 gt 119903

119910119903119909) for a solution to exist which is the case for all

but one target position in Figure 12

64 Hitting the Target Given the Target Slope Similarly it ispossible to hit [119903

119909 119903119910] given the exact slope 119886 at the target

position This type of planning allows for exact control overthe angle at which a target is hit Again this can be seen as a

International Journal of Computer Games Technology 11

special case of the planner from Section 62 using 119903119910minus 119886119903119909as

the value for 119887 When substituted and simplified this resultsin the following more direct formula

119905119903= radic

119903119910minus 119886119903119909

119896Vinfin

(26)

For this particular planner the slope 119886 needs to be lessthan the slope of the line from the origin to the target position(ie 119886 lt 119903

119910119903119909) Consequently only five of the six targets have

a valid trajectory in Figure 13

65 Hitting the Target Given the Arc Height or ldquoCurvinessrdquoThe time 119905

119903can also be calculated for a target position [119903

119909 119903119910]

and an ldquoarc heightrdquo 119887 Here 119887 is defined as the maximumdifference in the 119910 direction between the trajectory and thestraight line from origin to target Equivalently 119887 may beinterpreted as the height in principal space of the smallestparallelogram containing the whole trajectory as shown inFigure 14 This problem is another special case of the ldquolinetouchingrdquo problem and can be solved by substituting 119903

119910119903119909

for 119886 in (24) After applying some basic algebra the resultingformula may be written as follows

119905119903=

119887

Vinfin

+ 2radic119887

119896Vinfin

(27)

This function is particularly intuitive to plan with when

119887 = ℎradic1199032119909+ 1199032119910 (28)

where ℎ defines the ldquocurvinessrdquo of the trajectory For exampleℎ = 001 always leads to a low arc for any target positionwhileℎ = 05 always leads to a fairly high arc

66 Hitting the Target with (Almost)Minimal Effort A trajec-tory can also be planned to hit a target at [119903

119909 119903119910] with the

smallest initial speed (and thus the least amount of energy)possible Planning a trajectory this way requires finding thepositive time-to-target 119905

119903which solves 120597(V2

0119909+ V20119910)120597119905119903= 0

where V0119909

and V0119910

are defined by (21) and (22) respectivelyThis equation can be expanded into the following form

(1198962V2infin) 1199054

119903+ (1198962Vinfin119903119910) 1199053

119903minus 119896 (119903

2

119909+ 1199032

119910) 119905119903minus (1199032

119909+ 1199032

119910) = 0

(29)

Like all quartic equations solving this in a closed form ispossible but difficult to do robustly [10] In practice quarticequations are typically solved for any or all of their roots bygeneric iterative root solvers [11] But by exploiting domain-specific knowledge it is also possible to implement a special-ized iterative solver for (29) that is guaranteed to efficientlyconverge to the right root directly One possible implemen-tation is presented as a C++ function called GetTimeTo-TargetRWithMinimalInitialSpeed() in Algorithm 1 There theequation is first transformed into an equivalent but morewell-behaved strictly convex quartic function for which aconservative initial guess for 119905 (or rather 119906) is calculated

Figure 12 Planning trajectories through six different targets allstarting with the slope 34

Figure 13 Planning trajectories through six different targets allending at the slope minus34

which is then refined using multiple (but typically less thana total of six) modified or normal conservative Newtonrsquosmethod iterations This implementation has been carefullycrafted with both robustness and efficiency in mind As withany implementation numeric precision can become an issuewhen using extreme values but results for practical ranges aretypically within a few float epsilons of the exact value See thecomments in the implementation itself for more details

Alternatively when only a rough approximation of theminimal effort solution is needed the simpler ldquocurvinessrdquoplanner from (27) and (28) could be used with ℎ = 14 Thisapproximation is fairly accurate for larger values of V

infin as it

actually converges perfectly to the exact solution when Vinfin

goes to infinity But for high friction scenarios the difference

12 International Journal of Computer Games Technology

Figure 14 Planning trajectories through six different 119877s all with anarc height of 50

Figure 15 Planning trajectories through six different 119877s whileminimizing the initial velocity using the exact method (in black)and the approximate ℎ = 14 method (in red) in a medium-fictionscenario

between the exact method and the approximation becomesquite noticeable To get an idea of the size of the error for amedium friction scenario the trajectories resulting from theexact method and the approximation are shown side by sidein Figure 15 for the case of 119892 = 981ms2 and V

infin= 25ms

67 Hitting a Target Given the Initial Speed The last planningalgorithm covered in this paper solves for the time 119905

119903required

to hit the target [119903119909 119903119910] given the projectilersquos exact initial

speed 119904 The solution is found by solving V20119909

+ V20119910

= 1199042

for the positive time 119905119903to position [119903

119909 119903119910] where V

0119909and

V0119910

are once again defined by (21) and (22) respectively

Figure 16 Planning trajectories through six different119877s all startingat 100ms Each of the five reachable targets has a trajectory with a(red) low arc and a (black) high arc

This particular equation may be expanded into the followingquartic function

(1198962V2infin) 1199054

119903+ (21198962Vinfin119903119910) 1199053

119903+ (11989621199032

119909+ 11989621199032

119910+ 2119896Vinfin119903119910minus 1199042) 1199052

119903

+ 2119896 (1199032

119909+ 1199032

119910) 119905119903+ (1199032

119909+ 1199032

119910) = 0

(30)

Note that when 119904 is smaller than theminimal initial speedto hit [119903

119909 119903119910] (ie the sought solution of (29)) the problem

has no valid solutions But when 119904 is larger than that itwill always have exactly two valid solutions In that case thesmaller of the two 119905

119903values represents the time to hit the target

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

arc See Figure 16 for an exampleUsing a similar approach as in the previous section a spe-

cialized iterative solver can be implemented to solve this par-ticular quartic function The C++ function GetTimeToTar-getRGivenInitialSpeedS() in Algorithm 2 solves the equationfor either the high or low arc root and returns the resulting119905119903or returns 0 if no solution exists This implementation has

also beenwrittenwith robustness efficiency and accuracy fora wide range of parameters in mind Tests showed that theprocedure typically requires about six (modified) Newtonrsquosmethod iterations in total to converge to almost full floatprecision

7 Future work

As already hinted at in Section 4 planning to hit movingtargets can sometimes be done using a feedback loop betweena target position prediction formula and a planner for astatic target together converging to a solution over multipleiterations More research is necessary to explore the exact

International Journal of Computer Games Technology 13

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 thispaper can also be used for efficient exact collision detectionbetween a trajectory and an arbitrary polygonal mesh by test-ing the trajectory in principal space against the intersectionof the mesh and the principal plane This algorithm mighteven be combinedwith the planners from Sections 61 and 62to allow for efficient planning of the most optimal trajectoryabove or below a given polygonal mesh respectively Thesepossibilities have not been investigated in depth for this paperbut might be covered in future work

8 Conclusion

A novel analytic approximation of ballistic trajectories withair resistance has been presented that was designed to balancephysical accuracy and performance in a way that makes sensein the field of computer games

The approximationrsquos linearity in velocity has been used todefine a special principal frame of reference which makes itpossible to always work with these trajectories in a simplified2D space even though the original problem can be in 3Dwithwind coming from any directionThe combined result is thatthe proposed model is able to produce trajectories that arecomplex enough to be physically plausible while keeping themath simple enough to also allow for many different waysof efficient trajectory planning that otherwise might be tooimpractical for use in computer games

Conflict of Interests

The author declares that there is no conflict of interestsregarding the publication of this paper

References

[1] G M Gregorek Aerodynamic Drag of Model Rockets EstesIndustries Penrose Colo USA 1970

[2] R G Watts and R Ferrer ldquoThe lateral force on a spinningsphere aerodynamics of a curveballrdquo American Journal ofPhysics vol 55 no 1 pp 40ndash44 1987

[3] H D Curtis Orbital Mechanics for Engineering Students ch 1ndash5 Elsevier Butterworth-Heinemann BurlingtonMassUSA 1stedition 2005

[4] S T Thornton and J B Marion Classical Dynamics of Particlesand Systems BrooksCole Belmont Calif USA 2005

[5] P A Karkantzakos ldquoTime of flight and range of the motion of aprojectile in a constant gravitational field under the influenceof a retarding force proportional to the velocityrdquo Journal ofEngineering Science and Technology Review vol 2 no 1 pp 76ndash81 2009

[6] R D H Warburton J Wang and J Burgdofer ldquoAnalyticapproximations of projectile motion with quadratic air resis-tancerdquo Journal Service Science ampManagement no 3 pp 98ndash1052010

[7] P S Chudinov ldquoApproximate analytical investigation of projec-tile motion in a medium with quadratic drag forcerdquo Interna-tional Journal of Sports Science and Engineering vol 5 no 1 pp27ndash42 2011

[8] GW Parker ldquoProjectile motion with air resistance quadratic inthe speedrdquo American Journal of Physics vol 45 no 7 pp 606ndash610 1997

[9] DM BourgPhysics for GameDevelopers OrsquoReillyMedia 2002[10] D Herbison-Evans ldquoSolving quartics and cubics for graphicsrdquo

Tech Rep TR94-487 Basser Department of Computer ScienceUniversity of Sydney 1994

[11] WH Press S A TeukolskyW T Vetterling and B P FlanneryNumerical Recipes in C The Art of Scientific Computing Ch 9Cambridge University Press 2nd edition 1992

International Journal of

AerospaceEngineeringHindawi Publishing Corporationhttpwwwhindawicom Volume 2014

RoboticsJournal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Active and Passive Electronic Components

Control Scienceand Engineering

Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

International Journal of

RotatingMachinery

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporation httpwwwhindawicom

Journal ofEngineeringVolume 2014

Submit your manuscripts athttpwwwhindawicom

VLSI Design

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Shock and Vibration

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Civil EngineeringAdvances in

Acoustics and VibrationAdvances in

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Electrical and Computer Engineering

Journal of

Advances inOptoElectronics

Hindawi Publishing Corporation httpwwwhindawicom

Volume 2014

The Scientific World JournalHindawi Publishing Corporation httpwwwhindawicom Volume 2014

SensorsJournal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Modelling amp Simulation in EngineeringHindawi Publishing Corporation httpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Chemical EngineeringInternational Journal of Antennas and

Propagation

International Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Navigation and Observation

International Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

DistributedSensor Networks

International Journal of

Page 8: Research Article Analytical Ballistic Trajectories with ...downloads.hindawi.com/journals/ijcgt/2014/463489.pdf//a3 u + a4 = 0 for u where u = 1/t, but the latter is more well -behaved,

8 International Journal of Computer Games Technology

Figure 8 A 3D trajectory with wind at an angle and its decompo-sition on the principal plane (in blue)

Here Vinfin

is used as a shorthand for Vinfin And 119889 = V

0

if V0is already known In the case that V

0is not (yet) known

any position relative to 0known to be lying on the trajectory

may be used for 119889 instead For example use 119889 = 119903 minus 0when

targeting the position 119903 Note that in the case that Vinfin

and 119889

are collinear the trajectory can be described by movementsolely in the direction To still get a valid 2D basis in thatcase an arbitrary vector that is noncollinear should be usedfor 119889 instead

The frame of reference defined by 0 and is what

will be called the trajectoryrsquos principal space It is called thatbecause this space allows the math describing the trajectoryto be decomposed into a particularly compact and well-behaved form In particular wind and gravity do not affectmovement over the principal axis at all but solely over theprincipal axis This allows the function 119909(119905) in (9) to besimplified as will be shown and put to good use soon

The second useful property of this principal space is thatit guarantees that V

119909ge 0 That is all initial and in-flight

velocities expressed in principal space are guaranteed to havenonnegative values on the 119909 axis causing ballistic objects tonever move to or be on the negative 119909 side of this space eventhough they obviously can stillmove in any direction inworldspace Similarly targets are never on the negative 119909 side inprincipal space either The advantage of this property is thatit once again will allow for further simplifications in some ofthe planner math that is still to be discussed

The third useful property of this particular space is thatit is easy to convert from world space to principal space and

back as and are orthonormal Converting from anyworldspace position to the position [119909 119910] in principal space andvice versa can simply be done using (11) and (12) respectivelyas follows

[119909 119910] = [( minus 0) sdot ( minus

0) sdot ] (11)

= 119909 + 119910 + 0 (12)

Similarly it is possible to efficiently convert from anyworld space velocity V to the principal velocity [V

119909 V119910] and

back using (13) and (14) respectively as follows

[V119909 V119910] = [V sdot V sdot ] (13)

V = V119909 + V

119910 (14)

Starting a new notational convention here for clarityvector names (ie variables decorated with a rarr symbol)are only used for variables in world space while variablesin principal space never use this decoration and alwaysrepresent individual scalar quantities So for example V

119909is

the 119909 component of the vector representing the world spacevelocity V while V

119909is a scalar representing a velocity in the 119909

direction in principal spaceNow that the frame of reference itself has been covered

it is possible to define the two scalar functions that make upthe principal space trajectory function [119909(119905) 119910(119905)]

119909 (119905) =V0119909119905

1 + 119896119905 (15)

119910 (119905) =(V0119910minus 119896119905Vinfin) 119905

1 + 119896119905 (16)

These functions are derived by transforming (119905) intothis space using (11) Note that gravity and wind do indeednot affect movement over the 119909 direction in this space And[119909(0) 119910(0)] is equal to [0 0] which means that trajectories inprincipal space always start at the origin (while starting at

0

in world space)The simpler formula for 119909(119905)makes it possible to uniquely

invert the function to get the time 119905 at which the 119909 componentof a certain position will be reached given the horizontalinitial velocity The solution is as follows

119905 =119909

V0119909minus 119896119909

(17)

Here 0 le 119909 le V0119909119896 as that is the valid range of 119909(119905)

for 119905 ge 0 as defined by (15) By plugging (17) into (16) thefollowing explicit 119910-for-119909 relationship is found

119910 (119909) =(119896Vinfin119909 (119896119909 minus V

0119909) + V0119910) 119909

V0119909

(18)

This function always has exactly one 119910 value for eachvalid 119909 value which would not necessarily be true foran explicit trajectory function in any other space This

International Journal of Computer Games Technology 9

property is demonstrated in Figure 9 showing a trajectorythat is equivalent to the trajectory shown in Figure 1 butwhich is now plotted using 119910(119909) in principal space perfectlyoverlaying the original trajectory when mapped back intoworld space

For completeness the principal space counterparts of theworld space properties described by (5) (6) and (7) are givenhere as well Consider

V119909(119905) =

V0119909

(1 + 119896119905)2

V119910(119905) =

V0119910minus 119896119905 (2 + 119896119905) V

infin

(1 + 119896119905)2

119905top 119899

=radic1 +max (0 [V

0119909 V0119910] sdot [119899119909 119899119910] (Vinfin119899119910)) minus 1

119896

119905top119910 =radic1 +max (0 V

0119910Vinfin119910

) minus 1

119896

(19)

Lastly the local slope in principal space in terms of time(ie V

119910(119905)V119909(119905)) and in terms of 119909 (ie 120597119910(119909)120597119909) is as

follows

V119910 (119905)

V119909(119905)

=V0119910minus 119896119905 (2 + 119896119905) Vinfin

V0119909

120597119910 (119909)

120597119909=V0119910+ Vinfin

V0119909

minusV0119909Vinfin

(119896119909 minus V0119909)2

(20)

6 Planning in Principal Space

As the planners in this section all depend on the properties oftrajectories in principal space the most relevant propertiesare briefly repeated here Per definition any ballistic objectin principal space is launched from the origin any targethas a nonnegative 119909 component and the combined effect ofgravity and wind results in a V

infinvalue that is exactly in the

minus119910 direction As the planners will expect their parameters tobe specified in principal space the parameters of any worldspace problem need to be converted to this space beforethey can be used To recap the necessary steps (assumingthe problem involves hitting some target position 119903) start bydefining the actual principal spacersquos and axes using (10)with 119889 = 119903 minus

0 Next convert 119903 (or any other requested

position) to principal space using (11) to get [119903119909 119903119910]

All planners covered here will return the exact time 119905119903

at which the target [119903119909 119903119910] must be hit to meet the plannerrsquos

given constraints To get the actual initial velocity in principalspace that leads to hitting [119903

119909 119903119910] at this 119905

119903 both 119901

119909(119905119903) = 119903119909

Figure 9 The same Empire State Building trajectory example asfrom Figure 1 but seen from the principal frame of reference

and 119901119910(119905119903) = 119903119910need to be solved for [V

0119909 V0119910] which can be

done using the following two formulas

V0119909= 119903119909(119896 +

1

119905119903

) (21)

V0119910= 119903119910(119896 +

1

119905119903

) + 119896Vinfin119905119903 (22)

To get the initial velocity in world space from these it ispossible to convert [V

0119909 V0119910] to V0using (14) But V

0may also

be directly calculated from 119905119903and 119903 through (8) Now that it is

clear how to make use of principal space planners in generalthe actual planners are presented

61 Hitting the Target Given Another Position to PassThroughA trajectory can be planned to pass through both position[119902119909 119902119910] and through target [119903

119909 119903119910] by solving 119910(119902

119909) = 119902

119910

and 119910(119903119909) = 119903

119910for V0119909 and using (17) on 119903

119909and V

0119909to

get 119905119903 This specific form of planning may be useful to shoot

through a hole or exactly over an object at [119902119909 119902119910] to hit

[119903119909 119903119910] example The solution to at what time the position

[119903119909 119903119910] needs to be hit is as follows

119905119903= 119904 + radic119904(119904 +

2119903119909

119896 (119903119909minus 119902119909)) (23)

where 119904 = (119903119909119902119910minus 119903119910119902119909)2Vinfin119902119909 Note that the line from the

origin to the target position with the smallest 119909 must be atleast as steep as the line from the origin to the position with

10 International Journal of Computer Games Technology

Figure 10 Planning trajectories through 119876 and six different 119877targets

the largest 119909 for a valid trajectory (and thus a real solution) toexist That is 119902

119910119902119909ge 119903119910119903119909if 119902119909lt 119903119909 and 119903

119910119903119909ge 119902119910119902119909if

119902119909gt 119903119909 In Figure 10 two of the six targets do not meet this

requirement explaining why there are only four trajectoriesthere

62 Hitting the Target While Touching a Line When lookingfor the time 119905

119903atwhich a trajectory passes through [119903

119909 119903119910] and

touches the line 119910 = 119886119909 + 119887 in principal space 120597119910(119909)120597119909 = 119886has to be solved for 119909 first which can then be used to solve119910(119909) = 119886119909+119887 for V

0119909 Both V

0119909and 119903119909can then be used again

with (17) to get 119905119903 The solution may be written as follows

119905119903=119904 + radic1199042 + 119896V

infin(119886119903119909minus 119903119910)

119896Vinfin

(24)

where 119904 = radic119887119896Vinfin+ (12)119896(119886119903

119909minus 119903119910+ 119887) Note that a real

solution can only exist when 119887 ge 0 and 119886119903119909+ 119887 ge 119903

119910 That is

the line must always pass through or be above the initial andthe target position

In the example presented in Figure 11 the line to betouched is chosen to be horizontal leading to a specificationof the trajectoriesrsquo vertical tops in principal space But it isalso possible to find the 119905

119903that leads to hitting a top defined

in another space For example to let a trajectoryrsquos top touchtheworld-space planewith normal 119899 and throughpoint 119902119910 =119886119909 + 119887 becomes the line in principal space that describes theintersection between this plane and the trajectoryrsquos principalplane In that case 119886 = minus( sdot 119899)( sdot 119899) and 119887 = (( 119902 minus

0) sdot

119899)( sdot 119899) As always when 119899 is axis-aligned the dot productscan be optimized away For example when only interestedin trajectories exactly hitting a world space height ℎ at theirtops (in the +119910 direction) this simplifies to 119886 = minus

119910119910and

119887 = (ℎ minus 0119910)119910

The principal space slope 119886 can also be calculated fromthe slope 119908 of a world-space elevation angle 120579world (ie

Figure 11 Planning trajectories through six different targets touch-ing a line at each top

119908 = tan(120579world)) by using the conversion formula 119886 =

(sign(119910)119908radic119904(2

119910+ 2119910) minus 1199082 minus 119904

119910119910)(1199042

119910minus 1199082) where

119904 = 1 + 1199082 and sign(119909) = [119909 ge 0] minus [119909 lt 0] This 119886 is only

valid if an equivalent elevationwith a positive119909 component inprincipal space exists which is the case if 119904(2

119910+2

119910)minus1199082ge 0

and [1 119908] sdot [radic1 minus 2119910 119910] gt 0 This world-space elevation

conversion may be particularly useful when used togetherwith the next two principal-space planners

63 Hitting the Target Given the Initial Slope This subsectionis about finding the time 119905

119903at which a projectile will hit

position [119903119909 119903119910]while being launched at slope 119886 Planning this

way may be useful when there is control over the projectilersquosinitial speed but not over its direction (eg for some weaponmounted on a fixed rig)

This problem is actually simply a special case of theprevious planner where 119887 = 0 meaning that the problemis equivalent to finding the trajectory that touches the line119910 = 119886119909 After substituting 119887 in (24) and applying somebasic algebra the solution may be written more compactly asfollows

119905119903=119904 + radic119904 (119904 + 2V

infin)

119896Vinfin

(25)

where 119904 = (12)119896(119886119903119909minus 119903119910) Obviously the slope 119886 has to be

steeper than the line from the origin to the target position(ie 119886 gt 119903

119910119903119909) for a solution to exist which is the case for all

but one target position in Figure 12

64 Hitting the Target Given the Target Slope Similarly it ispossible to hit [119903

119909 119903119910] given the exact slope 119886 at the target

position This type of planning allows for exact control overthe angle at which a target is hit Again this can be seen as a

International Journal of Computer Games Technology 11

special case of the planner from Section 62 using 119903119910minus 119886119903119909as

the value for 119887 When substituted and simplified this resultsin the following more direct formula

119905119903= radic

119903119910minus 119886119903119909

119896Vinfin

(26)

For this particular planner the slope 119886 needs to be lessthan the slope of the line from the origin to the target position(ie 119886 lt 119903

119910119903119909) Consequently only five of the six targets have

a valid trajectory in Figure 13

65 Hitting the Target Given the Arc Height or ldquoCurvinessrdquoThe time 119905

119903can also be calculated for a target position [119903

119909 119903119910]

and an ldquoarc heightrdquo 119887 Here 119887 is defined as the maximumdifference in the 119910 direction between the trajectory and thestraight line from origin to target Equivalently 119887 may beinterpreted as the height in principal space of the smallestparallelogram containing the whole trajectory as shown inFigure 14 This problem is another special case of the ldquolinetouchingrdquo problem and can be solved by substituting 119903

119910119903119909

for 119886 in (24) After applying some basic algebra the resultingformula may be written as follows

119905119903=

119887

Vinfin

+ 2radic119887

119896Vinfin

(27)

This function is particularly intuitive to plan with when

119887 = ℎradic1199032119909+ 1199032119910 (28)

where ℎ defines the ldquocurvinessrdquo of the trajectory For exampleℎ = 001 always leads to a low arc for any target positionwhileℎ = 05 always leads to a fairly high arc

66 Hitting the Target with (Almost)Minimal Effort A trajec-tory can also be planned to hit a target at [119903

119909 119903119910] with the

smallest initial speed (and thus the least amount of energy)possible Planning a trajectory this way requires finding thepositive time-to-target 119905

119903which solves 120597(V2

0119909+ V20119910)120597119905119903= 0

where V0119909

and V0119910

are defined by (21) and (22) respectivelyThis equation can be expanded into the following form

(1198962V2infin) 1199054

119903+ (1198962Vinfin119903119910) 1199053

119903minus 119896 (119903

2

119909+ 1199032

119910) 119905119903minus (1199032

119909+ 1199032

119910) = 0

(29)

Like all quartic equations solving this in a closed form ispossible but difficult to do robustly [10] In practice quarticequations are typically solved for any or all of their roots bygeneric iterative root solvers [11] But by exploiting domain-specific knowledge it is also possible to implement a special-ized iterative solver for (29) that is guaranteed to efficientlyconverge to the right root directly One possible implemen-tation is presented as a C++ function called GetTimeTo-TargetRWithMinimalInitialSpeed() in Algorithm 1 There theequation is first transformed into an equivalent but morewell-behaved strictly convex quartic function for which aconservative initial guess for 119905 (or rather 119906) is calculated

Figure 12 Planning trajectories through six different targets allstarting with the slope 34

Figure 13 Planning trajectories through six different targets allending at the slope minus34

which is then refined using multiple (but typically less thana total of six) modified or normal conservative Newtonrsquosmethod iterations This implementation has been carefullycrafted with both robustness and efficiency in mind As withany implementation numeric precision can become an issuewhen using extreme values but results for practical ranges aretypically within a few float epsilons of the exact value See thecomments in the implementation itself for more details

Alternatively when only a rough approximation of theminimal effort solution is needed the simpler ldquocurvinessrdquoplanner from (27) and (28) could be used with ℎ = 14 Thisapproximation is fairly accurate for larger values of V

infin as it

actually converges perfectly to the exact solution when Vinfin

goes to infinity But for high friction scenarios the difference

12 International Journal of Computer Games Technology

Figure 14 Planning trajectories through six different 119877s all with anarc height of 50

Figure 15 Planning trajectories through six different 119877s whileminimizing the initial velocity using the exact method (in black)and the approximate ℎ = 14 method (in red) in a medium-fictionscenario

between the exact method and the approximation becomesquite noticeable To get an idea of the size of the error for amedium friction scenario the trajectories resulting from theexact method and the approximation are shown side by sidein Figure 15 for the case of 119892 = 981ms2 and V

infin= 25ms

67 Hitting a Target Given the Initial Speed The last planningalgorithm covered in this paper solves for the time 119905

119903required

to hit the target [119903119909 119903119910] given the projectilersquos exact initial

speed 119904 The solution is found by solving V20119909

+ V20119910

= 1199042

for the positive time 119905119903to position [119903

119909 119903119910] where V

0119909and

V0119910

are once again defined by (21) and (22) respectively

Figure 16 Planning trajectories through six different119877s all startingat 100ms Each of the five reachable targets has a trajectory with a(red) low arc and a (black) high arc

This particular equation may be expanded into the followingquartic function

(1198962V2infin) 1199054

119903+ (21198962Vinfin119903119910) 1199053

119903+ (11989621199032

119909+ 11989621199032

119910+ 2119896Vinfin119903119910minus 1199042) 1199052

119903

+ 2119896 (1199032

119909+ 1199032

119910) 119905119903+ (1199032

119909+ 1199032

119910) = 0

(30)

Note that when 119904 is smaller than theminimal initial speedto hit [119903

119909 119903119910] (ie the sought solution of (29)) the problem

has no valid solutions But when 119904 is larger than that itwill always have exactly two valid solutions In that case thesmaller of the two 119905

119903values represents the time to hit the target

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

arc See Figure 16 for an exampleUsing a similar approach as in the previous section a spe-

cialized iterative solver can be implemented to solve this par-ticular quartic function The C++ function GetTimeToTar-getRGivenInitialSpeedS() in Algorithm 2 solves the equationfor either the high or low arc root and returns the resulting119905119903or returns 0 if no solution exists This implementation has

also beenwrittenwith robustness efficiency and accuracy fora wide range of parameters in mind Tests showed that theprocedure typically requires about six (modified) Newtonrsquosmethod iterations in total to converge to almost full floatprecision

7 Future work

As already hinted at in Section 4 planning to hit movingtargets can sometimes be done using a feedback loop betweena target position prediction formula and a planner for astatic target together converging to a solution over multipleiterations More research is necessary to explore the exact

International Journal of Computer Games Technology 13

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 thispaper can also be used for efficient exact collision detectionbetween a trajectory and an arbitrary polygonal mesh by test-ing the trajectory in principal space against the intersectionof the mesh and the principal plane This algorithm mighteven be combinedwith the planners from Sections 61 and 62to allow for efficient planning of the most optimal trajectoryabove or below a given polygonal mesh respectively Thesepossibilities have not been investigated in depth for this paperbut might be covered in future work

8 Conclusion

A novel analytic approximation of ballistic trajectories withair resistance has been presented that was designed to balancephysical accuracy and performance in a way that makes sensein the field of computer games

The approximationrsquos linearity in velocity has been used todefine a special principal frame of reference which makes itpossible to always work with these trajectories in a simplified2D space even though the original problem can be in 3Dwithwind coming from any directionThe combined result is thatthe proposed model is able to produce trajectories that arecomplex enough to be physically plausible while keeping themath simple enough to also allow for many different waysof efficient trajectory planning that otherwise might be tooimpractical for use in computer games

Conflict of Interests

The author declares that there is no conflict of interestsregarding the publication of this paper

References

[1] G M Gregorek Aerodynamic Drag of Model Rockets EstesIndustries Penrose Colo USA 1970

[2] R G Watts and R Ferrer ldquoThe lateral force on a spinningsphere aerodynamics of a curveballrdquo American Journal ofPhysics vol 55 no 1 pp 40ndash44 1987

[3] H D Curtis Orbital Mechanics for Engineering Students ch 1ndash5 Elsevier Butterworth-Heinemann BurlingtonMassUSA 1stedition 2005

[4] S T Thornton and J B Marion Classical Dynamics of Particlesand Systems BrooksCole Belmont Calif USA 2005

[5] P A Karkantzakos ldquoTime of flight and range of the motion of aprojectile in a constant gravitational field under the influenceof a retarding force proportional to the velocityrdquo Journal ofEngineering Science and Technology Review vol 2 no 1 pp 76ndash81 2009

[6] R D H Warburton J Wang and J Burgdofer ldquoAnalyticapproximations of projectile motion with quadratic air resis-tancerdquo Journal Service Science ampManagement no 3 pp 98ndash1052010

[7] P S Chudinov ldquoApproximate analytical investigation of projec-tile motion in a medium with quadratic drag forcerdquo Interna-tional Journal of Sports Science and Engineering vol 5 no 1 pp27ndash42 2011

[8] GW Parker ldquoProjectile motion with air resistance quadratic inthe speedrdquo American Journal of Physics vol 45 no 7 pp 606ndash610 1997

[9] DM BourgPhysics for GameDevelopers OrsquoReillyMedia 2002[10] D Herbison-Evans ldquoSolving quartics and cubics for graphicsrdquo

Tech Rep TR94-487 Basser Department of Computer ScienceUniversity of Sydney 1994

[11] WH Press S A TeukolskyW T Vetterling and B P FlanneryNumerical Recipes in C The Art of Scientific Computing Ch 9Cambridge University Press 2nd edition 1992

International Journal of

AerospaceEngineeringHindawi Publishing Corporationhttpwwwhindawicom Volume 2014

RoboticsJournal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Active and Passive Electronic Components

Control Scienceand Engineering

Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

International Journal of

RotatingMachinery

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporation httpwwwhindawicom

Journal ofEngineeringVolume 2014

Submit your manuscripts athttpwwwhindawicom

VLSI Design

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Shock and Vibration

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Civil EngineeringAdvances in

Acoustics and VibrationAdvances in

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Electrical and Computer Engineering

Journal of

Advances inOptoElectronics

Hindawi Publishing Corporation httpwwwhindawicom

Volume 2014

The Scientific World JournalHindawi Publishing Corporation httpwwwhindawicom Volume 2014

SensorsJournal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Modelling amp Simulation in EngineeringHindawi Publishing Corporation httpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Chemical EngineeringInternational Journal of Antennas and

Propagation

International Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Navigation and Observation

International Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

DistributedSensor Networks

International Journal of

Page 9: Research Article Analytical Ballistic Trajectories with ...downloads.hindawi.com/journals/ijcgt/2014/463489.pdf//a3 u + a4 = 0 for u where u = 1/t, but the latter is more well -behaved,

International Journal of Computer Games Technology 9

property is demonstrated in Figure 9 showing a trajectorythat is equivalent to the trajectory shown in Figure 1 butwhich is now plotted using 119910(119909) in principal space perfectlyoverlaying the original trajectory when mapped back intoworld space

For completeness the principal space counterparts of theworld space properties described by (5) (6) and (7) are givenhere as well Consider

V119909(119905) =

V0119909

(1 + 119896119905)2

V119910(119905) =

V0119910minus 119896119905 (2 + 119896119905) V

infin

(1 + 119896119905)2

119905top 119899

=radic1 +max (0 [V

0119909 V0119910] sdot [119899119909 119899119910] (Vinfin119899119910)) minus 1

119896

119905top119910 =radic1 +max (0 V

0119910Vinfin119910

) minus 1

119896

(19)

Lastly the local slope in principal space in terms of time(ie V

119910(119905)V119909(119905)) and in terms of 119909 (ie 120597119910(119909)120597119909) is as

follows

V119910 (119905)

V119909(119905)

=V0119910minus 119896119905 (2 + 119896119905) Vinfin

V0119909

120597119910 (119909)

120597119909=V0119910+ Vinfin

V0119909

minusV0119909Vinfin

(119896119909 minus V0119909)2

(20)

6 Planning in Principal Space

As the planners in this section all depend on the properties oftrajectories in principal space the most relevant propertiesare briefly repeated here Per definition any ballistic objectin principal space is launched from the origin any targethas a nonnegative 119909 component and the combined effect ofgravity and wind results in a V

infinvalue that is exactly in the

minus119910 direction As the planners will expect their parameters tobe specified in principal space the parameters of any worldspace problem need to be converted to this space beforethey can be used To recap the necessary steps (assumingthe problem involves hitting some target position 119903) start bydefining the actual principal spacersquos and axes using (10)with 119889 = 119903 minus

0 Next convert 119903 (or any other requested

position) to principal space using (11) to get [119903119909 119903119910]

All planners covered here will return the exact time 119905119903

at which the target [119903119909 119903119910] must be hit to meet the plannerrsquos

given constraints To get the actual initial velocity in principalspace that leads to hitting [119903

119909 119903119910] at this 119905

119903 both 119901

119909(119905119903) = 119903119909

Figure 9 The same Empire State Building trajectory example asfrom Figure 1 but seen from the principal frame of reference

and 119901119910(119905119903) = 119903119910need to be solved for [V

0119909 V0119910] which can be

done using the following two formulas

V0119909= 119903119909(119896 +

1

119905119903

) (21)

V0119910= 119903119910(119896 +

1

119905119903

) + 119896Vinfin119905119903 (22)

To get the initial velocity in world space from these it ispossible to convert [V

0119909 V0119910] to V0using (14) But V

0may also

be directly calculated from 119905119903and 119903 through (8) Now that it is

clear how to make use of principal space planners in generalthe actual planners are presented

61 Hitting the Target Given Another Position to PassThroughA trajectory can be planned to pass through both position[119902119909 119902119910] and through target [119903

119909 119903119910] by solving 119910(119902

119909) = 119902

119910

and 119910(119903119909) = 119903

119910for V0119909 and using (17) on 119903

119909and V

0119909to

get 119905119903 This specific form of planning may be useful to shoot

through a hole or exactly over an object at [119902119909 119902119910] to hit

[119903119909 119903119910] example The solution to at what time the position

[119903119909 119903119910] needs to be hit is as follows

119905119903= 119904 + radic119904(119904 +

2119903119909

119896 (119903119909minus 119902119909)) (23)

where 119904 = (119903119909119902119910minus 119903119910119902119909)2Vinfin119902119909 Note that the line from the

origin to the target position with the smallest 119909 must be atleast as steep as the line from the origin to the position with

10 International Journal of Computer Games Technology

Figure 10 Planning trajectories through 119876 and six different 119877targets

the largest 119909 for a valid trajectory (and thus a real solution) toexist That is 119902

119910119902119909ge 119903119910119903119909if 119902119909lt 119903119909 and 119903

119910119903119909ge 119902119910119902119909if

119902119909gt 119903119909 In Figure 10 two of the six targets do not meet this

requirement explaining why there are only four trajectoriesthere

62 Hitting the Target While Touching a Line When lookingfor the time 119905

119903atwhich a trajectory passes through [119903

119909 119903119910] and

touches the line 119910 = 119886119909 + 119887 in principal space 120597119910(119909)120597119909 = 119886has to be solved for 119909 first which can then be used to solve119910(119909) = 119886119909+119887 for V

0119909 Both V

0119909and 119903119909can then be used again

with (17) to get 119905119903 The solution may be written as follows

119905119903=119904 + radic1199042 + 119896V

infin(119886119903119909minus 119903119910)

119896Vinfin

(24)

where 119904 = radic119887119896Vinfin+ (12)119896(119886119903

119909minus 119903119910+ 119887) Note that a real

solution can only exist when 119887 ge 0 and 119886119903119909+ 119887 ge 119903

119910 That is

the line must always pass through or be above the initial andthe target position

In the example presented in Figure 11 the line to betouched is chosen to be horizontal leading to a specificationof the trajectoriesrsquo vertical tops in principal space But it isalso possible to find the 119905

119903that leads to hitting a top defined

in another space For example to let a trajectoryrsquos top touchtheworld-space planewith normal 119899 and throughpoint 119902119910 =119886119909 + 119887 becomes the line in principal space that describes theintersection between this plane and the trajectoryrsquos principalplane In that case 119886 = minus( sdot 119899)( sdot 119899) and 119887 = (( 119902 minus

0) sdot

119899)( sdot 119899) As always when 119899 is axis-aligned the dot productscan be optimized away For example when only interestedin trajectories exactly hitting a world space height ℎ at theirtops (in the +119910 direction) this simplifies to 119886 = minus

119910119910and

119887 = (ℎ minus 0119910)119910

The principal space slope 119886 can also be calculated fromthe slope 119908 of a world-space elevation angle 120579world (ie

Figure 11 Planning trajectories through six different targets touch-ing a line at each top

119908 = tan(120579world)) by using the conversion formula 119886 =

(sign(119910)119908radic119904(2

119910+ 2119910) minus 1199082 minus 119904

119910119910)(1199042

119910minus 1199082) where

119904 = 1 + 1199082 and sign(119909) = [119909 ge 0] minus [119909 lt 0] This 119886 is only

valid if an equivalent elevationwith a positive119909 component inprincipal space exists which is the case if 119904(2

119910+2

119910)minus1199082ge 0

and [1 119908] sdot [radic1 minus 2119910 119910] gt 0 This world-space elevation

conversion may be particularly useful when used togetherwith the next two principal-space planners

63 Hitting the Target Given the Initial Slope This subsectionis about finding the time 119905

119903at which a projectile will hit

position [119903119909 119903119910]while being launched at slope 119886 Planning this

way may be useful when there is control over the projectilersquosinitial speed but not over its direction (eg for some weaponmounted on a fixed rig)

This problem is actually simply a special case of theprevious planner where 119887 = 0 meaning that the problemis equivalent to finding the trajectory that touches the line119910 = 119886119909 After substituting 119887 in (24) and applying somebasic algebra the solution may be written more compactly asfollows

119905119903=119904 + radic119904 (119904 + 2V

infin)

119896Vinfin

(25)

where 119904 = (12)119896(119886119903119909minus 119903119910) Obviously the slope 119886 has to be

steeper than the line from the origin to the target position(ie 119886 gt 119903

119910119903119909) for a solution to exist which is the case for all

but one target position in Figure 12

64 Hitting the Target Given the Target Slope Similarly it ispossible to hit [119903

119909 119903119910] given the exact slope 119886 at the target

position This type of planning allows for exact control overthe angle at which a target is hit Again this can be seen as a

International Journal of Computer Games Technology 11

special case of the planner from Section 62 using 119903119910minus 119886119903119909as

the value for 119887 When substituted and simplified this resultsin the following more direct formula

119905119903= radic

119903119910minus 119886119903119909

119896Vinfin

(26)

For this particular planner the slope 119886 needs to be lessthan the slope of the line from the origin to the target position(ie 119886 lt 119903

119910119903119909) Consequently only five of the six targets have

a valid trajectory in Figure 13

65 Hitting the Target Given the Arc Height or ldquoCurvinessrdquoThe time 119905

119903can also be calculated for a target position [119903

119909 119903119910]

and an ldquoarc heightrdquo 119887 Here 119887 is defined as the maximumdifference in the 119910 direction between the trajectory and thestraight line from origin to target Equivalently 119887 may beinterpreted as the height in principal space of the smallestparallelogram containing the whole trajectory as shown inFigure 14 This problem is another special case of the ldquolinetouchingrdquo problem and can be solved by substituting 119903

119910119903119909

for 119886 in (24) After applying some basic algebra the resultingformula may be written as follows

119905119903=

119887

Vinfin

+ 2radic119887

119896Vinfin

(27)

This function is particularly intuitive to plan with when

119887 = ℎradic1199032119909+ 1199032119910 (28)

where ℎ defines the ldquocurvinessrdquo of the trajectory For exampleℎ = 001 always leads to a low arc for any target positionwhileℎ = 05 always leads to a fairly high arc

66 Hitting the Target with (Almost)Minimal Effort A trajec-tory can also be planned to hit a target at [119903

119909 119903119910] with the

smallest initial speed (and thus the least amount of energy)possible Planning a trajectory this way requires finding thepositive time-to-target 119905

119903which solves 120597(V2

0119909+ V20119910)120597119905119903= 0

where V0119909

and V0119910

are defined by (21) and (22) respectivelyThis equation can be expanded into the following form

(1198962V2infin) 1199054

119903+ (1198962Vinfin119903119910) 1199053

119903minus 119896 (119903

2

119909+ 1199032

119910) 119905119903minus (1199032

119909+ 1199032

119910) = 0

(29)

Like all quartic equations solving this in a closed form ispossible but difficult to do robustly [10] In practice quarticequations are typically solved for any or all of their roots bygeneric iterative root solvers [11] But by exploiting domain-specific knowledge it is also possible to implement a special-ized iterative solver for (29) that is guaranteed to efficientlyconverge to the right root directly One possible implemen-tation is presented as a C++ function called GetTimeTo-TargetRWithMinimalInitialSpeed() in Algorithm 1 There theequation is first transformed into an equivalent but morewell-behaved strictly convex quartic function for which aconservative initial guess for 119905 (or rather 119906) is calculated

Figure 12 Planning trajectories through six different targets allstarting with the slope 34

Figure 13 Planning trajectories through six different targets allending at the slope minus34

which is then refined using multiple (but typically less thana total of six) modified or normal conservative Newtonrsquosmethod iterations This implementation has been carefullycrafted with both robustness and efficiency in mind As withany implementation numeric precision can become an issuewhen using extreme values but results for practical ranges aretypically within a few float epsilons of the exact value See thecomments in the implementation itself for more details

Alternatively when only a rough approximation of theminimal effort solution is needed the simpler ldquocurvinessrdquoplanner from (27) and (28) could be used with ℎ = 14 Thisapproximation is fairly accurate for larger values of V

infin as it

actually converges perfectly to the exact solution when Vinfin

goes to infinity But for high friction scenarios the difference

12 International Journal of Computer Games Technology

Figure 14 Planning trajectories through six different 119877s all with anarc height of 50

Figure 15 Planning trajectories through six different 119877s whileminimizing the initial velocity using the exact method (in black)and the approximate ℎ = 14 method (in red) in a medium-fictionscenario

between the exact method and the approximation becomesquite noticeable To get an idea of the size of the error for amedium friction scenario the trajectories resulting from theexact method and the approximation are shown side by sidein Figure 15 for the case of 119892 = 981ms2 and V

infin= 25ms

67 Hitting a Target Given the Initial Speed The last planningalgorithm covered in this paper solves for the time 119905

119903required

to hit the target [119903119909 119903119910] given the projectilersquos exact initial

speed 119904 The solution is found by solving V20119909

+ V20119910

= 1199042

for the positive time 119905119903to position [119903

119909 119903119910] where V

0119909and

V0119910

are once again defined by (21) and (22) respectively

Figure 16 Planning trajectories through six different119877s all startingat 100ms Each of the five reachable targets has a trajectory with a(red) low arc and a (black) high arc

This particular equation may be expanded into the followingquartic function

(1198962V2infin) 1199054

119903+ (21198962Vinfin119903119910) 1199053

119903+ (11989621199032

119909+ 11989621199032

119910+ 2119896Vinfin119903119910minus 1199042) 1199052

119903

+ 2119896 (1199032

119909+ 1199032

119910) 119905119903+ (1199032

119909+ 1199032

119910) = 0

(30)

Note that when 119904 is smaller than theminimal initial speedto hit [119903

119909 119903119910] (ie the sought solution of (29)) the problem

has no valid solutions But when 119904 is larger than that itwill always have exactly two valid solutions In that case thesmaller of the two 119905

119903values represents the time to hit the target

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

arc See Figure 16 for an exampleUsing a similar approach as in the previous section a spe-

cialized iterative solver can be implemented to solve this par-ticular quartic function The C++ function GetTimeToTar-getRGivenInitialSpeedS() in Algorithm 2 solves the equationfor either the high or low arc root and returns the resulting119905119903or returns 0 if no solution exists This implementation has

also beenwrittenwith robustness efficiency and accuracy fora wide range of parameters in mind Tests showed that theprocedure typically requires about six (modified) Newtonrsquosmethod iterations in total to converge to almost full floatprecision

7 Future work

As already hinted at in Section 4 planning to hit movingtargets can sometimes be done using a feedback loop betweena target position prediction formula and a planner for astatic target together converging to a solution over multipleiterations More research is necessary to explore the exact

International Journal of Computer Games Technology 13

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 thispaper can also be used for efficient exact collision detectionbetween a trajectory and an arbitrary polygonal mesh by test-ing the trajectory in principal space against the intersectionof the mesh and the principal plane This algorithm mighteven be combinedwith the planners from Sections 61 and 62to allow for efficient planning of the most optimal trajectoryabove or below a given polygonal mesh respectively Thesepossibilities have not been investigated in depth for this paperbut might be covered in future work

8 Conclusion

A novel analytic approximation of ballistic trajectories withair resistance has been presented that was designed to balancephysical accuracy and performance in a way that makes sensein the field of computer games

The approximationrsquos linearity in velocity has been used todefine a special principal frame of reference which makes itpossible to always work with these trajectories in a simplified2D space even though the original problem can be in 3Dwithwind coming from any directionThe combined result is thatthe proposed model is able to produce trajectories that arecomplex enough to be physically plausible while keeping themath simple enough to also allow for many different waysof efficient trajectory planning that otherwise might be tooimpractical for use in computer games

Conflict of Interests

The author declares that there is no conflict of interestsregarding the publication of this paper

References

[1] G M Gregorek Aerodynamic Drag of Model Rockets EstesIndustries Penrose Colo USA 1970

[2] R G Watts and R Ferrer ldquoThe lateral force on a spinningsphere aerodynamics of a curveballrdquo American Journal ofPhysics vol 55 no 1 pp 40ndash44 1987

[3] H D Curtis Orbital Mechanics for Engineering Students ch 1ndash5 Elsevier Butterworth-Heinemann BurlingtonMassUSA 1stedition 2005

[4] S T Thornton and J B Marion Classical Dynamics of Particlesand Systems BrooksCole Belmont Calif USA 2005

[5] P A Karkantzakos ldquoTime of flight and range of the motion of aprojectile in a constant gravitational field under the influenceof a retarding force proportional to the velocityrdquo Journal ofEngineering Science and Technology Review vol 2 no 1 pp 76ndash81 2009

[6] R D H Warburton J Wang and J Burgdofer ldquoAnalyticapproximations of projectile motion with quadratic air resis-tancerdquo Journal Service Science ampManagement no 3 pp 98ndash1052010

[7] P S Chudinov ldquoApproximate analytical investigation of projec-tile motion in a medium with quadratic drag forcerdquo Interna-tional Journal of Sports Science and Engineering vol 5 no 1 pp27ndash42 2011

[8] GW Parker ldquoProjectile motion with air resistance quadratic inthe speedrdquo American Journal of Physics vol 45 no 7 pp 606ndash610 1997

[9] DM BourgPhysics for GameDevelopers OrsquoReillyMedia 2002[10] D Herbison-Evans ldquoSolving quartics and cubics for graphicsrdquo

Tech Rep TR94-487 Basser Department of Computer ScienceUniversity of Sydney 1994

[11] WH Press S A TeukolskyW T Vetterling and B P FlanneryNumerical Recipes in C The Art of Scientific Computing Ch 9Cambridge University Press 2nd edition 1992

International Journal of

AerospaceEngineeringHindawi Publishing Corporationhttpwwwhindawicom Volume 2014

RoboticsJournal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Active and Passive Electronic Components

Control Scienceand Engineering

Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

International Journal of

RotatingMachinery

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporation httpwwwhindawicom

Journal ofEngineeringVolume 2014

Submit your manuscripts athttpwwwhindawicom

VLSI Design

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Shock and Vibration

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Civil EngineeringAdvances in

Acoustics and VibrationAdvances in

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Electrical and Computer Engineering

Journal of

Advances inOptoElectronics

Hindawi Publishing Corporation httpwwwhindawicom

Volume 2014

The Scientific World JournalHindawi Publishing Corporation httpwwwhindawicom Volume 2014

SensorsJournal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Modelling amp Simulation in EngineeringHindawi Publishing Corporation httpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Chemical EngineeringInternational Journal of Antennas and

Propagation

International Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Navigation and Observation

International Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

DistributedSensor Networks

International Journal of

Page 10: Research Article Analytical Ballistic Trajectories with ...downloads.hindawi.com/journals/ijcgt/2014/463489.pdf//a3 u + a4 = 0 for u where u = 1/t, but the latter is more well -behaved,

10 International Journal of Computer Games Technology

Figure 10 Planning trajectories through 119876 and six different 119877targets

the largest 119909 for a valid trajectory (and thus a real solution) toexist That is 119902

119910119902119909ge 119903119910119903119909if 119902119909lt 119903119909 and 119903

119910119903119909ge 119902119910119902119909if

119902119909gt 119903119909 In Figure 10 two of the six targets do not meet this

requirement explaining why there are only four trajectoriesthere

62 Hitting the Target While Touching a Line When lookingfor the time 119905

119903atwhich a trajectory passes through [119903

119909 119903119910] and

touches the line 119910 = 119886119909 + 119887 in principal space 120597119910(119909)120597119909 = 119886has to be solved for 119909 first which can then be used to solve119910(119909) = 119886119909+119887 for V

0119909 Both V

0119909and 119903119909can then be used again

with (17) to get 119905119903 The solution may be written as follows

119905119903=119904 + radic1199042 + 119896V

infin(119886119903119909minus 119903119910)

119896Vinfin

(24)

where 119904 = radic119887119896Vinfin+ (12)119896(119886119903

119909minus 119903119910+ 119887) Note that a real

solution can only exist when 119887 ge 0 and 119886119903119909+ 119887 ge 119903

119910 That is

the line must always pass through or be above the initial andthe target position

In the example presented in Figure 11 the line to betouched is chosen to be horizontal leading to a specificationof the trajectoriesrsquo vertical tops in principal space But it isalso possible to find the 119905

119903that leads to hitting a top defined

in another space For example to let a trajectoryrsquos top touchtheworld-space planewith normal 119899 and throughpoint 119902119910 =119886119909 + 119887 becomes the line in principal space that describes theintersection between this plane and the trajectoryrsquos principalplane In that case 119886 = minus( sdot 119899)( sdot 119899) and 119887 = (( 119902 minus

0) sdot

119899)( sdot 119899) As always when 119899 is axis-aligned the dot productscan be optimized away For example when only interestedin trajectories exactly hitting a world space height ℎ at theirtops (in the +119910 direction) this simplifies to 119886 = minus

119910119910and

119887 = (ℎ minus 0119910)119910

The principal space slope 119886 can also be calculated fromthe slope 119908 of a world-space elevation angle 120579world (ie

Figure 11 Planning trajectories through six different targets touch-ing a line at each top

119908 = tan(120579world)) by using the conversion formula 119886 =

(sign(119910)119908radic119904(2

119910+ 2119910) minus 1199082 minus 119904

119910119910)(1199042

119910minus 1199082) where

119904 = 1 + 1199082 and sign(119909) = [119909 ge 0] minus [119909 lt 0] This 119886 is only

valid if an equivalent elevationwith a positive119909 component inprincipal space exists which is the case if 119904(2

119910+2

119910)minus1199082ge 0

and [1 119908] sdot [radic1 minus 2119910 119910] gt 0 This world-space elevation

conversion may be particularly useful when used togetherwith the next two principal-space planners

63 Hitting the Target Given the Initial Slope This subsectionis about finding the time 119905

119903at which a projectile will hit

position [119903119909 119903119910]while being launched at slope 119886 Planning this

way may be useful when there is control over the projectilersquosinitial speed but not over its direction (eg for some weaponmounted on a fixed rig)

This problem is actually simply a special case of theprevious planner where 119887 = 0 meaning that the problemis equivalent to finding the trajectory that touches the line119910 = 119886119909 After substituting 119887 in (24) and applying somebasic algebra the solution may be written more compactly asfollows

119905119903=119904 + radic119904 (119904 + 2V

infin)

119896Vinfin

(25)

where 119904 = (12)119896(119886119903119909minus 119903119910) Obviously the slope 119886 has to be

steeper than the line from the origin to the target position(ie 119886 gt 119903

119910119903119909) for a solution to exist which is the case for all

but one target position in Figure 12

64 Hitting the Target Given the Target Slope Similarly it ispossible to hit [119903

119909 119903119910] given the exact slope 119886 at the target

position This type of planning allows for exact control overthe angle at which a target is hit Again this can be seen as a

International Journal of Computer Games Technology 11

special case of the planner from Section 62 using 119903119910minus 119886119903119909as

the value for 119887 When substituted and simplified this resultsin the following more direct formula

119905119903= radic

119903119910minus 119886119903119909

119896Vinfin

(26)

For this particular planner the slope 119886 needs to be lessthan the slope of the line from the origin to the target position(ie 119886 lt 119903

119910119903119909) Consequently only five of the six targets have

a valid trajectory in Figure 13

65 Hitting the Target Given the Arc Height or ldquoCurvinessrdquoThe time 119905

119903can also be calculated for a target position [119903

119909 119903119910]

and an ldquoarc heightrdquo 119887 Here 119887 is defined as the maximumdifference in the 119910 direction between the trajectory and thestraight line from origin to target Equivalently 119887 may beinterpreted as the height in principal space of the smallestparallelogram containing the whole trajectory as shown inFigure 14 This problem is another special case of the ldquolinetouchingrdquo problem and can be solved by substituting 119903

119910119903119909

for 119886 in (24) After applying some basic algebra the resultingformula may be written as follows

119905119903=

119887

Vinfin

+ 2radic119887

119896Vinfin

(27)

This function is particularly intuitive to plan with when

119887 = ℎradic1199032119909+ 1199032119910 (28)

where ℎ defines the ldquocurvinessrdquo of the trajectory For exampleℎ = 001 always leads to a low arc for any target positionwhileℎ = 05 always leads to a fairly high arc

66 Hitting the Target with (Almost)Minimal Effort A trajec-tory can also be planned to hit a target at [119903

119909 119903119910] with the

smallest initial speed (and thus the least amount of energy)possible Planning a trajectory this way requires finding thepositive time-to-target 119905

119903which solves 120597(V2

0119909+ V20119910)120597119905119903= 0

where V0119909

and V0119910

are defined by (21) and (22) respectivelyThis equation can be expanded into the following form

(1198962V2infin) 1199054

119903+ (1198962Vinfin119903119910) 1199053

119903minus 119896 (119903

2

119909+ 1199032

119910) 119905119903minus (1199032

119909+ 1199032

119910) = 0

(29)

Like all quartic equations solving this in a closed form ispossible but difficult to do robustly [10] In practice quarticequations are typically solved for any or all of their roots bygeneric iterative root solvers [11] But by exploiting domain-specific knowledge it is also possible to implement a special-ized iterative solver for (29) that is guaranteed to efficientlyconverge to the right root directly One possible implemen-tation is presented as a C++ function called GetTimeTo-TargetRWithMinimalInitialSpeed() in Algorithm 1 There theequation is first transformed into an equivalent but morewell-behaved strictly convex quartic function for which aconservative initial guess for 119905 (or rather 119906) is calculated

Figure 12 Planning trajectories through six different targets allstarting with the slope 34

Figure 13 Planning trajectories through six different targets allending at the slope minus34

which is then refined using multiple (but typically less thana total of six) modified or normal conservative Newtonrsquosmethod iterations This implementation has been carefullycrafted with both robustness and efficiency in mind As withany implementation numeric precision can become an issuewhen using extreme values but results for practical ranges aretypically within a few float epsilons of the exact value See thecomments in the implementation itself for more details

Alternatively when only a rough approximation of theminimal effort solution is needed the simpler ldquocurvinessrdquoplanner from (27) and (28) could be used with ℎ = 14 Thisapproximation is fairly accurate for larger values of V

infin as it

actually converges perfectly to the exact solution when Vinfin

goes to infinity But for high friction scenarios the difference

12 International Journal of Computer Games Technology

Figure 14 Planning trajectories through six different 119877s all with anarc height of 50

Figure 15 Planning trajectories through six different 119877s whileminimizing the initial velocity using the exact method (in black)and the approximate ℎ = 14 method (in red) in a medium-fictionscenario

between the exact method and the approximation becomesquite noticeable To get an idea of the size of the error for amedium friction scenario the trajectories resulting from theexact method and the approximation are shown side by sidein Figure 15 for the case of 119892 = 981ms2 and V

infin= 25ms

67 Hitting a Target Given the Initial Speed The last planningalgorithm covered in this paper solves for the time 119905

119903required

to hit the target [119903119909 119903119910] given the projectilersquos exact initial

speed 119904 The solution is found by solving V20119909

+ V20119910

= 1199042

for the positive time 119905119903to position [119903

119909 119903119910] where V

0119909and

V0119910

are once again defined by (21) and (22) respectively

Figure 16 Planning trajectories through six different119877s all startingat 100ms Each of the five reachable targets has a trajectory with a(red) low arc and a (black) high arc

This particular equation may be expanded into the followingquartic function

(1198962V2infin) 1199054

119903+ (21198962Vinfin119903119910) 1199053

119903+ (11989621199032

119909+ 11989621199032

119910+ 2119896Vinfin119903119910minus 1199042) 1199052

119903

+ 2119896 (1199032

119909+ 1199032

119910) 119905119903+ (1199032

119909+ 1199032

119910) = 0

(30)

Note that when 119904 is smaller than theminimal initial speedto hit [119903

119909 119903119910] (ie the sought solution of (29)) the problem

has no valid solutions But when 119904 is larger than that itwill always have exactly two valid solutions In that case thesmaller of the two 119905

119903values represents the time to hit the target

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

arc See Figure 16 for an exampleUsing a similar approach as in the previous section a spe-

cialized iterative solver can be implemented to solve this par-ticular quartic function The C++ function GetTimeToTar-getRGivenInitialSpeedS() in Algorithm 2 solves the equationfor either the high or low arc root and returns the resulting119905119903or returns 0 if no solution exists This implementation has

also beenwrittenwith robustness efficiency and accuracy fora wide range of parameters in mind Tests showed that theprocedure typically requires about six (modified) Newtonrsquosmethod iterations in total to converge to almost full floatprecision

7 Future work

As already hinted at in Section 4 planning to hit movingtargets can sometimes be done using a feedback loop betweena target position prediction formula and a planner for astatic target together converging to a solution over multipleiterations More research is necessary to explore the exact

International Journal of Computer Games Technology 13

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 thispaper can also be used for efficient exact collision detectionbetween a trajectory and an arbitrary polygonal mesh by test-ing the trajectory in principal space against the intersectionof the mesh and the principal plane This algorithm mighteven be combinedwith the planners from Sections 61 and 62to allow for efficient planning of the most optimal trajectoryabove or below a given polygonal mesh respectively Thesepossibilities have not been investigated in depth for this paperbut might be covered in future work

8 Conclusion

A novel analytic approximation of ballistic trajectories withair resistance has been presented that was designed to balancephysical accuracy and performance in a way that makes sensein the field of computer games

The approximationrsquos linearity in velocity has been used todefine a special principal frame of reference which makes itpossible to always work with these trajectories in a simplified2D space even though the original problem can be in 3Dwithwind coming from any directionThe combined result is thatthe proposed model is able to produce trajectories that arecomplex enough to be physically plausible while keeping themath simple enough to also allow for many different waysof efficient trajectory planning that otherwise might be tooimpractical for use in computer games

Conflict of Interests

The author declares that there is no conflict of interestsregarding the publication of this paper

References

[1] G M Gregorek Aerodynamic Drag of Model Rockets EstesIndustries Penrose Colo USA 1970

[2] R G Watts and R Ferrer ldquoThe lateral force on a spinningsphere aerodynamics of a curveballrdquo American Journal ofPhysics vol 55 no 1 pp 40ndash44 1987

[3] H D Curtis Orbital Mechanics for Engineering Students ch 1ndash5 Elsevier Butterworth-Heinemann BurlingtonMassUSA 1stedition 2005

[4] S T Thornton and J B Marion Classical Dynamics of Particlesand Systems BrooksCole Belmont Calif USA 2005

[5] P A Karkantzakos ldquoTime of flight and range of the motion of aprojectile in a constant gravitational field under the influenceof a retarding force proportional to the velocityrdquo Journal ofEngineering Science and Technology Review vol 2 no 1 pp 76ndash81 2009

[6] R D H Warburton J Wang and J Burgdofer ldquoAnalyticapproximations of projectile motion with quadratic air resis-tancerdquo Journal Service Science ampManagement no 3 pp 98ndash1052010

[7] P S Chudinov ldquoApproximate analytical investigation of projec-tile motion in a medium with quadratic drag forcerdquo Interna-tional Journal of Sports Science and Engineering vol 5 no 1 pp27ndash42 2011

[8] GW Parker ldquoProjectile motion with air resistance quadratic inthe speedrdquo American Journal of Physics vol 45 no 7 pp 606ndash610 1997

[9] DM BourgPhysics for GameDevelopers OrsquoReillyMedia 2002[10] D Herbison-Evans ldquoSolving quartics and cubics for graphicsrdquo

Tech Rep TR94-487 Basser Department of Computer ScienceUniversity of Sydney 1994

[11] WH Press S A TeukolskyW T Vetterling and B P FlanneryNumerical Recipes in C The Art of Scientific Computing Ch 9Cambridge University Press 2nd edition 1992

International Journal of

AerospaceEngineeringHindawi Publishing Corporationhttpwwwhindawicom Volume 2014

RoboticsJournal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Active and Passive Electronic Components

Control Scienceand Engineering

Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

International Journal of

RotatingMachinery

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporation httpwwwhindawicom

Journal ofEngineeringVolume 2014

Submit your manuscripts athttpwwwhindawicom

VLSI Design

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Shock and Vibration

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Civil EngineeringAdvances in

Acoustics and VibrationAdvances in

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Electrical and Computer Engineering

Journal of

Advances inOptoElectronics

Hindawi Publishing Corporation httpwwwhindawicom

Volume 2014

The Scientific World JournalHindawi Publishing Corporation httpwwwhindawicom Volume 2014

SensorsJournal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Modelling amp Simulation in EngineeringHindawi Publishing Corporation httpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Chemical EngineeringInternational Journal of Antennas and

Propagation

International Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Navigation and Observation

International Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

DistributedSensor Networks

International Journal of

Page 11: Research Article Analytical Ballistic Trajectories with ...downloads.hindawi.com/journals/ijcgt/2014/463489.pdf//a3 u + a4 = 0 for u where u = 1/t, but the latter is more well -behaved,

International Journal of Computer Games Technology 11

special case of the planner from Section 62 using 119903119910minus 119886119903119909as

the value for 119887 When substituted and simplified this resultsin the following more direct formula

119905119903= radic

119903119910minus 119886119903119909

119896Vinfin

(26)

For this particular planner the slope 119886 needs to be lessthan the slope of the line from the origin to the target position(ie 119886 lt 119903

119910119903119909) Consequently only five of the six targets have

a valid trajectory in Figure 13

65 Hitting the Target Given the Arc Height or ldquoCurvinessrdquoThe time 119905

119903can also be calculated for a target position [119903

119909 119903119910]

and an ldquoarc heightrdquo 119887 Here 119887 is defined as the maximumdifference in the 119910 direction between the trajectory and thestraight line from origin to target Equivalently 119887 may beinterpreted as the height in principal space of the smallestparallelogram containing the whole trajectory as shown inFigure 14 This problem is another special case of the ldquolinetouchingrdquo problem and can be solved by substituting 119903

119910119903119909

for 119886 in (24) After applying some basic algebra the resultingformula may be written as follows

119905119903=

119887

Vinfin

+ 2radic119887

119896Vinfin

(27)

This function is particularly intuitive to plan with when

119887 = ℎradic1199032119909+ 1199032119910 (28)

where ℎ defines the ldquocurvinessrdquo of the trajectory For exampleℎ = 001 always leads to a low arc for any target positionwhileℎ = 05 always leads to a fairly high arc

66 Hitting the Target with (Almost)Minimal Effort A trajec-tory can also be planned to hit a target at [119903

119909 119903119910] with the

smallest initial speed (and thus the least amount of energy)possible Planning a trajectory this way requires finding thepositive time-to-target 119905

119903which solves 120597(V2

0119909+ V20119910)120597119905119903= 0

where V0119909

and V0119910

are defined by (21) and (22) respectivelyThis equation can be expanded into the following form

(1198962V2infin) 1199054

119903+ (1198962Vinfin119903119910) 1199053

119903minus 119896 (119903

2

119909+ 1199032

119910) 119905119903minus (1199032

119909+ 1199032

119910) = 0

(29)

Like all quartic equations solving this in a closed form ispossible but difficult to do robustly [10] In practice quarticequations are typically solved for any or all of their roots bygeneric iterative root solvers [11] But by exploiting domain-specific knowledge it is also possible to implement a special-ized iterative solver for (29) that is guaranteed to efficientlyconverge to the right root directly One possible implemen-tation is presented as a C++ function called GetTimeTo-TargetRWithMinimalInitialSpeed() in Algorithm 1 There theequation is first transformed into an equivalent but morewell-behaved strictly convex quartic function for which aconservative initial guess for 119905 (or rather 119906) is calculated

Figure 12 Planning trajectories through six different targets allstarting with the slope 34

Figure 13 Planning trajectories through six different targets allending at the slope minus34

which is then refined using multiple (but typically less thana total of six) modified or normal conservative Newtonrsquosmethod iterations This implementation has been carefullycrafted with both robustness and efficiency in mind As withany implementation numeric precision can become an issuewhen using extreme values but results for practical ranges aretypically within a few float epsilons of the exact value See thecomments in the implementation itself for more details

Alternatively when only a rough approximation of theminimal effort solution is needed the simpler ldquocurvinessrdquoplanner from (27) and (28) could be used with ℎ = 14 Thisapproximation is fairly accurate for larger values of V

infin as it

actually converges perfectly to the exact solution when Vinfin

goes to infinity But for high friction scenarios the difference

12 International Journal of Computer Games Technology

Figure 14 Planning trajectories through six different 119877s all with anarc height of 50

Figure 15 Planning trajectories through six different 119877s whileminimizing the initial velocity using the exact method (in black)and the approximate ℎ = 14 method (in red) in a medium-fictionscenario

between the exact method and the approximation becomesquite noticeable To get an idea of the size of the error for amedium friction scenario the trajectories resulting from theexact method and the approximation are shown side by sidein Figure 15 for the case of 119892 = 981ms2 and V

infin= 25ms

67 Hitting a Target Given the Initial Speed The last planningalgorithm covered in this paper solves for the time 119905

119903required

to hit the target [119903119909 119903119910] given the projectilersquos exact initial

speed 119904 The solution is found by solving V20119909

+ V20119910

= 1199042

for the positive time 119905119903to position [119903

119909 119903119910] where V

0119909and

V0119910

are once again defined by (21) and (22) respectively

Figure 16 Planning trajectories through six different119877s all startingat 100ms Each of the five reachable targets has a trajectory with a(red) low arc and a (black) high arc

This particular equation may be expanded into the followingquartic function

(1198962V2infin) 1199054

119903+ (21198962Vinfin119903119910) 1199053

119903+ (11989621199032

119909+ 11989621199032

119910+ 2119896Vinfin119903119910minus 1199042) 1199052

119903

+ 2119896 (1199032

119909+ 1199032

119910) 119905119903+ (1199032

119909+ 1199032

119910) = 0

(30)

Note that when 119904 is smaller than theminimal initial speedto hit [119903

119909 119903119910] (ie the sought solution of (29)) the problem

has no valid solutions But when 119904 is larger than that itwill always have exactly two valid solutions In that case thesmaller of the two 119905

119903values represents the time to hit the target

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

arc See Figure 16 for an exampleUsing a similar approach as in the previous section a spe-

cialized iterative solver can be implemented to solve this par-ticular quartic function The C++ function GetTimeToTar-getRGivenInitialSpeedS() in Algorithm 2 solves the equationfor either the high or low arc root and returns the resulting119905119903or returns 0 if no solution exists This implementation has

also beenwrittenwith robustness efficiency and accuracy fora wide range of parameters in mind Tests showed that theprocedure typically requires about six (modified) Newtonrsquosmethod iterations in total to converge to almost full floatprecision

7 Future work

As already hinted at in Section 4 planning to hit movingtargets can sometimes be done using a feedback loop betweena target position prediction formula and a planner for astatic target together converging to a solution over multipleiterations More research is necessary to explore the exact

International Journal of Computer Games Technology 13

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 thispaper can also be used for efficient exact collision detectionbetween a trajectory and an arbitrary polygonal mesh by test-ing the trajectory in principal space against the intersectionof the mesh and the principal plane This algorithm mighteven be combinedwith the planners from Sections 61 and 62to allow for efficient planning of the most optimal trajectoryabove or below a given polygonal mesh respectively Thesepossibilities have not been investigated in depth for this paperbut might be covered in future work

8 Conclusion

A novel analytic approximation of ballistic trajectories withair resistance has been presented that was designed to balancephysical accuracy and performance in a way that makes sensein the field of computer games

The approximationrsquos linearity in velocity has been used todefine a special principal frame of reference which makes itpossible to always work with these trajectories in a simplified2D space even though the original problem can be in 3Dwithwind coming from any directionThe combined result is thatthe proposed model is able to produce trajectories that arecomplex enough to be physically plausible while keeping themath simple enough to also allow for many different waysof efficient trajectory planning that otherwise might be tooimpractical for use in computer games

Conflict of Interests

The author declares that there is no conflict of interestsregarding the publication of this paper

References

[1] G M Gregorek Aerodynamic Drag of Model Rockets EstesIndustries Penrose Colo USA 1970

[2] R G Watts and R Ferrer ldquoThe lateral force on a spinningsphere aerodynamics of a curveballrdquo American Journal ofPhysics vol 55 no 1 pp 40ndash44 1987

[3] H D Curtis Orbital Mechanics for Engineering Students ch 1ndash5 Elsevier Butterworth-Heinemann BurlingtonMassUSA 1stedition 2005

[4] S T Thornton and J B Marion Classical Dynamics of Particlesand Systems BrooksCole Belmont Calif USA 2005

[5] P A Karkantzakos ldquoTime of flight and range of the motion of aprojectile in a constant gravitational field under the influenceof a retarding force proportional to the velocityrdquo Journal ofEngineering Science and Technology Review vol 2 no 1 pp 76ndash81 2009

[6] R D H Warburton J Wang and J Burgdofer ldquoAnalyticapproximations of projectile motion with quadratic air resis-tancerdquo Journal Service Science ampManagement no 3 pp 98ndash1052010

[7] P S Chudinov ldquoApproximate analytical investigation of projec-tile motion in a medium with quadratic drag forcerdquo Interna-tional Journal of Sports Science and Engineering vol 5 no 1 pp27ndash42 2011

[8] GW Parker ldquoProjectile motion with air resistance quadratic inthe speedrdquo American Journal of Physics vol 45 no 7 pp 606ndash610 1997

[9] DM BourgPhysics for GameDevelopers OrsquoReillyMedia 2002[10] D Herbison-Evans ldquoSolving quartics and cubics for graphicsrdquo

Tech Rep TR94-487 Basser Department of Computer ScienceUniversity of Sydney 1994

[11] WH Press S A TeukolskyW T Vetterling and B P FlanneryNumerical Recipes in C The Art of Scientific Computing Ch 9Cambridge University Press 2nd edition 1992

International Journal of

AerospaceEngineeringHindawi Publishing Corporationhttpwwwhindawicom Volume 2014

RoboticsJournal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Active and Passive Electronic Components

Control Scienceand Engineering

Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

International Journal of

RotatingMachinery

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporation httpwwwhindawicom

Journal ofEngineeringVolume 2014

Submit your manuscripts athttpwwwhindawicom

VLSI Design

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Shock and Vibration

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Civil EngineeringAdvances in

Acoustics and VibrationAdvances in

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Electrical and Computer Engineering

Journal of

Advances inOptoElectronics

Hindawi Publishing Corporation httpwwwhindawicom

Volume 2014

The Scientific World JournalHindawi Publishing Corporation httpwwwhindawicom Volume 2014

SensorsJournal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Modelling amp Simulation in EngineeringHindawi Publishing Corporation httpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Chemical EngineeringInternational Journal of Antennas and

Propagation

International Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Navigation and Observation

International Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

DistributedSensor Networks

International Journal of

Page 12: Research Article Analytical Ballistic Trajectories with ...downloads.hindawi.com/journals/ijcgt/2014/463489.pdf//a3 u + a4 = 0 for u where u = 1/t, but the latter is more well -behaved,

12 International Journal of Computer Games Technology

Figure 14 Planning trajectories through six different 119877s all with anarc height of 50

Figure 15 Planning trajectories through six different 119877s whileminimizing the initial velocity using the exact method (in black)and the approximate ℎ = 14 method (in red) in a medium-fictionscenario

between the exact method and the approximation becomesquite noticeable To get an idea of the size of the error for amedium friction scenario the trajectories resulting from theexact method and the approximation are shown side by sidein Figure 15 for the case of 119892 = 981ms2 and V

infin= 25ms

67 Hitting a Target Given the Initial Speed The last planningalgorithm covered in this paper solves for the time 119905

119903required

to hit the target [119903119909 119903119910] given the projectilersquos exact initial

speed 119904 The solution is found by solving V20119909

+ V20119910

= 1199042

for the positive time 119905119903to position [119903

119909 119903119910] where V

0119909and

V0119910

are once again defined by (21) and (22) respectively

Figure 16 Planning trajectories through six different119877s all startingat 100ms Each of the five reachable targets has a trajectory with a(red) low arc and a (black) high arc

This particular equation may be expanded into the followingquartic function

(1198962V2infin) 1199054

119903+ (21198962Vinfin119903119910) 1199053

119903+ (11989621199032

119909+ 11989621199032

119910+ 2119896Vinfin119903119910minus 1199042) 1199052

119903

+ 2119896 (1199032

119909+ 1199032

119910) 119905119903+ (1199032

119909+ 1199032

119910) = 0

(30)

Note that when 119904 is smaller than theminimal initial speedto hit [119903

119909 119903119910] (ie the sought solution of (29)) the problem

has no valid solutions But when 119904 is larger than that itwill always have exactly two valid solutions In that case thesmaller of the two 119905

119903values represents the time to hit the target

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

arc See Figure 16 for an exampleUsing a similar approach as in the previous section a spe-

cialized iterative solver can be implemented to solve this par-ticular quartic function The C++ function GetTimeToTar-getRGivenInitialSpeedS() in Algorithm 2 solves the equationfor either the high or low arc root and returns the resulting119905119903or returns 0 if no solution exists This implementation has

also beenwrittenwith robustness efficiency and accuracy fora wide range of parameters in mind Tests showed that theprocedure typically requires about six (modified) Newtonrsquosmethod iterations in total to converge to almost full floatprecision

7 Future work

As already hinted at in Section 4 planning to hit movingtargets can sometimes be done using a feedback loop betweena target position prediction formula and a planner for astatic target together converging to a solution over multipleiterations More research is necessary to explore the exact

International Journal of Computer Games Technology 13

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 thispaper can also be used for efficient exact collision detectionbetween a trajectory and an arbitrary polygonal mesh by test-ing the trajectory in principal space against the intersectionof the mesh and the principal plane This algorithm mighteven be combinedwith the planners from Sections 61 and 62to allow for efficient planning of the most optimal trajectoryabove or below a given polygonal mesh respectively Thesepossibilities have not been investigated in depth for this paperbut might be covered in future work

8 Conclusion

A novel analytic approximation of ballistic trajectories withair resistance has been presented that was designed to balancephysical accuracy and performance in a way that makes sensein the field of computer games

The approximationrsquos linearity in velocity has been used todefine a special principal frame of reference which makes itpossible to always work with these trajectories in a simplified2D space even though the original problem can be in 3Dwithwind coming from any directionThe combined result is thatthe proposed model is able to produce trajectories that arecomplex enough to be physically plausible while keeping themath simple enough to also allow for many different waysof efficient trajectory planning that otherwise might be tooimpractical for use in computer games

Conflict of Interests

The author declares that there is no conflict of interestsregarding the publication of this paper

References

[1] G M Gregorek Aerodynamic Drag of Model Rockets EstesIndustries Penrose Colo USA 1970

[2] R G Watts and R Ferrer ldquoThe lateral force on a spinningsphere aerodynamics of a curveballrdquo American Journal ofPhysics vol 55 no 1 pp 40ndash44 1987

[3] H D Curtis Orbital Mechanics for Engineering Students ch 1ndash5 Elsevier Butterworth-Heinemann BurlingtonMassUSA 1stedition 2005

[4] S T Thornton and J B Marion Classical Dynamics of Particlesand Systems BrooksCole Belmont Calif USA 2005

[5] P A Karkantzakos ldquoTime of flight and range of the motion of aprojectile in a constant gravitational field under the influenceof a retarding force proportional to the velocityrdquo Journal ofEngineering Science and Technology Review vol 2 no 1 pp 76ndash81 2009

[6] R D H Warburton J Wang and J Burgdofer ldquoAnalyticapproximations of projectile motion with quadratic air resis-tancerdquo Journal Service Science ampManagement no 3 pp 98ndash1052010

[7] P S Chudinov ldquoApproximate analytical investigation of projec-tile motion in a medium with quadratic drag forcerdquo Interna-tional Journal of Sports Science and Engineering vol 5 no 1 pp27ndash42 2011

[8] GW Parker ldquoProjectile motion with air resistance quadratic inthe speedrdquo American Journal of Physics vol 45 no 7 pp 606ndash610 1997

[9] DM BourgPhysics for GameDevelopers OrsquoReillyMedia 2002[10] D Herbison-Evans ldquoSolving quartics and cubics for graphicsrdquo

Tech Rep TR94-487 Basser Department of Computer ScienceUniversity of Sydney 1994

[11] WH Press S A TeukolskyW T Vetterling and B P FlanneryNumerical Recipes in C The Art of Scientific Computing Ch 9Cambridge University Press 2nd edition 1992

International Journal of

AerospaceEngineeringHindawi Publishing Corporationhttpwwwhindawicom Volume 2014

RoboticsJournal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Active and Passive Electronic Components

Control Scienceand Engineering

Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

International Journal of

RotatingMachinery

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporation httpwwwhindawicom

Journal ofEngineeringVolume 2014

Submit your manuscripts athttpwwwhindawicom

VLSI Design

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Shock and Vibration

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Civil EngineeringAdvances in

Acoustics and VibrationAdvances in

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Electrical and Computer Engineering

Journal of

Advances inOptoElectronics

Hindawi Publishing Corporation httpwwwhindawicom

Volume 2014

The Scientific World JournalHindawi Publishing Corporation httpwwwhindawicom Volume 2014

SensorsJournal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Modelling amp Simulation in EngineeringHindawi Publishing Corporation httpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Chemical EngineeringInternational Journal of Antennas and

Propagation

International Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Navigation and Observation

International Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

DistributedSensor Networks

International Journal of

Page 13: Research Article Analytical Ballistic Trajectories with ...downloads.hindawi.com/journals/ijcgt/2014/463489.pdf//a3 u + a4 = 0 for u where u = 1/t, but the latter is more well -behaved,

International Journal of Computer Games Technology 13

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 thispaper can also be used for efficient exact collision detectionbetween a trajectory and an arbitrary polygonal mesh by test-ing the trajectory in principal space against the intersectionof the mesh and the principal plane This algorithm mighteven be combinedwith the planners from Sections 61 and 62to allow for efficient planning of the most optimal trajectoryabove or below a given polygonal mesh respectively Thesepossibilities have not been investigated in depth for this paperbut might be covered in future work

8 Conclusion

A novel analytic approximation of ballistic trajectories withair resistance has been presented that was designed to balancephysical accuracy and performance in a way that makes sensein the field of computer games

The approximationrsquos linearity in velocity has been used todefine a special principal frame of reference which makes itpossible to always work with these trajectories in a simplified2D space even though the original problem can be in 3Dwithwind coming from any directionThe combined result is thatthe proposed model is able to produce trajectories that arecomplex enough to be physically plausible while keeping themath simple enough to also allow for many different waysof efficient trajectory planning that otherwise might be tooimpractical for use in computer games

Conflict of Interests

The author declares that there is no conflict of interestsregarding the publication of this paper

References

[1] G M Gregorek Aerodynamic Drag of Model Rockets EstesIndustries Penrose Colo USA 1970

[2] R G Watts and R Ferrer ldquoThe lateral force on a spinningsphere aerodynamics of a curveballrdquo American Journal ofPhysics vol 55 no 1 pp 40ndash44 1987

[3] H D Curtis Orbital Mechanics for Engineering Students ch 1ndash5 Elsevier Butterworth-Heinemann BurlingtonMassUSA 1stedition 2005

[4] S T Thornton and J B Marion Classical Dynamics of Particlesand Systems BrooksCole Belmont Calif USA 2005

[5] P A Karkantzakos ldquoTime of flight and range of the motion of aprojectile in a constant gravitational field under the influenceof a retarding force proportional to the velocityrdquo Journal ofEngineering Science and Technology Review vol 2 no 1 pp 76ndash81 2009

[6] R D H Warburton J Wang and J Burgdofer ldquoAnalyticapproximations of projectile motion with quadratic air resis-tancerdquo Journal Service Science ampManagement no 3 pp 98ndash1052010

[7] P S Chudinov ldquoApproximate analytical investigation of projec-tile motion in a medium with quadratic drag forcerdquo Interna-tional Journal of Sports Science and Engineering vol 5 no 1 pp27ndash42 2011

[8] GW Parker ldquoProjectile motion with air resistance quadratic inthe speedrdquo American Journal of Physics vol 45 no 7 pp 606ndash610 1997

[9] DM BourgPhysics for GameDevelopers OrsquoReillyMedia 2002[10] D Herbison-Evans ldquoSolving quartics and cubics for graphicsrdquo

Tech Rep TR94-487 Basser Department of Computer ScienceUniversity of Sydney 1994

[11] WH Press S A TeukolskyW T Vetterling and B P FlanneryNumerical Recipes in C The Art of Scientific Computing Ch 9Cambridge University Press 2nd edition 1992

International Journal of

AerospaceEngineeringHindawi Publishing Corporationhttpwwwhindawicom Volume 2014

RoboticsJournal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Active and Passive Electronic Components

Control Scienceand Engineering

Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

International Journal of

RotatingMachinery

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporation httpwwwhindawicom

Journal ofEngineeringVolume 2014

Submit your manuscripts athttpwwwhindawicom

VLSI Design

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Shock and Vibration

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Civil EngineeringAdvances in

Acoustics and VibrationAdvances in

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Electrical and Computer Engineering

Journal of

Advances inOptoElectronics

Hindawi Publishing Corporation httpwwwhindawicom

Volume 2014

The Scientific World JournalHindawi Publishing Corporation httpwwwhindawicom Volume 2014

SensorsJournal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Modelling amp Simulation in EngineeringHindawi Publishing Corporation httpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Chemical EngineeringInternational Journal of Antennas and

Propagation

International Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Navigation and Observation

International Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

DistributedSensor Networks

International Journal of

Page 14: Research Article Analytical Ballistic Trajectories with ...downloads.hindawi.com/journals/ijcgt/2014/463489.pdf//a3 u + a4 = 0 for u where u = 1/t, but the latter is more well -behaved,

International Journal of

AerospaceEngineeringHindawi Publishing Corporationhttpwwwhindawicom Volume 2014

RoboticsJournal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Active and Passive Electronic Components

Control Scienceand Engineering

Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

International Journal of

RotatingMachinery

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporation httpwwwhindawicom

Journal ofEngineeringVolume 2014

Submit your manuscripts athttpwwwhindawicom

VLSI Design

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Shock and Vibration

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Civil EngineeringAdvances in

Acoustics and VibrationAdvances in

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Electrical and Computer Engineering

Journal of

Advances inOptoElectronics

Hindawi Publishing Corporation httpwwwhindawicom

Volume 2014

The Scientific World JournalHindawi Publishing Corporation httpwwwhindawicom Volume 2014

SensorsJournal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Modelling amp Simulation in EngineeringHindawi Publishing Corporation httpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Chemical EngineeringInternational Journal of Antennas and

Propagation

International Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Navigation and Observation

International Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

DistributedSensor Networks

International Journal of


Recommended