Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Contest: rectangle intersection
#7
In Java:

Code:
public boolean c(int cx1, int cy1, int w1, int h1, int cx2, int cy2, int w2, int h2)
{
    int tlx1 = cx1 - (w1 * 1/2);
    int tly1 = cy1 + (h1 * 1/2);
    int brx1 = cx1 + (w1 * 1/2);
    int bry1 = cy1 - (h1 * 1/2);
    int tlx2 = cx2 - (w2 * 1/2);
    int tly2 = cy2 + (h2 * 1/2);
    int brx2 = cx2 + (w2 * 1/2);
    int bry2 = cy2 - (h2 * 1/2);
    
    if ((tlx1 < brx2 and tly1 > bry2) || (tlx2 < brx1 and tly2 > brx2))
    {
        return true;
    }
    else
    {
        return false;
    }
}

public boolean d(int tlx1, int tly1, int brx1, int bry1, int tlx2, int tly2, int brx2, int bry2)
{
    if ((tlx1 < brx2 and tly1 > bry2) || (tlx2 < brx1 and tly2 > brx2))
    {
        return true;
    }
    else
    {
        return false;
    }
}
Reply


Messages In This Thread
Contest: rectangle intersection - by noob007 - 06-18-2012, 01:00 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)