protected boolean raycast(Vector2 start,double length,double invDx,double invDy,AABB aabb){
  double tx1=(aabb.getMinX() - start.x) * invDx;
  double tx2=(aabb.getMaxX() - start.x) * invDx;
  double tmin=Math.min(tx1,tx2);
  double tmax=Math.max(tx1,tx2);
  double ty1=(aabb.getMinY() - start.y) * invDy;
  double ty2=(aabb.getMaxY() - start.y) * invDy;
  tmin=Math.max(tmin,Math.min(ty1,ty2));
  tmax=Math.min(tmax,Math.max(ty1,ty2));
  if (tmax < 0)   return false;
  if (tmin > length)   return false;
  return tmax >= tmin;
}

protected boolean raycast ( Vector2 start , double length , double invDx , double invDy , AABB aabb ) { double tx1 = ( aabb . getMinX ( ) - start . x ) * invDx ; double tx2 = ( aabb . getMaxX ( ) - start . x ) * invDx ; double tmin = Math . min ( tx1 , tx2 ) ; double tmax = Math . max ( tx1 , tx2 ) ; double ty1 = ( aabb . getMinY ( ) - start . y ) * invDy ; double ty2 = ( aabb . getMaxY ( ) - start . y ) * invDy ; tmin = Math . max ( tmin , Math . min ( ty1 , ty2 ) ) ; tmax = Math . min ( tmax , Math . max ( ty1 , ty2 ) ) ; if ( tmax < 0 ) return false ; if ( tmin > length ) return false ; return tmax >= tmin ; }
returns true if the ray and aabb intersect . < p > this method is ideally called for a number of aabbs where the invdx and invdy can be computed once .
