跳到主要内容

KVector2d.isEqual() method

在特定容差下,判断两个向量是否相等。 两个向量相等需要满足在距离容差下长度相等和余弦容差下方向相等。

Check whether two vectors are equal with specified tolerances. If the length of two vectors are equal in the distance tolerance and the direction are same in the cosine tolerance, it will return true.

Signature:

isEqual(other: KVector2d, distanceTolerance?: number, cosTolerance?: number): boolean;

Links: isEqual(other: KVector2d, distanceTolerance?: number, cosTolerance?: number): boolean;

Parameters

Parameter

Type

Description

other

KVector2d

被比较的向量。

The vector to compare this vector with.

distanceTolerance

number

(Optional) 距离容差,默认值是1e-6。

It will provide distance tolerance when the length of vectors are measured.The default value is 1e-6.

cosTolerance

number

(Optional) 余弦容差,默认值是1e-6。

It will provide cosine tolerance when the direction of vectors are measured.The default value is 1e-6.

Returns:

boolean

相等则返回true。

Return true if equal, otherwise return false.