# AABB¶

## 描述¶

`AABB` consists of a position, a size, and several utility functions. It is typically used for fast overlap tests.

It uses floating-point coordinates. The 2D counterpart to `AABB` is Rect2.

Negative values for size are not supported and will not work for most methods. Use abs to get an AABB with a positive size.

Note: Unlike Rect2, `AABB` does not have a variant that uses integer coordinates.

## 属性¶

 Vector3 end `Vector3( 0, 0, 0 )` Vector3 position `Vector3( 0, 0, 0 )` Vector3 size `Vector3( 0, 0, 0 )`

## 方法¶

 AABB AABB ( Vector3 position, Vector3 size ) AABB abs ( ) bool encloses ( AABB with ) AABB expand ( Vector3 to_point ) float get_area ( ) Vector3 Vector3 get_endpoint ( int idx ) Vector3 int float Vector3 int float Vector3 get_support ( Vector3 dir ) AABB grow ( float by ) bool bool bool has_point ( Vector3 point ) AABB intersection ( AABB with ) bool intersects ( AABB with ) bool intersects_plane ( Plane plane ) bool intersects_segment ( Vector3 from, Vector3 to ) bool is_equal_approx ( AABB aabb ) AABB merge ( AABB with )

## 属性说明¶

 Default `Vector3( 0, 0, 0 )`

 Default `Vector3( 0, 0, 0 )`

 Default `Vector3( 0, 0, 0 )`

positionend 的大小。通常所有分量都是正数。

## 方法说明¶

`AABB` 完全包含另一个时，返回 `true`

```# position (-3, 2, 0), size (1, 1, 1)
var box = AABB(Vector3(-3, 2, 0), Vector3(1, 1, 1))
# position (-3, -1, 0), size (3, 4, 2), 包含原来的 AABB 和 Vector3(0, -1, 2)
var box2 = box.expand(Vector3(0, -1, 2))
```

Returns the center of the `AABB`, which is equal to position + (size / 2).

• int get_longest_axis_index ( )

• float get_longest_axis_size ( )

• int get_shortest_axis_index ( )

• float get_shortest_axis_size ( )

• bool has_no_area ( )

`AABB` 为平面或者为空时，返回 `true`

• bool has_no_surface ( )

`AABB` 为空时，返回 `true`

`AABB` 包含指定点时，返回 `true`

`AABB` 与另一个交叠时，返回 `true`

`AABB` 同时位于指定平面的两边时，返回 `true`

`AABB``from``to` 所构成的线段有交叠时，返回 `true`

`AABB``aabb` 近似相等时，返回 `true`。通过将各个分量调用 @GDScript.is_equal_approx 确定。