title: Motion blur convolution matrix given an angle and magnitude
body: <p>I have Java code that takes a convolution matrix (just a 2D <code>double[][]</code>) and applies it to an image. I'm trying to figure out how to create a matrix that will give a motion blur, given an angle (in degrees) and a magnitude for the blur.</p>
  
  <p>An example matrix for a blur with magnitude = 1 (the middle pixel is blurred by one pixel in each direction), 45 degree motion blur is:</p>
  
  <pre><code>0      0    1/3
  0     1/3    0
  1/3    0     0
  </code></pre>
  
  <p>The magnitude determines the size of the matrix (size = 2*magnitude + 1) and a single line of cells is non-zero in the direction of motion.</p>
  
  <p>What I'm having trouble with is the math/code necessary to figure out which cells to have non-zero in the matrix given the angle.</p>
  
  <p>Pseudo (or actual) code would be immensely helpful!</p>