views:

39

answers:

1

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.

Thanks

from a top view
---------------
|              |
|              |
|      c       |
|              |
|--------------|
A: 

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
...
Richard Fearn
Perfect thanks!
Milo
Not if the box is not aligned to all three axes.
dirkgently
Its totally axis alligned
Milo