title: Collision Detection with rotated sprites SharpDX
body: <p>I am writing a SharpDx.Toolkit(XNA) Game. I searched in the internet how to program a collision detection, and I've found this:</p>
  
  <pre><code>static bool perPixel(Rectangle rectangleA, Color[] dataA, Rectangle rectangleB, Color[] dataB)
          {
              // Find the bounds of the rectangle intersection
              int top = Math.Max(rectangleA.Top, rectangleB.Top);
              int bottom = Math.Min(rectangleA.Bottom, rectangleB.Bottom);
              int left = Math.Max(rectangleA.Left, rectangleB.Left);
              int right = Math.Min(rectangleA.Right, rectangleB.Right);
  
              // Check every point within the intersection bounds
              for (                      
                  int y = top; y &lt; bottom; y++)
              {
                  for (int x = left; x &lt; right; x++)
                  {
                      if (dataA[(x - rectangleA.Left) + (y - rectangleA.Top) * rectangleA.Width] != new Color(0, 0, 0, 0) &amp;&amp; dataB[(x - rectangleB.Left) + (y - rectangleB.Top) * rectangleB.Width] != new Color(0, 0, 0, 0))
                      {
                          // Get the color of both pixels at this point
                          Color colorA = dataA[(x - rectangleA.Left) +
                                               (y - rectangleA.Top) * rectangleA.Width];
                          Color colorB = dataB[x - rectangleB.Left) +
                                               (y - rectangleB.Top) * rectangleB.Width];
  
                          // If both pixels are not completely transparent,
                          if (colorA.A != 0 &amp;&amp; colorB.A != 0)
                          {
                              // then an intersection has been found
                              return true;
                          }
                      }
                  }
              }
  
              // No intersection found
              return false;
          }
  </code></pre>
  
  <p>This code works fine, but only on non-rotating sprites. So I tried to add a Matrix Transformation, but it doesn't work. </p>
  
  <p>Does anyone has an idea, how to do this?</p>
  
  <p>Thank you,
  Christian</p>
  
  <p>EDIT:The game is an 2D Game.</p>