Difference between revisions of "Targeting Matrix"
(Created page with "A technique employing knowledge at the intersection of linear algebra and statistics. == Idea == Using projections, as described in linear algebra, it's possible to map an n-d...") |
m |
||
Line 32: | Line 32: | ||
where v is the target velocity. (x in this case would also need another element). | where v is the target velocity. (x in this case would also need another element). | ||
+ | |||
+ | [[Category:Targeting]] |
Revision as of 16:59, 24 March 2011
A technique employing knowledge at the intersection of linear algebra and statistics.
Idea
Using projections, as described in linear algebra, it's possible to map an n-dimensional matrix, A, to a vector, b, via a third vector, x, such that Ax=b.
Example
Consider we wanted to simply devise a matrix that would map distance to a firing angle. In order to do this, we might create an 3-dimensional matrix, with values [x^2, x, 1] for every x that we record, where x is the distance to our target at the time of firing, and a second vector, [y] where y is the correct firing angle. After acquiring three data points, we'll be able to arrange our vectors in the form Ax=b, as such:
A = [[a^2, a, 1], [b^2, b, 1], [c^2, c, 1]]
x = [unknown1, unknown2, unknown3]
b = [[angle_a], [angle_b], [angle_c]]
Now we wish to solve for x. To do this, we project A onto b. Therefore, we first multiply both sides of the equation by <math>A^T</math> to get:
<math>A^T * A * x = A^T * b</math>
And then multiply by the inverse of <math>(A^T * A)</math> to reach <math>x = (A^T * A)^-1 * A^T * b</math>. We now can compute x.
Since we have <math>x</math>, we can now accurately map distances to targets to firing angles, via simply inputing distance into the function:
<math>f(x) = unknown_1 * x^2 + unknown_2 * x + unknown_3 * 1 = angle</math>
Notice that we used <math>(A^T * A)^-1 * A^T</math> (called the projection matrix, P) rather than simply <math>A^-1</math>. This is because by using the projection matrix we can actually compute <math>x</math> for any number of tuples. This is extremely useful, because if this was not possible, then we could have to use a polynomial of dimension <math>n</math> to fit a line through <math>n</math> tuples.
This idea is also extremely powerful because it allows us to easily factor more in variable by simply increasing the dimension of A. For example, if we also wanted to track target velocity, we would simply append a vector to A, such that:
A = [[v, a^2, a, 1], [v, b^2, b, 1], [v, c^2, c, 1]]
where v is the target velocity. (x in this case would also need another element).