|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Announcements
Services
Chapters
Feature Zones
|
Overview of DownloadsThe simulator itself is a console window. The kernel beep Doppler effect output and the HTML copy of the console window saved to the desktop can be turned on or off by adjusting the values of the Boolean constants at the top of Program.cs.
The GUI helps visualize the way adjusting variables alters the time it will take to intercept the target. Remember, where the red/blue line crosses the x axis is an intercept time and when the green/purple line crosses the x axis is a valid closest approach, which if less than the radius of tolerance, is a glancing blow, and not a miss.
The simple UI provides a sample of a simple application which uses my guidance system in a graphical interface. The concept is quite simple: you are the little red spaceship that starts out in the middle of the screen, and the green spaceships are trying to hit you with their white missiles. Note that anything going too far in any direction will wrap around to the other side to prevent it from flying off screen. Also note that your ship and the green ships have a limit on their velocities to prevent the situation from getting out of hand. Additionally, your ship will turn orange when you thrust forward or backward, but not when that thrust is thrown out because it would exceed the velocity limit.
IntroductionO.K., here I go with my first article. I hope you like it; I've put my heart and soul into it. Comments are more than welcome, and you can count on me to read them and respond to any and all questions, comments, or concerns. I became fascinated with guided missiles back in August of 2006 when I attended a game programming workshop. I came up with a crude way of leading a target because I did not like that the enemies in my game shot at where the player was, rather than where the player would be when the bullet got to him. My solution worked somewhat, but it was strictly limited to two dimensions and it produced a rough estimate of the correct firing angle through the use of a loop; I knew this was algorithmically inefficient, but I had a 72 hour time-line, and what I threw together would have to suffice. After that time I researched the problem on my own. Time was limited because I was starting my senior year in high school, but I was fortunate enough to be able to use this topic as my senior project, a project with a self-assigned topic that every student must, it is hoped, learn something through. I did not know how to solve this complex mathematical problem, and I was able to get some time set aside for my research as a result. This project summarizes my findings. I have developed a system for intercepting a target with a position, velocity, and acceleration with a missile (fired from a shooter with a given position and velocity-- shooter acceleration does not effect the missile) which has a given acceleration for a given duration of time (think of it as fuel, which anticipates no acceleration after being exhausted), a given initial or "muzzle" velocity, and a given initial radial distance (as in the length of the launcher which the missile appears at the end of when fired, with said initial velocity). The results of this calculation come in the form of a Boolean return indicating the ability for the specified missile to hit the specified target from the specified shooter, a list of unit vectors (a 2D double array) in which the first index is the intercept direction (there may be up to four possibilities!) listed in ascending order (fastest intercept is first in the array) and the second index ( BackgroundRelax, while I have used basic calculus gospel and the quartic formula blended together in complex algebra, you, the developer, are not expected to know the first thing about these topics, though it certainly wouldn't hurt if you do (conceptually, understanding polar graphing couldn't hurt either). I will provide here the basic mathematical foundation required to understand what my project does; when we're done here, I hope, the mathematics will be completely demystified. Essentially I solve for the amount of time it will take to hit the target, and then simply figure out where it will be after that amount of time has passed and aim in that direction. First of all, if I want to determine the path of interception relative to the shooter (with acceleration disregarded because it does not effect the initial state of the missile as velocity and position do), by subtracting the shooter's position and velocity from the target's respective values the result is a scenario that will have the same intercept vector(s) as our original scenario, but firing from the origin at these new target values instead. We have already completely eliminated the shooter's parameters from the problem. Next, handed down from calculus, are two equations that help us describe the position of an object as a function of time. Firstly, the velocity of an object after given time T has passed is equal to the acceleration times Lastly, and defiantly the most obscure piece is the use of the quartic formula. Many of you may know the quadratic formula, which states that where Using the CodeFirst of all, to prevent my code from becoming needlessly long and difficult to sift through, my variable names are quite short but still very intuitive. I use three letters to identify most variables in my guidance system. The first letter indicates whom we are speaking of ( The guidance system of my project is in a DLL which contains the static class An Abstract Look at the AlgorithmFor a more in-depth analysis, please read the actual lower-level mathematics is described in the algebraic solution section below. This section aims at conveying the concept abstractly in a simple 2D scenario, and does not discuss the specifics of how the actual results are calculated in my DLL. Firstly, subtract the positions and velocities of the shooter from the shooter and the target Position subtraction:
Velocity subtraction:
The next step is to find all occurrences where the missile can be at the same place as the target at the same time (now fired from the origin with no shooter-induced drift at the target's relative position and velocity). Essentially, these are the precise times where the target's location along its parabolic trajectory at some given time intersects the sphere centered at the origin with a radius of the distance that the projectile will have traveled in that particular amount of time (the red target dot and the black circle in the next animation, respectively); there can be as many as four such times, as few as zero, or anywhere in between (the reason why is investigated in the algebraic section), but in practice, due to the nature of the problem, there will simply be zero or two such times in the vast majority of scenarios.
Finally the launch unit vector(s) are calculated (and sorted in order of shortest to longest time in flight). This is done by taking all times calculated in the previous step and determining where the target will be at each of these times. By doing this the missile's guidance system knows where the target will be at every moment in time that it can hit it by traveling in a straight line, so, to calculate the launch unit vectors, each of these coordinates is treated as a vector and normalized. Now all that the caller will have to do is use these vectors to appropriately configure the actual missile object's state and introduce it into their runtime environment (physics engine etc.); the specifics of this environmental configuration can be found in the penultimate paragraph of the algebraic section.
Note that the second stage (the post- As for those so-called "closest" approaches, those equations simply do some calculations to determine the exact points in time when adjusting the value of time used to determine the target's future position to fire at will result in either missing the target by more or missing the target by less, regardless of weather that adjustment was an increase or a decrease (i.e. that is to say that it is the best of times or it is the worst of times, so to speak), and determines if any of these apexes were close enough. Used with the intercept calculations for both stages, these four interlocking equations account for all possible situations and are completely failsafe when used together.
Note that this is not only useful for determining glancing blows off of targets that almost escaped but were too large for their own good, but also for eliminating the adverse side-effects of rounding error when the projectile does not have any acceleration of its own (i.e. Walk-through of the Algebraic SolutionPlease note that the above naming conventions will be used here. Imagine this: After eliminating the shooter's parameters (as in paragraph two of the background section) and applying the equation that determines the position after a given amount of time has passed Next we can use this same formula to describe the target's distance from the origin in every dimension It follows that when a value for While the highest power of Here is what we have so far: To complete this problem, one must internally square each sub-equation. Fortunately the workload is reduced by the fact that the equation is essentially the same for all of them. Later when I mention the calculation of intercepts where the missile runs out of fuel during its flight, the We start with this: Xt2 = ((1/2) * Tax * t2 + Tvx * t + Tpx)2
It follows that: (A + B + C)2 = A * A + A * B + A * C +
B * A + B * B + B * C +
C * A + C * B + C * C
This is similar to the old FOIL method of multiplying binomials (First, Outside, Inside, Last), which is far more common, but it is a broader implementation of the underlying mathematical truth (this one uses trinomials) and it can be simplified for our purposes because we are only interested in squaring trinomials, so we can simplify that: (A + B + C)2 = A2 + B2 + C2 + 2 * (A * B + A * C + B * C)
Ergo, in standard polynomial form for Xt2 = (1/4) * Tax2 * t4 +
Tax * Tvx * t3 +
(Tax * Tpx + Tvx2) * t2 +
2 * Tvx * Tpx * t +
Tpx2
Combining the So now, how does this help us solve for 0 = ( (1/4) * (Tax2 + Tay2 + Taz2 - Pam2) ) * t4 +
( Tax * Tvx + Tay * Tvy + Taz * Tvz - Pam * Pvm ) * t3 +
( Tax * Tpx + Tvx2 + Tay * Tpy + Tvy2 +
Taz * Tpz + Tvz2 - Pam * Ppm - Pvm2 ) * t2 +
( 2 * ( Tvx * Tpx + Tvy * Tpy + Tvz * Tpz - Pvm * Ppm ) ) * t +
( Tpx2 + Tpy2 + Tpz2 - Ppm2 )
This can be solved for To find out what our roots are for times after P't = ( Pam * Rbt *+ Pvm ) * t + ( Ppm - (1/2) * Pam * Rbt2 )
which squared looks like this: P't2 = ( Pam2 * Rbt2 + 2 * Pam * Pvm * Rbt + Pvm2 ) * t2 +
( 2 * Pam * Ppm * (Pam * Rbt + Pvm) - Pam2 * Rbt3 - Pam * Pvm * Rbt2 ) * t +
( (1/4) * Pam2 * Rbt4 - Pam * Ppm * Rbt2 + Ppm2 )
Please bear in mind that, after subtracting these terms from the Lastly, a word about impacts which are glancing blows: Given a quartic polynomial By using this cubic, we can take our quartic coefficients and calculate closest approaches. The potentially confusing part about this is the fact that they are not necessarily meaningful, as they are commonly "furthest" approaches if a true intercepts or true closest approaches exist at the base of that apex. However, if in fact a closest approach does exist (for instance, if no true intercepts exist, then either the first and last cubic roots are closest approaches, or the middle root is a closest approach, where order is determined by the value of A generic cubic:
A generic quartic:
A cubic with roots at the places where the slope of a quartic is zero:
So, we've solved for all of our roots, now here comes the final step. By substituting those values of To use each of these unit vectors, the missile's initial state is set as follows (Acceleration, Velocity, and Position), given a targeting unit vector A = U * Pam
V = U * Pvm + Sv
P = U * Ppm + Sp
Note that during the flight when the missile is updating it's trajectory, it tells the guidance system that it's current velocity and position are the "shooter" parameters, and that it has an initial velocity of zero and an initial position of zero, because adjustments to the flight path must be done at this point with the missile's acceleration alone, i.e. there is no "shooter" to give it an initial velocity or position from where the missile starts out. Where the Quartic Formula Comes from and What Makes it SignificantIn 1540, Lodovico Ferrari discovered the quartic formula. This masterful formula was first published in the 1545 publication entitled Ars Magna, along with the cubic formula, discovered by Gerolamo Cardano, which is so crucial to solving quartic formula that it caused this five year delay. An important question arises—what is a quartic? If there are five defined constants and one variable in an equation, it is quartic if zero equals the first constant times the variable raised to the fourth power, plus the second constant times the variable raised to the third power, plus the third constant raised to the second power, plus the fourth constant times the variable, plus the fifth constant. This is generally written as This is particularly insightful to a guided missile that takes the acceleration, velocity, and position of itself and its target into account. After substituting, distributing, combining like terms, and methodically moving everything to one side of the equation, hence leaving zero on the other side, a quartic equation results, due to the fact that acceleration changes position in respect to time appears as These conclusions suggest that a missile might be able to navigate with knowledge of position, velocity, acceleration, and change in acceleration, in the same sense as acceleration represents a change in velocity, though there is no good descriptor of a change in acceleration. Surprisingly enough, this is, however, incorrect. Another question arises—what makes acceleration so special? The answer lies in the power of four that results in a quartic itself. A quintic, or an equation of any nonzero coefficient of a higher degree polynomial, does not have a formula that, given the coefficients, produces all possible values for the variable in question, namely time in the case of the guided missile. It is common knowledge in the mathematical community that "The Abel–Ruffini theorem (also known as Abel's impossibility theorem) states that there is no general solution in radicals to polynomial equations of degree five or higher" (Wikipedia). There are methods for homing in on really good estimations of all of the roots of such a polynomial, but there is no way to use the coefficients in an elegant equality statement to find all of its roots as the quadratic, cubic, and quartic formulas provide for polynomials of the second, third, and fourth degree. Points of InterestI am aware that as fuel is exhausted the mass of the projectile will decrease, and, applying HistoryFirst I made a rough routine for estimation of constant velocities in 2D in a matter of hours, later I developed an analytical 2D solution using trigonometry (primarily the law of cosines, solving for some unknowns with the quadratic equation). I was able to convert this into a 3D solution for constant velocities, but hit a wall here. After changing my thinking and moving towards algebra and calculus, and away from geometry and trigonometry, I have a 3D solution for constant acceleration, which is easily adaptable for any number of dimensions, as the quartic coefficients are quite simply the sum of the results of a particular small sub-equation for every dimension. Want a 6D solution? how about an 11D solution? one can easily set that up in 5 minutes using this method of solving for time.
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||