軸線對齊邊界框,以獲取樂趣和利潤。
var aabb = require ( 'aabb-3d' )
var bounding_box = aabb ( [ 0 , 0 , 0 ] , [ 12 , 12 , 12 ] ) // x, y, z == 0; width, height, depth == 12
, other = aabb ( [ 10 , 10 , 10 ] , [ 2 , 2 , 2 ] )
bounding_box . intersects ( other ) // true
bounding_box . translate ( [ 2 , 2 , 2 ] ) // moves the bounding box
bounding_box . expand ( other ) // returns a new aabb that surrounds both bboxes
返回新的AABB。
返回:
x0/y1/z1---x1/y1/z1
depth-> / /|
/ / |
x0/y1/z0 -- x1/y1/z0
| | |
| | <-- height
| | /
| | /
x0/y0/z0 ----- x1/y0/z0
^
|
width
移動盒子。返回自己。
如果兩個邊界框相交(或根本觸摸),則返回true。
返回一個新的aabb
代表兩個AABB的共享區域。如果盒子不相交,則返回null
。
返回圍繞兩個AABB的新aabb
。
麻省理工學院