title: How to interpolate collisions between paint events
body: <p>As of late, I have been researching all sorts of fancy collision detection algorithms and quadtrees for a 2 dimensional app, and have my application at the point where I want to start implementing those collision algorithms in. My gameloop is capable of calculating the Δt of my frames, and I want to perform 'interpolation' collision checks between painted frames (as opposed to 'brute-force' method: paint as fast as possible causing a general decrease in performance and animation quality).</p>
  
  <p><strong>Bottom Liner</strong></p>
  
  <p><em>What is the most efficient way to implement 'interpolation' collision checks and additionally, is there any collision algorithms that can simply take in the Δt and velocity to do the interpolation for me?</em></p>
  
  <hr>
  
  <p>Additional musings and information</p>
  
  <p>I am using per pixel intersection on images after AABB within a quad-tree. Images are inherently expressed as rectangles, and I find it too in-efficient to calculate convex/concave polygons around the pixels of the image that fit a defined alpha transparency threshold then perform some other algorithm such as minkowski portal refinement or recursive circles. I choose per pixel despite it's inefficiency speed wise because of the specifically rectangular constrained shape of images (Knowing this, I decrease per pixel checks by wrapping the check with a AABB collision check). In the future I might try to re-optimize/use a different method than AABB because my images will rotate at different angles.</p>
  
  <p>Game Loop code: where update() handles catch-up operations.</p>
  
  <pre><code>currentUpdateTime = System.nanoTime();
  
      while(true) {
          beginLoopTime = System.nanoTime();
  
          drawPanel.repaint();
  
          lastUpdateTime = currentUpdateTime;
          currentUpdateTime = System.nanoTime();
          update((int) ((currentUpdateTime - lastUpdateTime)/( Math.pow(10,-9) )));//1000*1000
  
          endLoopTime = System.nanoTime();
          deltaLoop = endLoopTime - beginLoopTime;
  
          if(deltaLoop &lt;= desiredDeltaLoop) {
             try {
             /*Refer to: 'http://stackoverflow.com/questions/1036754/difference-between-wait-and-sleep'
             on differences between Thread.sleep() and wait()*/
                 wait((long) ((desiredDeltaLoop - deltaLoop)/( Math.pow(10,-6) )));
             } catch(InterruptedException e) {
                 e.printStackTrace(System.out);
             }
          }
      }
  </code></pre>