跳到主要内容

KBoundingBox2d interface

KBoundingBox2d类代表着二维空间中的一个包围盒。

The KBoundingBox2d class represents a bounding box in 2d space.

Signature:

export interface KBoundingBox2d 

Properties

Property

Modifiers

Type

Description

center

readonly

KPoint2d

获取包围盒的中心点。

Get bounding box' center point.

height

readonly

number

获取包围盒的高度(y方向)。

Get bounding box' height (y direction).

max

readonly

KPoint2d

获取包围盒的右上端点。

Get bounding box' maximum point.

min

readonly

KPoint2d

获取包围盒的左下端点。

Get bounding box' minimum point.

width

readonly

number

获取包围盒的宽度(x方向)。

Get bounding box' width (x direction).

Methods

Method

Description

addPoint(point)

包围盒加入一个点,包围盒的表征范围会改变。

Add point into bounding box, bounding box's min and max will maybe be changed.

expand(delta)

包围盒的范围各向扩大一个Δ。 注意:如何Δ是一个负数,则包围盒的控制范围会减小,甚至会反转。

Expand the bounding box by a delta value. NOTE: if delta is a minus value, bounding box will be shrunk or even be reversed.

isEqual(other, tolerance)

在指定的容差下检查两个包围盒是否相等。

Check whether two bounding boxes are equal with specified tolerances.

isInside(other, tolerance)

检查输入包围盒在指定容差下是否落在包围盒中。 注意:包围盒的区域范围包括包围盒边界。

Check whether this bounding box is in the input bounding box with specified tolerance. NOTE: boundary is included.

isOverlapping(other, tolerance)

检查传入包围盒在指定容差下,与当前包围盒是否有重叠区域。 注意:重叠区域的子集包括两个包围盒为嵌套关系。

Check whether this input bounding box and this bounding box share the same space with specified tolerance. NOTE: 'inside' relationship is included.

isPointInside(point, tolerance)

检查输入点在指定容差下是否落在包围盒中。 注意:包围盒的区域范围包括包围盒边界。

Check whether the input point is in this bounding box with specified tolerance. NOTE: boundary is included.

isValid()

包围盒是否有效。

Whether this bounding box is valid.

merge(box)

合并另外一个包围盒,使得当前包围盒可以包围传入包围盒。

Merge another bounding box, thus this bounding box is able to contain the another box.