Minimum and maximum of a box?
Given the, width, height and depth of a box and its center point, how could I find the minimum, x, y, and z coordinate and the maximum x, y and z coordinate without bruteforcing through each vertex? its an AABB box.
Tha开发者_JS百科nks
from a top view
---------------
| |
| |
| c |
| |
|--------------|
This should do it:
(xmin, ymin, zmin) = (xcentre, ycentre, zcentre) - (width, height, depth) / 2
(xmax, ymax, zmax) = (xcentre, ycentre, zcentre) + (width, height, depth) / 2
or in full:
xmin = xcentre - width / 2
xmax = xcentre + width / 2
ymin = ycentre - height / 2
...
精彩评论