2013-09-03 3 views

답변

2

의사 코드 :

Rectangle 
{ 
    left, 
    top, 
    right, 
    bottom 
} 

Rectangle Intersection(Rectangle A, Rectangle B) 
{ 
    return Rectangle 
    { 
     left = max(A.left, B.left), 
     top = max(A.top, B.top), 
     right = min(A.right, B.right), 
     bottom = min(A.bottom, B.bottom) 
    } 
} 

이것은 Y 값은 위에서 아래로가는 증가 할 것으로 가정합니다. 그 반대 인 경우/maxtopbottom으로 토글합니다.

관련 문제