开发者

Minimum and maximum of a box?

开发者 https://www.devze.com 2023-01-15 06:22 出处:网络
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? i

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

精彩评论

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