Skip to main content

KBoundingBox2d

kds-plugin-document / Exports / KBoundingBox2d

Interface: KBoundingBox2d

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

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

Table of contents​

Properties​

Methods​

Properties​

center​

• Readonly center: KPoint2d

获取包围盒的中心点。

Get bounding box' center point.

Defined in​

api.d.ts:7593


height​

• Readonly height: number

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

Get bounding box' height (y direction).

Defined in​

api.d.ts:7605


max​

• Readonly max: KPoint2d

获取包围盒的右上端点。

Get bounding box' maximum point.

Defined in​

api.d.ts:7587


min​

• Readonly min: KPoint2d

获取包围盒的左下端点。

Get bounding box' minimum point.

Defined in​

api.d.ts:7581


width​

• Readonly width: number

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

Get bounding box' width (x direction).

Defined in​

api.d.ts:7599

Methods​

addPoint​

▸ addPoint(point): void

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

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

Parameters​

NameTypeDescription
pointKPoint2d要加入的点。 the added point.

Returns​

void

Defined in​

api.d.ts:7633


expand​

▸ expand(delta): void

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

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

Parameters​

NameTypeDescription
deltanumber扩张参数。 The expanded coefficient.

Returns​

void

Defined in​

api.d.ts:7645


isEqual​

▸ isEqual(other, tolerance?): boolean

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

Check whether two bounding boxes are equal with specified tolerances.

Parameters​

NameTypeDescription
otherKBoundingBox2d需要被比较的包围盒。 The bounding box to compare this bounding box with.
tolerance?number指定容差·1,默认值是1e-6。 The specified tolerance.The default value is 1e-6.

Returns​

boolean

两者相等返回true,否则为false。

Return true if equal, otherwise return false.

Defined in​

api.d.ts:7623


isInside​

▸ isInside(other, tolerance?): boolean

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

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

Parameters​

NameTypeDescription
otherKBoundingBox2d传入包围盒。 The input bounding box.
tolerance?number传入容差。 The specified tolerance.

Returns​

boolean

当输入包围盒落在包围盒中,返回true。

Return True if this box is inside the input box, otherwise return false.

Defined in​

api.d.ts:7705


isOverlapping​

▸ isOverlapping(other, tolerance?): boolean

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

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

Parameters​

NameTypeDescription
otherKBoundingBox2d传入包围盒。 The input bounding box.
tolerance?number传入容差。 The specified tolerance.

Returns​

boolean

当输入包围盒与当前包围盒有共同区域,返回true。

Return true if two box share the same space, otherwise return false.

Defined in​

api.d.ts:7725


isPointInside​

▸ isPointInside(point, tolerance?): boolean

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

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

Parameters​

NameTypeDescription
pointKPoint2d输入点。 The input point.
tolerance?number传入容差。 The specified tolerance.

Returns​

boolean

当输入点落在包围盒中,返回true。

Return True if the input point is inside this box, otherwise return false.

Defined in​

api.d.ts:7685


isValid​

▸ isValid(): boolean

包围盒是否有效。

Whether this bounding box is valid.

Returns​

boolean

当左下角点的坐标小于右上角的坐标时返回true。

True will be returned if min's xy are smaller or equal to max' xy.

Defined in​

api.d.ts:7665


merge​

▸ merge(box): void

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

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

Parameters​

NameTypeDescription
boxKBoundingBox2d要合并的包围盒。 The merged bounding box.

Returns​

void

Defined in​

api.d.ts:7655