v8.1.2

ht.Math.Line3(start, end)

new Line3(start, end)

Line3 是用于表示 3D 空间中线段的类,通过起点和终点两个 3D 向量来定义线段

Parameters:
Name Type Attributes Description
start ht.Math.Vector3 <optional>

线段起始点

end ht.Math.Vector3 <optional>

线段结束点

Since:
  • 8.1.2

Methods

applyMatrix4(matrix) → {ht.Math.Line3}

对起点和终点应用 4x4 矩阵变换

Parameters:
Name Type Description
matrix any

4x4 变换矩阵

Returns:
ht.Math.Line3 -

当前线段实例

at(t) → {ht.Math.Vector3}

计算线段上参数为 t 的点(t=0 为起点,t=1 为终点)

Parameters:
Name Type Description
t number

线段参数

Returns:
ht.Math.Vector3 -

对应点的向量

at(t, target) → {ht.Math.Vector3}

计算线段上参数为 t 的点(t=0 为起点,t=1 为终点)

Parameters:
Name Type Description
t number

线段参数

target ht.Math.Vector3

存储结果的向量

Returns:
ht.Math.Vector3 -

对应点的向量

clone() → {ht.Math.Line3}

创建当前线段的副本

Returns:
ht.Math.Line3 -

新的 Line3 实例

closestPointToPoint(point, clampToLine) → {ht.Math.Vector3}

计算给定点到线段的最近点

Parameters:
Name Type Description
point ht.Math.Vector3

目标点

clampToLine boolean

是否限制最近点在线段上(而非直线上)

Returns:
ht.Math.Vector3 -

最近点向量

closestPointToPoint(point, clampToLine, target) → {ht.Math.Vector3}

计算给定点到线段的最近点

Parameters:
Name Type Description
point ht.Math.Vector3

目标点

clampToLine boolean

是否限制最近点在线段上(而非直线上)

target ht.Math.Vector3

存储结果的向量

Returns:
ht.Math.Vector3 -

最近点向量

closestPointToPointParameter(point, clampToLine) → {number}

计算给定点在直线上的最近点对应的参数 t

Parameters:
Name Type Description
point ht.Math.Vector3

目标点

clampToLine boolean

是否限制 t 在 [0,1] 内

Returns:
number -

参数 t

closestPointToPointParameter(point, clampToLine) → {number}

计算给定点在直线上的最近点对应的参数 t

Parameters:
Name Type Description
point ht.Math.Vector3

目标点

clampToLine boolean

是否限制 t 在 [0,1] 内

Returns:
number -

参数 t

copy(line) → {ht.Math.Line3}

从另一个线段复制起点和终点

Parameters:
Name Type Description
line ht.Math.Line3

要复制的线段

Returns:
ht.Math.Line3 -

当前线段实例

delta() → {ht.Math.Vector3}

计算终点减起点的向量差(线段方向向量)

Returns:
ht.Math.Vector3 -

方向向量

delta(target) → {ht.Math.Vector3}

计算终点减起点的向量差(线段方向向量)

Parameters:
Name Type Description
target ht.Math.Vector3

存储结果的向量(可选,默认创建新 Vector3)

Returns:
ht.Math.Vector3 -

方向向量

distance() → {number}

计算起点到终点的直线距离

Returns:
number -

距离值

distanceSq() → {number}

计算起点到终点的距离平方

Returns:
number -

距离平方值

equals(line) → {boolean}

判断与另一个线段是否相等(起点和终点均相等)

Parameters:
Name Type Description
line ht.Math.Line3

要比较的线段

Returns:
boolean -

是否相等

getCenter() → {ht.Math.Vector3}

计算线段中点

Returns:
ht.Math.Vector3 -

中点向量

getCenter(target) → {ht.Math.Vector3}

计算线段中点

Parameters:
Name Type Description
target ht.Math.Vector3

存储结果的向量

Returns:
ht.Math.Vector3 -

中点向量