You want to use the separation axis theorem (SAT). It is usually used in 3d, but it drops quickly enough to 2d. Since you have a special case, the only axis you need to consider is the 4 main axes of your rectangles:
[1,0]
[0,1]
[sin (theta), cos (theta)]
[-cos (theta), sin (theta)]
, . min max , , . - , , ( ). 4 , .
SO :
Python
http://en.wikipedia.org/wiki/Separating_axis_theorem