-(Rectangle *) intersect:(Rectangle *)bRect
{
Rectangle *aRect = [[Rectangle alloc] init];
if (((self.origin.y + self.height) > bRect.origin.y) &&
((bRect.origin.x + bRect.width) > self.origin.x)) {
XYPoint *aPoint = [[XYPoint alloc] init];
[aPoint setX:self.origin.x andY:bRect.origin.y];
aRect.origin = aPoint;
aRect.width = (bRect.origin.x + bRect.width) - self.origin.x;
aRect.height = (self.origin.y + self.height) - bRect.origin.y;
}
return aRect;
}
2012-08-18 22:07:12.539 Rectangle[2368:303] First rectangle origin (400.00, 300.00)
2012-08-18 22:07:12.539 Rectangle[2368:303] First rectangle w = 100.00, h = 180.00
2012-08-18 22:07:12.540 Rectangle[2368:303] Second rectangle origin (200.00, 420.00)
2012-08-18 22:07:12.540 Rectangle[2368:303] Second rectangle w = 250.00, h = 75.00
2012-08-18 22:07:12.541 Rectangle[2368:303] Overlaping rectangle origin (400.00, 420.00)
2012-08-18 22:07:12.541 Rectangle[2368:303] Overlaping rectangle w = 50.00, h = 60.00
2012-08-18 22:06:06.524 Rectangle[2360:303] First rectangle origin (4000.00, 300.00)
2012-08-18 22:06:06.525 Rectangle[2360:303] First rectangle w = 100.00, h = 180.00
2012-08-18 22:06:06.526 Rectangle[2360:303] Second rectangle origin (200.00, 4200.00)
2012-08-18 22:06:06.527 Rectangle[2360:303] Second rectangle w = 250.00, h = 75.00
2012-08-18 22:06:06.530 Rectangle[2360:303] Overlaping rectangle origin (0.00, 0.00)
2012-08-18 22:06:06.531 Rectangle[2360:303] Overlaping rectangle w = 0.00, h = 0.00