Math3

Math3

Math3 三维数学计算函数。提供长度、面积、角度、缓冲区、插值等计算。

Members

Methods

staticAngle(v1,v2,up) → number

计算两个向量围绕指定法向量之间所张的角度。逆时针为正
Name Type Description
v1 Vector3 向量1
v2 Vector3 向量2
up Vector3 optional法向量

staticArea(triPoints) → number

计算三角网面积,相邻三个点依次代表一个三角形
Name Type Description
triPoints Vector3[] 点数组

staticBuffer(points,radius,isRoundJoin,isRoundEnd,isClosed) → Vector3[]

计算缓冲区
Name Type Description
points Vector3[] 中心线坐标
radius number 半径米
isRoundJoin boolean optional是否圆角转弯
isRoundEnd boolean optional是否原型端头
isClosed boolean optional是否闭合

staticDistance(x1,y1,z1,x2,y2,z2) → number

计算一对三维坐标点之间的距离
Name Type Description
x1 number
y1 number
z1 number
x2 number
y2 number
z2 number

staticDistanceLineLine(points1,points2) → number

计算两条三维折线之间的最小距离
Name Type Description
points1 Vector3[]
points2 Vector3[]

staticDistanceLineLineAdvance(points1,points2,distLinePoints) → number

计算两条三维折线之间的最小距离,保存最短线段坐标
Name Type Description
points1 Vector3[]
points2 Vector3[]
distLinePoints RefValue<Array<Vector3>> 保存最短线段坐标,RefValue指向结果顶点数组

staticDistancePoint(pt1,pt2) → number

计算两点之间距离
Name Type Description
pt1 Vector3
pt2 Vector3

staticDistancePointLine(point,points) → number

计算点到折线距离
Name Type Description
point Vector3
points Vector3[]

staticDistancePointLineAdvance(point,points,distPoint) → number

计算点到折线距离,保存最近点坐标
Name Type Description
point Vector3
points Vector3[]
distPoint Vector3 最近点坐标

staticIntersectRay(trianglePoints,pt1,pt2,ptResult) → boolean

计算射线与三角形集合的交点
Name Type Description
trianglePoints Vector3[] 点数组,相邻三个点代表一个三角形
pt1 Vector3 射线起点
pt2 Vector3 射线终点
ptResult Vector3 交点坐标

staticIntersectRayIndexed(trianglePoints,indices,pt1,pt2,ptResult) → boolean

计算射线与索引三角形集合的交点
Name Type Description
trianglePoints Array<Vector3> 点数组
indices Array<number> 索引数组,相邻三个索引指向的点代表一个三角形
pt1 Vector3 射线起点
pt2 Vector3 射线终点
ptResult Vector3 交点坐标

staticLength(points) → number

计算三维折线长度
Name Type Description
points Vector3[]

staticLengthVector3Array(points,start,count) → number

计算三维折线长度
Name Type Description
points Vector3Array
start number optional
count number optional

staticNearEqual(pt1,pt2,tolerance) → boolean

判断两个向量是否近似相等
Name Type Description
pt1 Vector3 点1
pt2 Vector3 点2
tolerance number optional容差值

staticNearZero(pt,tolerance) → boolean

判断向量是否近似为零向量
Name Type Description
pt Vector3
tolerance number optional容差值

staticPolygonToTriangles(polyPoints,holes) → Vector3[]

多边形转换为三角网
Name Type Description
polyPoints Vector3[] 多边形外轮廓点数组
holes Vector3[][] optional

staticSpline(controlPoints,insertCount,isClosed) → Vector3[]

计算样条插值曲线
Name Type Description
controlPoints Vector3[] 控制点数组
insertCount number 控制点之间插值点数目
isClosed boolean optional是否闭合