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 matrixany 4x4 变换矩阵
-
at(t) → {ht.Math.Vector3}
-
计算线段上参数为 t 的点(t=0 为起点,t=1 为终点)
Parameters:
Name Type Description tnumber 线段参数
-
at(t, target) → {ht.Math.Vector3}
-
计算线段上参数为 t 的点(t=0 为起点,t=1 为终点)
Parameters:
Name Type Description tnumber 线段参数
targetht.Math.Vector3 存储结果的向量
-
clone() → {ht.Math.Line3}
-
创建当前线段的副本
-
closestPointToPoint(point, clampToLine) → {ht.Math.Vector3}
-
计算给定点到线段的最近点
Parameters:
Name Type Description pointht.Math.Vector3 目标点
clampToLineboolean 是否限制最近点在线段上(而非直线上)
-
closestPointToPoint(point, clampToLine, target) → {ht.Math.Vector3}
-
计算给定点到线段的最近点
Parameters:
Name Type Description pointht.Math.Vector3 目标点
clampToLineboolean 是否限制最近点在线段上(而非直线上)
targetht.Math.Vector3 存储结果的向量
-
closestPointToPointParameter(point, clampToLine) → {number}
-
计算给定点在直线上的最近点对应的参数 t
Parameters:
Name Type Description pointht.Math.Vector3 目标点
clampToLineboolean 是否限制 t 在 [0,1] 内
Returns:
number -参数 t
-
closestPointToPointParameter(point, clampToLine) → {number}
-
计算给定点在直线上的最近点对应的参数 t
Parameters:
Name Type Description pointht.Math.Vector3 目标点
clampToLineboolean 是否限制 t 在 [0,1] 内
Returns:
number -参数 t
-
copy(line) → {ht.Math.Line3}
-
从另一个线段复制起点和终点
Parameters:
Name Type Description lineht.Math.Line3 要复制的线段
-
delta() → {ht.Math.Vector3}
-
计算终点减起点的向量差(线段方向向量)
-
delta(target) → {ht.Math.Vector3}
-
计算终点减起点的向量差(线段方向向量)
Parameters:
Name Type Description targetht.Math.Vector3 存储结果的向量(可选,默认创建新 Vector3)
-
distance() → {number}
-
计算起点到终点的直线距离
Returns:
number -距离值
-
distanceSq() → {number}
-
计算起点到终点的距离平方
Returns:
number -距离平方值
-
equals(line) → {boolean}
-
判断与另一个线段是否相等(起点和终点均相等)
Parameters:
Name Type Description lineht.Math.Line3 要比较的线段
Returns:
boolean -是否相等
-
getCenter() → {ht.Math.Vector3}
-
计算线段中点
-
getCenter(target) → {ht.Math.Vector3}
-
计算线段中点
Parameters:
Name Type Description targetht.Math.Vector3 存储结果的向量