Skip to main content

KVector3d

kds-plugin-document / Exports / KVector3d

Interface: KVector3d

KVector3d表示一个三维向量。 三维向量包含三个数。 注意:三维向量的三个分量不可变。

The KVector3d class represents a 3D vector. A 3D vector is an ordered triplet of numbers (labeled x, y, and z). NOTE: KVector3d's x, y and z are immutable.

Table of contents​

Properties​

Methods​

Properties​

length​

• Readonly length: number

获得向量的长度。

Get vector's length.

Defined in​

api.d.ts:12782


x​

• Readonly x: number

获得向量的x值。

Get vector's x value.

Defined in​

api.d.ts:12764


y​

• Readonly y: number

获得向量的y值。

Get vector's y value.

Defined in​

api.d.ts:12770


z​

• Readonly z: number

获得向量的z值。

Get vector's z value.

Defined in​

api.d.ts:12776

Methods​

added​

▸ added(other): KVector3d

两向量相加。

Return a new KVector3d which is this vector add the input vector.

Parameters​

NameTypeDescription
otherKVector3d被加的另一个向量。 The vector to add.

Returns​

KVector3d

两向量的和。

The new vector.

Defined in​

api.d.ts:12955


angle​

▸ angle(other): number

计算两向量的夹角,以弧度计。

Calculate the angle between this vector and the other vector in radians.

Parameters​

NameTypeDescription
otherKVector3d要比较的向量。 The vector to compare this vector with.

Returns​

number

两向量的夹角,范围为[0, PI]。

The angle between the two vectors, the range is [0, PI].

Defined in​

api.d.ts:12923


angleTo​

▸ angleTo(other, vecRef): number

以特定方向来计算两向量的夹角,以弧度计。

Calculate the angle to other vector, with vecRef as reference.

Parameters​

NameTypeDescription
otherKVector3d要比较的向量。 The vector to compare this vector with.
vecRefKVector3d该向量用来决定角度计算的时针方向。 the reference vec to determine the counter clockwise direction.

Returns​

number

两向量的夹角,范围为[0, 2PI]。

The angle between the two vectors, the range is [0, 2PI).

Defined in​

api.d.ts:12941


appliedEuler​

▸ appliedEuler(euler): KVector3d

对当前向量应用一个由欧拉角定义的旋转变换,得到一个新向量。

Return a new Vector which is the result of this vector transformed by the input euler angles.

Parameters​

NameTypeDescription
eulerKEuler欧拉角和欧拉角的顺序 the input Euler angles and their order.

Returns​

KVector3d

得到一个新的向量。

The new vector.

Defined in​

api.d.ts:13125


appliedMatrix4​

▸ appliedMatrix4(matrix): KVector3d

对当前向量应用一个矩阵来进行变换。

Return a new Vector which is the result of this vector transformed by the input matrix.

Parameters​

NameTypeDescription
matrixKMatrix4变换矩阵。 the input transform matrix.

Returns​

KVector3d

得到一个新的向量。

The new vector.

Defined in​

api.d.ts:13111


appliedQuaternion​

▸ appliedQuaternion(quaternion): KVector3d

对当前向量应用一个由四元数定义的旋转变换,得到一个新向量。

Return a new Vector which is the result of this vector transformed by the input quaternion.

Parameters​

NameTypeDescription
quaternionKQuaternion四元数 the input quaternion which detines the rotation.

Returns​

KVector3d

得到一个新的向量。

The new vector.

Defined in​

api.d.ts:13139


clone​

▸ clone(): KVector3d

复制一个当前向量。

Return the cloned vector of this.

Returns​

KVector3d

复制的向量。

The cloned vector.

Defined in​

api.d.ts:13007


cross​

▸ cross(other): KVector3d

两向量的叉积。

Return the cross result of this vector and the input other vector.

Parameters​

NameTypeDescription
otherKVector3d被叉积的另一向量。 The vector to cross.

Returns​

KVector3d

两向量叉积的结果。

The cross product of the vectors.

Defined in​

api.d.ts:12997


dot​

▸ dot(other): number

两向量的点积。

Return the dot product of this vector and the input other vector.

Parameters​

NameTypeDescription
otherKVector3d被点积的另一个向量。 The vector to dot.

Returns​

number

两向量点积的结果。

The dot product of the vectors.

Defined in​

api.d.ts:12983


isEqual​

▸ isEqual(other, distanceTolerance?, cosTolerance?): boolean

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

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.

Parameters​

NameTypeDescription
otherKVector3d被比较的向量。 The vector to compare this vector with.
distanceTolerance?number距离容差,默认值是1e-6。 It will provide distance tolerance when the length of vectors are measured.The default value is 1e-6.
cosTolerance?number余弦容差,默认值是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.

Defined in​

api.d.ts:12841


isOnSameSide​

▸ isOnSameSide(other, distanceTolerance?, cosTolerance?, checkFuzzyZeroVec?): boolean

检查两个向量在特定容差下是否为相同侧,相同侧意味着夹角小于九十度。 当checkFuzzyZeroVec为真时,如果两个向量中的任意一个长度在容差内接近零,结果直接为false。 当checkFuzzyZeroVec为假时,如果两个向量中的任意一个长度精确的等于零,结果直接为false。

Check if the directions of two vectors are equal within specified tolerance. If checkFuzzyZeroVec is true, any vector's length is nearly zero within the tolerance, false will be returned directly. If checkFuzzyZeroVec if false, only when any vector's length is exact 0, false will be returned directly.

Parameters​

NameTypeDescription
otherKVector3d被比较的另外一向量。 The vector to compare this vector with.
distanceTolerance?number距离容差,默认值是1e-6。 It will provide distance tolerance when the length of vectors are measured.The default value is 1e-6.
cosTolerance?number余弦容差,默认值是1e-6。 It will provide cosine tolerance when the direction of vectors are measured.The default value is 1e-6.
checkFuzzyZeroVec?boolean默认checkFuzzyZeroVec是真。 The default value is true.

Returns​

boolean

相同则返回true。

Return true if same, otherwise return false.

Defined in​

api.d.ts:13067


isOpposite​

▸ isOpposite(other, distanceTolerance?, cosTolerance?, checkFuzzyZeroVec?): boolean

检查两个向量的方向在特定容差下是否相反。 当checkFuzzyZeroVec为真时,如果两个向量中的任意一个长度在容差内接近零,结果直接为false。 当checkFuzzyZeroVec为假时,如果两个向量中的任意一个长度精确的等于零,结果直接为false。

Check if this vector is opposite with other vector with specified tolerance. If checkFuzzyZeroVec is true, any vector's length is nearly zero within the tolerance, false will be returned directly. If checkFuzzyZeroVec if false, only when any vector's length is exact 0, false will be returned directly.

Parameters​

NameTypeDescription
otherKVector3d被比较的另外一向量。 The vector to compare this vector with.
distanceTolerance?number距离容差,默认值是1e-6。 It will provide distance tolerance when the length of vectors are measured.The default value is 1e-6.
cosTolerance?number余弦容差,默认值是1e-6。 It will provide cosine tolerance when the direction of vectors are measured.The default value is 1e-6.
checkFuzzyZeroVec?boolean默认checkFuzzyZeroVec是真。 The default value is true.

Returns​

boolean

相反则返回true。

Return true if opposite, otherwise return false.

Defined in​

api.d.ts:13097


isParallel​

▸ isParallel(other, tolerance?, checkFuzzyZeroVec?): boolean

在特定容差下判断两个向量是否平行。 当checkFuzzyZeroVec为真时,如果两个向量中的任意一个长度在容差内接近零,结果直接为false。 当checkFuzzyZeroVec为假时,如果两个向量中的任意一个长度精确的等于零,结果直接为false。

Check if this vector is parallel with other vector with specified tolerance. If checkFuzzyZeroVec is true and any vector's length is nearly zero with the tolerance, false will be return directly. If checkFuzzyZeroVec if false, only when any vector's length is exact 0, false will be returned directly.

Parameters​

NameTypeDescription
otherKVector3d要比较的向量。 The vector to compare this vector with.
tolerance?number指定的容差。默认值是1e-6。 The specified tolerance.The default value is 1e-6.
checkFuzzyZeroVec?boolean默认checkFuzzyZeroVec是真。 The default value is true.

Returns​

boolean

如果平行则返回true。

Return true if parallel, otherwise return false.

Defined in​

api.d.ts:12893


isPerpendicular​

▸ isPerpendicular(other, tolerance?, checkFuzzyZeroVec?): boolean

在特定容差下判断两个向量是否垂直。 当checkFuzzyZeroVec为真时,如果两个向量中的任意一个长度在容差内接近零,结果直接为false。 当checkFuzzyZeroVec为假时,如果两个向量中的任意一个长度精确的等于零,结果直接为false。

Check if this vector is perpendicular with other vector with specified tolerance. If checkFuzzyZeroVec is true, any vector's length is nearly zero within the tolerance, false will be returned directly. If checkFuzzyZeroVec is false, only when any vector's length is exact 0, false will be returned directly.

Parameters​

NameTypeDescription
otherKVector3d要比较的向量。 The vector to compare this vector with.
tolerance?number指定的容差。默认值是1e-6。 The specified tolerance.The default value is 1e-6.
checkFuzzyZeroVec?boolean默认checkFuzzyZeroVec是真。 The default value is true.

Returns​

boolean

如果垂直则返回true。

Return true if perpendicular, otherwise return false.

Defined in​

api.d.ts:12867


isSameDirection​

▸ isSameDirection(other, distanceTolerance?, cosTolerance?, checkFuzzyZeroVec?): boolean

检查两个向量在特定容差下是否方向相同。 当checkFuzzyZeroVec为真时,如果两个向量中的任意一个长度在容差内接近零,结果直接为false。 当checkFuzzyZeroVec为假时,如果两个向量中的任意一个长度精确的等于零,结果直接为false。

Check if the directions of two vectors are equal within specified tolerance. If checkFuzzyZeroVec is true, any vector's length is nearly zero within the tolerance, false will be returned directly. If checkFuzzyZeroVec if false, only when any vector's length is exact 0, false will be returned directly.

Parameters​

NameTypeDescription
otherKVector3d被比较的另外一向量。 The vector to compare this vector with.
distanceTolerance?number距离容差,默认值是1e-6。 It will provide distance tolerance when the length of vectors are measured.The default value is 1e-6.
cosTolerance?number余弦容差,默认值是1e-6。 It will provide cosine tolerance when the direction of vectors are measured.The default value is 1e-6.
checkFuzzyZeroVec?boolean默认checkFuzzyZeroVec是真。 The default value is true.

Returns​

boolean

相同则返回true。

Return true if same, otherwise return false.

Defined in​

api.d.ts:13037


isZero​

▸ isZero(tolerance?): boolean

检查当前向量是否为零向量。 注意:零向量是指向量的长度在容差范围内等于零。

Check whether a vector is zero vector. NOTE: A vector is zero vector if its length is 0 with specified tolerance.

Parameters​

NameTypeDescription
tolerance?number指定的容差。默认值是1e-6。 The specified tolerance.The default value is 1e-6.

Returns​

boolean

如果为零向量。

Return true if the vector is zero vector, otherwise return false.

Defined in​

api.d.ts:12909


multiplied​

▸ multiplied(scale): KVector3d

返回一个新的向量,该新向量为当前向量的倍乘。

Return a new vector which is the scaler result of this vector.

Parameters​

NameTypeDescription
scalenumber乘数。 The scale factor.

Returns​

KVector3d

倍乘后的向量。

a new multiplied vector.

Defined in​

api.d.ts:12816


normalized​

▸ normalized(): KVector3d

返回当前向量的单位向量。

Return this vector's normalized vector.

Returns​

KVector3d

一个新的单位向量。

a new normalized vector.

Defined in​

api.d.ts:12792


reversed​

▸ reversed(): KVector3d

返回一个新的向量,该新向量为当前向量的翻转。

Return a new vector which is the reverse of this vector.

Returns​

KVector3d

一个新的翻转向量。

a new reversed vector.

Defined in​

api.d.ts:12802


subtracted​

▸ subtracted(other): KVector3d

两向量相减。

Return a new KVector3d which is this vector subtract the input vector.

Parameters​

NameTypeDescription
otherKVector3d被减的另一个向量。 The vector to subtract.

Returns​

KVector3d

两向量的差。

The new vector.

Defined in​

api.d.ts:12969