开发者

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
...
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜