title: Separating Axis Theorem: Finding which edge normals to use
body: <p>I'm using the implementation of the algorithm described here: <a href="http://www.codezealot.org/archives/55" rel="nofollow">http://www.codezealot.org/archives/55</a></p>
  
  <p>Using this implementation, when I want to find the minimal displacement vector for two colliding rectangles, the algorithm will sometimes (in one of two cases to be exact) give me the wrong "direction" in which one rectangle needs to pushed in order to get away from the rectangle that it's colliding with. It will instead produce the exact opposite direction from the one which it is supposed to go in.</p>
  
  <p>This is because (of course) the two opposing edges of a rectangle are of course mathematically similar and hence produce the same results.</p>
  
  <p>This is the implementation of the algorithm in Java: </p>
  
  <p><a href="http://pastebin.com/fgAwBsGv" rel="nofollow">http://pastebin.com/fgAwBsGv</a></p>
  
  <p>You can assume that Vector2f, Projection2D etc. function correctly and produce correct values. By the way, </p>
  
  <p>I'm using left hand normals because the polygon is assembled counterclock-wise. Principally, this should be enough, since the left-hand normal will always point away from the polygon. The problem is that since the two overlaps of opposing edges of a rectangle will be exactly the same, the algorithm will simply use the first one and its corresponding axis.</p>
  
  <p>thanks for your help!</p>