title: Separating Axis Theorem and Python
body: <p>This is what I am currently doing:</p>
  
  <p>Creating 4 axis that are perpendicular to 4 edges of 2 rectangles. Since they are rectangles I do not need to generate an axis (normal) per edge. </p>
  
  <p>I then loop over my 4 axes. </p>
  
  <p>So for each axis: 
  I get the projection of every corner of a rectangle on to the axis. 
  There are 2 lists (arrays) containing those projections. One for each rectangle.
  I then get the dot product of each projection and the axis. This returns a scalar value
  that can be used to to determine the min and max.</p>
  
  <p>Now the 2 lists contain scalars and not vectors. I sort the lists so I can easily select the min and max values. If the min of box B >= the max of box A  OR the max of box B &lt;= the min of box A then there is no collision on that axis and no collision between the objects.</p>
  
  <p>At this point the function finishes and the loop breaks.</p>
  
  <p>If those conditions are never met for all the axis then we have a collision</p>
  
  <p>I hope this was the correct way of doing it.</p>
  
  <p>The python code itself can be found here <a href="http://pastebin.com/vNFP3mAb" rel="nofollow">http://pastebin.com/vNFP3mAb</a></p>
  
  <p>Also:
  <a href="http://www.gamedev.net/page/reference/index.html/_/reference/programming/game-programming/collision-detection/2d-rotated-rectangle-collision-r2604" rel="nofollow">http://www.gamedev.net/page/reference/index.html/_/reference/programming/game-programming/collision-detection/2d-rotated-rectangle-collision-r2604</a></p>
  
  <p>The problem i was having is that the code above does not work. It always detects a a collision even where there is not a collision. What i typed out is exactly what the code is doing. If I am missing any steps or just not understanding how SAT works please let me know.</p>