AABB 교차판정 (minimax test)

아래 두 함수는 동일 copy&paste용으로 2벌 작성.

//교차하면 true, 교차하지 않으면 false를 반환
bool AABB_intersect(const agg::rect_base<int>& boxA, const agg::rect_base<int>& boxB)
{
    return
        !((boxA.xmax < boxB.xmin) || (boxA.xmin > boxB.xmax)) &&
        !((boxA.ymax < boxB.ymin) || (boxA.ymin > boxB.ymax))
}

//멤버가 x1, y1, x2, y2 이고 x1<x2, y1<y2로 정규화 되어있다고 가정할때
bool AABB_intersect(const agg::rect_base<int>& boxA, const agg::rect_base<int>& boxB)
{
    return
        !((boxA.x2 < boxB.x1) || (boxA.x1 > boxB.x2)) &&
        !((boxA.y2 < boxB.y1) || (boxA.y1 > boxB.y2))
}

by Int32 | 2008/12/01 15:38 | 코드 조각 | 트랙백 | 덧글(0)

트랙백 주소 : http://scilence.egloos.com/tb/1204870
☞ 내 이글루에 이 글과 관련된 글 쓰기 (트랙백 보내기) [도움말]

:         :

:

비공개 덧글

◀ 이전 페이지          다음 페이지 ▶