Created
October 27, 2012 18:05
-
-
Save HybridEidolon/3965540 to your computer and use it in GitHub Desktop.
minimum translation vector between aabb's
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vec_t Col_RectRect(const rectangle_t* a, const rectangle_t* b) { | |
vec_t ret; | |
float left, right, top, bottom; | |
// zero the vector | |
ret.x = 0; | |
ret.y = 0; | |
// axis | |
left = b->min.x - a->max.x; | |
right = b->max.x - a->min.x; | |
bottom = b->min.y - a->max.y; | |
top = b->max.y - a->min.y; | |
if (abs(left) > right) { | |
ret.x = right; | |
} else { | |
ret.x = left; | |
} | |
if (abs(bottom) > top) { | |
ret.y = top; | |
} else { | |
ret.y = bottom; | |
} | |
if (abs(ret.x) <= abs(ret.y)) { | |
ret.y = 0; | |
} else { | |
ret.x = 0; | |
} | |
return ret; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment