跳到主要内容

KInterval 接口

export interface KInterval 

KInterval类代表着一维空间中的一个区间。

The KInterval class represents an interval in 1d space

属性

end

readonly end: number;

获取区间的终点。

Get end of the interval.

length

readonly length: number;

获取区间的长度。

Get length of the interval.

middle

readonly middle: number;

获取区间的中点。

Get middle of the interval.

start

readonly start: number;

获取区间的起点。

Get start of the interval.

方法

clone

clone(): KInterval;

克隆当前区间,返回一个新对象。

Return the cloned object.

返回值: KInterval

返回克隆的新对象。

Return the new cloned object.

contains

contains(point: number, includeEnds: boolean, disTol?: number): boolean;

判断当前区间是否包含某个数值。

Check whether the interval contains a value.

参数:

  • point: number

    要检查的数值。

    The value to check.

  • includeEnds: boolean

    是否把当前区间当作是闭区间。

    Whether take the interval as closed.

  • disTol: number

    用于判断包含关系的容差。如果没有给定则采用全局距离容差。

    The tolerance used to check the value is containded by the interval. If it is not provided, global distance tolerance will be used.

返回值: boolean

如果区间包含输入值,则返回真,否则为假。

True, if the interval contains the value, otherwise false.

containsInterval

containsInterval(interval: KInterval, includeEnds: boolean, disTol?: number): boolean;

判断当前区间是否包含另外一个区间。

Check whether the current interval contains the other interval.

参数:

  • interval: KInterval

    是否被当前区间包含的另一个区间。

    The other interval to be checked.

  • includeEnds: boolean

    是否把两个区间当作是闭区间。

    Whether take the two intervals as closed.

  • disTol: number

    用于判断包含关系的容差。如果没有给定则采用全局距离容差。

    The tolerance used to check the value is containded by the interval. If it is not provided, global distance tolerance will be used.

返回值: boolean

如果当前区间包含输入的区间,则返回真,否则为假。

True, if current interval contains the other interval, otherwise false.

expanded

expanded(length: number): KInterval;

构建一个新的区间,起点和终点分别是当前区间起点和终点向外扩张给定距离。

Create a new interval whose start and end are expended by the given number.

参数:

  • length: number

    扩张距离。

    The expand distance.

返回值: KInterval

一个新区间。

A new interval.

interpolate

interpolate(alpha: number): number;

根据插值系数求得区间起点和终点之间的插值结果。

Get the interpolated value by the input coefficient.

参数:

  • alpha: number

    插值系数。

    The interplate coefficient.

返回值: number

区间插值结果。

Interplation result.

intersection

intersection(interval: KInterval): KInterval;

求当前区间和另外一个区间的相交部分,返回相交部分的区间。如果两个区间不相交,则返回一个不合法区间。

Get the intersected part between current interval and the other interval. If two intervals are not intersected, then return an invalid interval.

参数:

  • interval: KInterval

    另外一个区间。

    The other interval.

返回值: KInterval

两个区间的相交部分。如果两个区间不相交,则返回一个不合法区间。

A new interval for the intersected parts of the two intervals. If two intervals are not intersected, then return an invalid interval.

intersects

intersects(interval: KInterval, includeEnds: boolean, disTol?: number): boolean;

判断当前区间是否和另外一个区间相交。

Check whther the current interval intersects with the other interval.

参数:

  • interval: KInterval

    输入另一个区间。

    The other interval.

  • includeEnds: boolean

    是否把两个区间当作是闭区间。

    Whether take the two intervals as closed.

  • disTol: number

    用于判断相交关系的容差。如果没有给定则采用全局距离容差。

    The tolerance used to check the two intervals are intersected. If it is not provided, global distance tolerance will be used.

返回值: boolean

返回两个区间是否有交。

Reture true if two intervals have common parts.

isEqual

isEqual(other: KInterval, numTol?: number): boolean;

判断当前区间和另外一个区间是否相等。

Returns true if this interval equals to another within specified tolerance.

参数:

  • other: KInterval

    另一个区间。

    The other interval.

  • numTol: number

    用于判断两个区间的起点和终点是否相等的容差。如果不提供,则使用全局容差。

    The tolerance used to check whether the starts and ends of two intervals are equal.

返回值: boolean

如果两个区间的起点和终点在容差范围内,则返回真,否则为假。

True, if the starts and ends of two intervals are equal within tolerance. Otherwise, false.

isValid

isValid(): boolean;

判断当前区间是否合法。

Check whether the interval is valid.

返回值: boolean

返回区间是否合法。

Return true if the interval is valid.

multiplied

multiplied(num: number): KInterval;

构建一个新区间,起点和终点是当前区间的起点和终点乘上一个数。

Create a new interval whose start and end are multiplied the given number.

参数:

  • num: number

    乘数

    The multiply number.

返回值: KInterval

一个新区间。

A new interval.

offset

offset(num: number): KInterval;

构建一个新的区间,起点和终点分别是当前区间的起点和终点加上输入数值。

Create a new interval which is offset by the given number.

参数:

  • num: number

    起点和终点需要偏移的数值。

    The offset value to be added to start and end.

返回值: KInterval

一个新的区间。

A new interval object.

toString

toString(): String;

把当前区间转成字符串。

Convert the interval to string format.

返回值: String

返回区间字符串。

Return the interval string format.

union

union(interval: KInterval): KInterval;

合并当前区间和另外一个区间,返回叠加在一起后的区间。如果两个区间不相交,则返回一个不合法区间。

Combine the current interval and the other interval, return a new interval. If two intervals are not intersected, then return an invalid interval.

参数:

  • interval: KInterval

    另外一个区间。

    The other interval.

返回值: KInterval

合并后的区间。如果两个区间不相交,则返回一个不合法区间。

A new interval which has combined the two intervals. If two intervals are not intersected, then return an invalid interval.