Difference between revisions of "Targeting Matrix"

From Robowiki
Jump to navigation Jump to search
m
m (move to category=Targeting Discussions)
 
(2 intermediate revisions by one other user not shown)
Line 7: Line 7:
 
== Example ==
 
== 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:
+
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 <code>A = [x^2, x, 1]</code> for every x that we record, where x is the distance to our target at the time of firing, and a second vector, <code>b = [y]</code> 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:
  
 
<code>A = [[a^2, a, 1], [b^2, b, 1], [c^2, c, 1]]
 
<code>A = [[a^2, a, 1], [b^2, b, 1], [c^2, c, 1]]
Line 15: Line 15:
 
b = [[angle_a], [angle_b], [angle_c]]</code>
 
b = [[angle_a], [angle_b], [angle_c]]</code>
  
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:
+
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>
 
<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.
+
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:
+
With '''x''', it is possible to 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>
 
<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 since the alternative is to use a polynomial of dimension <math>n</math> to fit a line through all of the <math>n</math> data points.
+
Notice that the projection matrix, <math>(A^T * A)^{-1} * A^T</math>, was used to compute '''x''' rather than simply <math>A^{-1}</math>. This is because by using the projection matrix it is possible to compute '''x''' for any number of tuples. This is extremely useful since the alternative is to use a polynomial of dimension <math>n</math> to fit a line through all of the <math>n</math> data points.
  
This idea is also extremely powerful because it allows us to easily factor more in variables 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:
+
This idea is also extremely powerful because it simplifies segmentation- in order to track another factor one simply appends a vector to A. For example, if one wanted to additionally track target velocity, one would simply append another vector to A, such that:
  
 
<code>A = [[v, a^2, a, 1], [v, b^2, b, 1], [v, c^2, c, 1]]</code>
 
<code>A = [[v, a^2, a, 1], [v, b^2, b, 1], [v, c^2, c, 1]]</code>
  
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]]
+
{{Targeting Navbox}}
 +
[[Category:Targeting Discussions]]

Latest revision as of 19:27, 8 September 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 A = [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, b = [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.

With x, it is possible to 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 the projection matrix, <math>(A^T * A)^{-1} * A^T</math>, was used to compute x rather than simply <math>A^{-1}</math>. This is because by using the projection matrix it is possible to compute x for any number of tuples. This is extremely useful since the alternative is to use a polynomial of dimension <math>n</math> to fit a line through all of the <math>n</math> data points.

This idea is also extremely powerful because it simplifies segmentation- in order to track another factor one simply appends a vector to A. For example, if one wanted to additionally track target velocity, one would simply append another 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).