How can I test if an oriented rectangle contains another oriented rectangle?

I have the following situation:

To detect whether is the red rectangle is inside orange area I use this function:

- (BOOL)isTile:(CGPoint)tile insideCustomAreaMin:(CGPoint)min max:(CGPoint)max {
if ((tile.x < min.x) ||
(tile.x > max.x) ||
(tile.y < min.y) ||
(tile.y > max.y)) {
NSLog(@" Object is out of custom area! ");
return NO;
}
return YES;
}


But what if I need to detect whether the red tile is inside of the blue rectangle? I wrote this function which uses the world position:

- (BOOL)isTileInsidePlayableArea:(CGPoint)tile {

// get world positions from tiles
CGPoint rt = [[CoordinateFunctions shared] worldFromTile:ccp(24, 0)];
CGPoint lb = [[CoordinateFunctions shared] worldFromTile:ccp(24, 48)];
CGPoint worldTile = [[CoordinateFunctions shared] worldFromTile:tile];

return [self isTile:worldTile insideCustomAreaMin:ccp(lb.x, lb.y) max:ccp(rt.x, rt.y)];
}


How could I do this without converting to the global position of the tiles?

• insideCustomAreaMin will work only for axis aligned rectangles. To hit-test against blue rect you need a fair hit-test function. – Kromster Aug 21 '14 at 10:51
• Sorry for my question, but what is "fair hit-test func" ? – gronzzz Aug 21 '14 at 18:40
• I believe that @KromStern is simply referring to a decent Hit-testing implementation. – Joshua Drake Aug 21 '14 at 19:45
• The top 3 results for 2d collision detection may be helpful. – Joshua Drake Aug 21 '14 at 19:48