KGeomLib
kds-plugin-document / Exports / KGeomLib
Interface: KGeomLib
KGeomLib类定义了若干方法以方便的执行多种几何建模操作,例如构建曲线、曲面或其他几何算法等。
The KGeometry class defines a number of methods that let you perform different geometric operations, such as creating geometric curves, surfaces, using geometric algorithms, etc.
Table of contents
Methods
- areCurvesOverlap
- areCurvesTotallyOverlap
- boundedCurve2dInLoop2D
- createAlignCCSMatrix4
- createArc2dByArcAngle
- createArc2dByChordAndBulge
- createArc2dByPointsAndStartTangent
- createArc2dByStartEndAngles
- createArc2dByStartEndPoints
- createArc2dByThreePoints
- createArc2dByTwoPointsAndRadius
- createArc3dByCenterNormalRadius
- createArc3dByStartEndAngles
- createArc3dByThreePoints
- createBoundingBox2d
- createBoundingBox3d
- createCircle2dByCenterAndPoint
- createCircle2dByCenterAndRadius
- createCircle2dByThreePoints
- createCircle3dByCenterNormalRadius
- createCircle3dByLCSRadius
- createCircle3dByThreePoints
- createEllipticalArc2dByStartEndParams
- createEllipticalArc2dByStartEndPoints
- createEuler
- createGeomFace2d
- createGeomLoop2d
- createGeomLoop2dByPoints
- createIdentityMatrix3
- createIdentityMatrix4
- createInterval
- createIntervalFromValues
- createInvalidInterval
- createLine2d
- createLine3d
- createLineSegment2d
- createLineSegment3d
- createNurbsCurve2d
- createPlaneByPointNormal
- createPlaneByThreePoints
- createPoint2d
- createPoint3d
- createPolylineCurve2d
- createPolylineCurve3d
- createQuaternion
- createRotateMatrix3
- createRotateMatrix4
- createRotateMatrix4FromEuler
- createRotateMatrix4FromQuaternion
- createScaleMatrix3
- createScaleMatrix4
- createTranslationMatrix3
- createTranslationMatrix4
- createVector2d
- createVector3d
- curve2dsFromJson
- curveIntersectCurve
- curveIntersectSurface
- faces2dBoolean
- intersectIntervals
- loop2DInLoop2D
- offsetPath2dWithDistances
- planeIntersectPlane
- pointInFace2D
- pointInLoop2D
- slerpFlatQuaternion
- uniteIntervals
Methods
areCurvesOverlap
▸ areCurvesOverlap(curve1
, curve2
, tolerance?
): boolean
在特定容差下,检查两曲线是否有重合部分(包括完全重合)。
Get the overlap status of two curves, include totally and partial overlap.
Parameters
Name | Type | Description |
---|---|---|
curve1 | KCurve3d | 第一条曲线。 The first curve. |
curve2 | KCurve3d | 第二条曲线。 The second curve. |
tolerance? | number | 特定容差,默认值是1e-6。 The specified tolerance.The default value is 1e-6. |
Returns
boolean
如果两条曲线有重合部分,则返回true。
Return true if two curves overlap, otherwise return false.
Defined in
api.d.ts:8276
areCurvesTotallyOverlap
▸ areCurvesTotallyOverlap(curve1
, curve2
, tolerance?
): boolean
在特定容差下,检查两曲线是否完全重合。
Get the totally overlap status of two curves with specified tolerance.
Parameters
Name | Type | Description |
---|---|---|
curve1 | KCurve3d | 第一条曲线。 The first curve. |
curve2 | KCurve3d | 第二条曲线。 The second curve. |
tolerance? | number | 特定容差,默认值是1e-6。 The specified tolerance.The default value is 1e-6. |
Returns
boolean
若两条曲线完全重叠,则返回true。
Return true if two curves totally overlap, otherwise return false.
Defined in
api.d.ts:8254
boundedCurve2dInLoop2D
▸ boundedCurve2dInLoop2D(checkCurve
, baseLoop
, tolerance?
): KCurveInLoopType
以特定容差判断轮廓线是否落在另一环内。
Check if bounded curve is inside of base loop2d with specified tolerance.
Parameters
Name | Type | Description |
---|---|---|
checkCurve | KBoundedCurve2d | 被判断的轮廓线。 The bounded curve to check. |
baseLoop | KLoop2d | 环。 The base loop2d. |
tolerance? | number | 特定容差,默认值是1e-6。 The specified tolerance.The default value is 1e-6. |
Returns
返回CurveInLoopType,包含曲线与环的位置关系信息。
The KCurveInLoopType include intersect type.
Defined in
api.d.ts:8450
createAlignCCSMatrix4
▸ createAlignCCSMatrix4(x
, y
, z
, origin
): KMatrix4
创建一个变换矩阵,是从全局坐标系到局部坐标系的变换。
Create a transformation matrix which align global ccs to the given ccs.
Parameters
Name | Type | Description |
---|---|---|
x | KVector3d | 给定坐标系的x方向。 The x direction of the given coordinate system. |
y | KVector3d | 给定坐标系的y方向。 The y direction of the given coordinate system. |
z | KVector3d | 给定坐标系的z方向。 The z direction of the given coordinate system. |
origin | KPoint3d | 给定坐标系的原点。 The origin of the given coordinate system. |
Returns
变换矩阵。
The transformation matrix.
Defined in
api.d.ts:7487
createArc2dByArcAngle
▸ createArc2dByArcAngle(center
, radius
, startAngle
, arcAngle
): KArc2d
通过圆弧的圆心、半径、起始角度和圆弧角度来创建一段圆弧。
Create an arc by center, radius, start angle and arc angle.
Parameters
Name | Type | Description |
---|---|---|
center | KPoint2d | 圆心。 The center point of the 2D arc. |
radius | number | 圆弧半径。 The radius of the 2D arc. |
startAngle | number | 圆弧的起始角度。 The start angle of the arc. |
arcAngle | number | 圆弧的角度。 正的圆弧角度值表示从圆弧起始角度沿逆时针方向转动这个角度为圆弧终点。 负的圆弧角度值表示从圆弧起始角度沿顺时针方向转动这个角度为圆弧终点。 The angle of the arc. If the angle is positive, it means the arc span is along the counter clockwise direction. If the angle is negative, it means the arc span is along the clockwise direction. |
Returns
二维圆弧。
The 2D arc.
Defined in
api.d.ts:7784
createArc2dByChordAndBulge
▸ createArc2dByChordAndBulge(chord
, signedBulge
): KArc2d
通过圆弧的弦和圆弧突起的高度比例来创建圆弧。
Create an arc by the chord of the arc and the bulge ratio.
..
. | . . A | .
chord
bulge = Math.tan(A) = sagitta / (0.5 * chord)
NOTE: if signedBulge > 0, the arc is conter clockwise, otherwise it's clockwise.
Parameters
Name | Type | Description |
---|---|---|
chord | KLineSegment2d | 圆弧的弦。 The chord of the 2d arc. |
signedBulge | number | 圆弧的突起比例。 The bulge ratio of the arc. |
Returns
圆弧。
The 2d arc.
Defined in
api.d.ts:7811
createArc2dByPointsAndStartTangent
▸ createArc2dByPointsAndStartTangent(start
, end
, startTangent
, cosTol?
): KArc2d
通过圆弧起点、终点以及起点切向来创建圆弧。
Create an arc by start point, end point and tangent at start point.
Parameters
Name | Type | Description |
---|---|---|
start | KPoint2d | 圆弧起点。 The start point of the 2d arc. |
end | KPoint2d | 圆弧终点。 The end point of the 2d arc. |
startTangent | KVector2d | 圆弧起点的切向量(单位向量)。 切向量的方向决定了圆弧是逆时针的还是顺时针的。 The tangent at the start point of the 2d arc. The direction of the tangent determines whether the arc is counter clockwise or clockwise. |
cosTol? | number | 可选参数,用于判断切向量和起点终点之间的连线方向是否平行的容差。如果平行,则返回空。 The cosin angle tolerance to check whether the tangent is parallel to the direction from start point to end point. If it is parallel, return null. |
Returns
圆弧。
The 2d arc.
Defined in
api.d.ts:7840
createArc2dByStartEndAngles
▸ createArc2dByStartEndAngles(center
, radius
, startAngle
, endAngle
, isCCW
): KArc2d
通过圆弧的圆心、半径、起始角度和终止角度来创建一段圆弧。
Create an arc by center, radius, start angle and end angle.
Parameters
Name | Type | Description |
---|---|---|
center | KPoint2d | 圆心。 The center point of the 2D arc. |
radius | number | 圆弧半径。 The radius of the 2D arc. |
startAngle | number | 圆弧的起始角度。 The start angle of the arc. |
endAngle | number | 圆弧的终止角度。 The end angle of the arc. |
isCCW | boolean | 圆弧是否是逆时针方向。 如果圆弧是逆时针方向,则表示圆弧是圆上从起始角开始沿逆时针方向到达终止角的那一段圆,反之则表示圆上另外一侧的一段。 Whether the 2d arc is counter clockwise from startAngle to endAngle. True means the counter clockwise segment of the circle from startAngle to endAngle. False means the clockwise segment of the circle from startAngle to endAngle. |
Returns
二维圆弧。
The 2D arc.
Defined in
api.d.ts:7754
createArc2dByStartEndPoints
▸ createArc2dByStartEndPoints(center
, startPoint
, endPoint
, isCCW
): KArc2d
通过圆心、圆弧起点和末点来创建圆弧。
Create an arc by start and end points.
Parameters
Name | Type | Description |
---|---|---|
center | KPoint2d | 圆心。 The center point of the 2D arc. |
startPoint | KPoint2d | 圆弧的起点,需要注意,该点需要在圆弧上。 The startPoint point of the 2D arc. The caller need to make sure it's on the arc. |
endPoint | KPoint2d | 圆弧的末点,需要注意,该点需要在圆弧上。 The end point of the 2D arc. The caller need to make sure it's on the arc. |
isCCW | boolean | 圆弧是否是逆时针方向。 如果圆弧是逆时针方向,则表示圆弧是圆上从起点开始沿逆时针方向到达终点的那一段圆,反之则表示圆上另外一侧的一段。 Whether the 2d arc is counter clockwise from startPoint to endPoint. True means the counter clockwise segment of the circle from startPoint to endPoint. False means the clockwise segment of the circle from startPoint to endPoint. |
Returns
二维圆弧。
The 2D arc.
Defined in
api.d.ts:7721
createArc2dByThreePoints
▸ createArc2dByThreePoints(startPoint
, midPoint
, endPoint
): KArc2d
通过三个点创建一个圆弧。 Create an arc by input three points.
Parameters
Name | Type | Description |
---|---|---|
startPoint | KPoint2d | 圆弧的起点。 The start point of the 2D arc. |
midPoint | KPoint2d | 圆弧的中点。 The middle point of the 2D arc. |
endPoint | KPoint2d | 圆弧的末点。 The end point of the 2D arc. |
Returns
返回一个圆弧或者null,当三点共线时就是null。
The 2D arc or null (if the three points are colinear).
Defined in
api.d.ts:7692
createArc2dByTwoPointsAndRadius
▸ createArc2dByTwoPointsAndRadius(startPoint
, endPoint
, radius
, isMinorArc
, isCCW
): KArc2d
创建给定半径并经过给定起点和终点的圆弧。 当给定圆弧起点、终点和半径之后,总共有4种选择,通过isMinorArc和isCCW两个参数再来决定是哪一种选择。 . . . . . . . .e . . . . . . . . . . . . . . . . . . .s . . . . . . .
Create an arc by start end points and the radius. There will be 4 choices if the start end points and radius of the arc are determined, and the other two parameters isMinorArc and isCCW will determine which one.
Parameters
Name | Type | Description |
---|---|---|
startPoint | KPoint2d | 圆弧的起点。 The startPoint point of the 2D arc. |
endPoint | KPoint2d | 圆弧的终点。 The end point of the 2D arc. |
radius | number | 圆弧半径。 如果半径小于起点和终点之间距离的一半,则取这个距离的一半。也就是圆弧会是经过起点和终点的一个半圆弧。 The radius of the 2d arc. If radius is smaller than the half distance from startPoint to endPoint, it will return a semicircle arc whose diameter is the distance. |
isMinorArc | boolean | 当值为true时,表示的是起点和终点之间小的那两段圆弧其中之一。当值为false时,表示的是起点和终点之间大的那两段圆弧其中之一。 true: minor arc; false: major arc |
isCCW | boolean | 圆弧是否是逆时针方向。 如果圆弧是逆时针方向,则表示圆弧是圆上从起点开始沿逆时针方向到达终点的那一段圆,反之则表示圆上另外一侧的一段。 Whether the 2d arc is counter clockwise from startPoint to endPoint. True means the counter clockwise segment of the circle from startPoint to endPoint. False means the clockwise segment of the circle from startPoint to endPoint. |
Returns
圆弧。
The 2d arc.
Defined in
api.d.ts:7888
createArc3dByCenterNormalRadius
▸ createArc3dByCenterNormalRadius(center
, normal
, radius
, startPoint
, endPoint
): KArc3d
通过圆心和法向和半径和起点末点来创建圆弧。 注意:这种方式创建的圆弧始终时围绕着法向逆时针的。
Create an arc by start and end points. NOTE: the created arc is always counter-clockwise around the normal.
Parameters
Name | Type | Description |
---|---|---|
center | KPoint3d | 圆心。 The center point of the 3D arc. |
normal | KVector3d | 法向。 The normal of the 3D arc. |
radius | number | 圆弧半径。 The radius of the 3D arc. |
startPoint | KPoint3d | 圆弧的起点,需要注意,该点需要在圆弧上。 The startPoint point of the 3D arc. The caller need to make sure it's on the arc. |
endPoint | KPoint3d | 圆弧的末点,需要注意,该点需要在圆弧上。 The end point of the 3D arc. The caller need to make sure it's on the arc. |
Returns
三维圆弧。
The 3D arc.
Defined in
api.d.ts:7941
createArc3dByStartEndAngles
▸ createArc3dByStartEndAngles(center
, xDir
, yDir
, radius
, startAngle
, endAngle
): KArc3d
通过圆弧的圆心、X轴、Y轴、半径、起始角度和终止角度来创建一段圆弧。
Create an arc by center, x direction, y direction, radius, start angle and end angle.
Parameters
Name | Type | Description |
---|---|---|
center | KPoint3d | 圆心。 The center point of the 3D arc. |
xDir | KVector3d | 圆弧局部标架的X轴方向。 X direction of the arc's local coordinate system, must be normalized. |
yDir | KVector3d | 圆弧局部标架的Y轴方向。 Y direction of the arc's local coordinate system, must be normalized. |
radius | number | 圆弧半径。 The radius of the 3D arc. |
startAngle | number | 圆弧的起始角度。 The start angle of the arc, will be clamped to [0, 2PI). |
endAngle | number | 圆弧的终止角度。 The end angle of the arc, will be clamped to [0, 2PI). |
Returns
三维圆弧。
The 3D arc.
Defined in
api.d.ts:7975
createArc3dByThreePoints
▸ createArc3dByThreePoints(startPoint
, midPoint
, endPoint
): KArc3d
通过三个点创建一个圆弧。 Create an arc by input three points.
Parameters
Name | Type | Description |
---|---|---|
startPoint | KPoint3d | 圆弧的起点。 The start point of the 3D arc. |
midPoint | KPoint3d | 圆弧的中点。 The middle point of the 3D arc. |
endPoint | KPoint3d | 圆弧的末点。 The end point of the 3D arc. |
Returns
返回一个圆弧或者null,当三点共线时就是null。
The 3D arc or null (if the three points are colinear).
Defined in
api.d.ts:7909
createBoundingBox2d
▸ createBoundingBox2d(minPoint
, maxPoint
): KBoundingBox2d
创建一个KBoundingBox2d对象。
Creates an instance of KBoundingBox2d.
Parameters
Name | Type | Description |
---|---|---|
minPoint | KPoint2d | 二维包围盒的左下角点。 The minimum point of the bounding box. |
maxPoint | KPoint2d | 二维包围盒的右上顶点。 The maximum point of the bounding box. |
Returns
包围盒。
The bounding box.
Defined in
api.d.ts:7299
createBoundingBox3d
▸ createBoundingBox3d(minPoint
, maxPoint
): KBoundingBox3d
创建一个KBoundingBox3d对象。
Creates an instance of KBoundingBox3d.
Parameters
Name | Type | Description |
---|---|---|
minPoint | KPoint3d | 三维包围盒的左下角点。 The minimum point of the bounding box. |
maxPoint | KPoint3d | 三维包围盒的右上顶点。 The maximum point of the bounding box. |
Returns
包围盒。
The bounding box.
Defined in
api.d.ts:7317
createCircle2dByCenterAndPoint
▸ createCircle2dByCenterAndPoint(center
, pointOnCircle
): KCircle2d
通过圆心和圆上一点创建一个二维空间的圆。
Create a 2d circle by the origin of the circle and a point on the circle.
Parameters
Name | Type | Description |
---|---|---|
center | KPoint2d | 圆心。 The origin of the circle. |
pointOnCircle | KPoint2d | 圆上一点。 A point on the circle. |
Returns
返回一个圆,也可能是null(当两点重合时)。
The 2D circle or null if the two points overlap.
Defined in
api.d.ts:8015
createCircle2dByCenterAndRadius
▸ createCircle2dByCenterAndRadius(center
, radius
): KCircle2d
通过圆心和半径创建一个二维空间的圆。
Create a 2d circle by the origin and radius.
Parameters
Name | Type | Description |
---|---|---|
center | KPoint2d | 圆心。 Origin of the circle. |
radius | number | 半径。 Radius of the circle. |
Returns
返回一个圆。
The 2D circle.
Defined in
api.d.ts:8033
createCircle2dByThreePoints
▸ createCircle2dByThreePoints(startPoint
, midPoint
, endPoint
): KCircle2d
通过三点来创建一圆。
Create an circle by input three points.
Parameters
Name | Type | Description |
---|---|---|
startPoint | KPoint2d | 圆上第一个点。 The start point of the 2D circle. |
midPoint | KPoint2d | 圆上第二个点。 The middle point of the 2D circle. |
endPoint | KPoint2d | 圆上第三个点。 The end point of the 2D circle. |
Returns
返回一个圆,也可能是null(当三点共线时)。
The 2D circle or null (if the three points are colinear).
Defined in
api.d.ts:7997
createCircle3dByCenterNormalRadius
▸ createCircle3dByCenterNormalRadius(center
, normal
, radius
, xDir?
): KCircle3d
通过圆心、半径和法向来创建圆。 注意:创建的圆围绕着·法向时逆时针的。
Create an circle by center, normal, radius. NOTE: the created arc is always counter-clockwise around the normal.
Parameters
Name | Type | Description |
---|---|---|
center | KPoint3d | 圆心。 The center point of the 3D circle. |
normal | KVector3d | 法向。 The normal of the 3D circle. |
radius | number | 半径。 The radius of the 3D circle. |
xDir? | KVector3d | 圆的X轴方向(可选参数)。 The X direction of the local coordinate system of the circle. |
Returns
圆。
The 3D circle.
Defined in
api.d.ts:8083
createCircle3dByLCSRadius
▸ createCircle3dByLCSRadius(center
, xDir
, yDir
, radius
): KCircle3d
通过圆心、X轴方向、Y轴方向和半径来创建圆。
Create an circle by origin, direction of X axis, direction of Y axis and radius.
Parameters
Name | Type | Description |
---|---|---|
center | KPoint3d | 圆心。 The origin of the 3D circle. |
xDir | KVector3d | 圆的X轴方向。 The direction of the X axis of the circle. |
yDir | KVector3d | 圆的Y轴方向。 The direction of the Y axis of the circle. |
radius | number | 半径。 The radius of the 3D circle. |
Returns
圆。
The 3D circle.
Defined in
api.d.ts:8109
createCircle3dByThreePoints
▸ createCircle3dByThreePoints(startPoint
, midPoint
, endPoint
): KCircle3d
通过三点来创建一圆。
Create an circle by input three points.
Parameters
Name | Type | Description |
---|---|---|
startPoint | KPoint3d | 圆上第一个点。 The start point of the 3D circle. |
midPoint | KPoint3d | 圆上第二个点。 The middle point of the 3D circle. |
endPoint | KPoint3d | 圆上第三个点。 The end point of the 3D circle. |
Returns
返回一个圆,也可能是null(当三点共线时)。
The 3D circle or null (if the three points are colinear).
Defined in
api.d.ts:8055
createEllipticalArc2dByStartEndParams
▸ createEllipticalArc2dByStartEndParams(center
, xDirection
, majorRadius
, minorRadius
, startParam
, endParam
, isCCW
): KEllipticalArc2d
通过椭圆心、椭圆长轴方向、椭圆长轴半径、椭圆短轴半径、圆弧起点和末点来创建圆弧。
Create an elliptical arc by center, x direction, major radius, minor radius, start and end points.
Parameters
Name | Type | Description |
---|---|---|
center | KPoint2d | 椭圆圆心。 The center point of the 2D elliptical arc. |
xDirection | KVector2d | 椭圆长轴方向(X 方向)。 X direction of the 2D elliptical arc. |
majorRadius | number | 椭圆长轴半径。 Major radius of the elliptical arc. |
minorRadius | number | 椭圆短轴半径。 Minor radius of the elliptical arc. |
startParam | number | 椭圆弧的起点参数。 The start parameter of the 2D arc. |
endParam | number | 椭圆弧的终点参数。 The end parameter of the 2D arc. |
isCCW | boolean | 圆弧是否是逆时针方向。 如果圆弧是逆时针方向,则表示圆弧是圆上从起点开始沿逆时针方向到达终点的那一段圆,反之则表示圆上另外一侧的一段。 Whether the 2d arc is counter clockwise from startPoint to endPoint. True means the counter clockwise segment of the circle from startPoint to endPoint. False means the clockwise segment of the circle from startPoint to endPoint. |
Returns
二维椭圆弧。
The 2D arc.
Defined in
api.d.ts:7670
createEllipticalArc2dByStartEndPoints
▸ createEllipticalArc2dByStartEndPoints(center
, xDirection
, majorRadius
, minorRadius
, startPoint
, endPoint
, isCCW
): KEllipticalArc2d
通过椭圆心、椭圆长轴方向、椭圆长轴半径、椭圆短轴半径、圆弧起点和末点来创建圆弧。
Create an elliptical arc by center, x direction, major radius, minor radius, start and end points.
Parameters
Name | Type | Description |
---|---|---|
center | KPoint2d | 椭圆圆心。 The center point of the 2D elliptical arc. |
xDirection | KVector2d | 椭圆长轴方向(X 方向)。 X direction of the 2D elliptical arc. |
majorRadius | number | 椭圆长轴半径。 Major radius of the elliptical arc. |
minorRadius | number | 椭圆短轴半径。 Minor radius of the elliptical arc. |
startPoint | KPoint2d | 椭圆弧的起点,需要注意,该点需要在圆弧上。 The start point of the 2D arc. The caller need to make sure it's on the arc. |
endPoint | KPoint2d | 椭圆弧的末点,需要注意,该点需要在圆弧上。 The end point of the 2D arc. The caller need to make sure it's on the arc. |
isCCW | boolean | 圆弧是否是逆时针方向。 如果圆弧是逆时针方向,则表示圆弧是圆上从起点开始沿逆时针方向到达终点的那一段圆,反之则表示圆上另外一侧的一段。 Whether the 2d arc is counter clockwise from startPoint to endPoint. True means the counter clockwise segment of the circle from startPoint to endPoint. False means the clockwise segment of the circle from startPoint to endPoint. |
Returns
二维椭圆弧。
The 2D arc.
Defined in
api.d.ts:7628
createEuler
▸ createEuler(x?
, y?
, z?
, order?
): KEuler
创建一个表示旋转变换的欧拉角对象。
Create an Euler object which represents a rotational transformation.
Parameters
Name | Type | Description |
---|---|---|
x? | number | 绕x轴旋转角度,默认为0。 The rotate angle around x axis in radians. Dafault value is 0. |
y? | number | 绕y轴旋转角度,默认为0。 The rotate angle around y axis in radians. Dafault value is 0. |
z? | number | 绕z轴旋转角度,默认为0。 The rotate angle around z axis in radians. Dafault value is 0. |
order? | KEulerOrder | 绕x,y,z轴旋转的顺序,包括XYZ,YZX, ZXY, XZY, YXZ, ZYX,默认XYZ。 The order in which to apply the rotations, including XYZ,YZX, ZXY, XZY, YXZ, ZYX. Dafault value is XYZ. |
Returns
欧拉角
The euler defining the rotations.
Defined in
api.d.ts:8530
createGeomFace2d
▸ createGeomFace2d(contour
, holes?
): KGeomFace2d
通过内轮廓和外轮廓创建面。 注意:需要保证内轮廓与外轮廓方向相反。
Create a face2d by contour and holes. NOTE: the caller need to make sure the contour and holes have opposite ccw direction
Parameters
Name | Type | Description |
---|---|---|
contour | KGeomLoop2d | 面的外轮廓。 The contour (outer loop) of the face |
holes? | KGeomLoop2d [] | 面的内轮廓。 The holes (inner loops) of the face. |
Returns
返回二维面对象。
Return a face2d object.
Defined in
api.d.ts:8232
createGeomLoop2d
▸ createGeomLoop2d(curves
): KGeomLoop2d
通过轮廓线数组来创建二维环。 需要保证轮廓线数组首尾相连。
Create a loop2d by bounded curves. The caller need to make sure the input curves are connected tail to head and closed.
Parameters
Name | Type | Description |
---|---|---|
curves | KBoundedCurve2d [] | 输入轮廓线数组。 The input curves of a loop2d. |
Returns
返回二维环对象。
Return a loop2d object.
Defined in
api.d.ts:8198
createGeomLoop2dByPoints
▸ createGeomLoop2dByPoints(points
): KGeomLoop2d
通过点集合来创建二维loop。loop将只含线段。
Create a loop2d by points, the result loop contains only line segments.
Parameters
Name | Type | Description |
---|---|---|
points | KPoint2d [] | 环的顶点集合。 The vertex points of the loop. |
Returns
返回二维环对象。
Return a loop2d object.
Defined in
api.d.ts:8212
createIdentityMatrix3
▸ createIdentityMatrix3(): KMatrix3
创建一个单位矩阵。
Create an identity matrix.
Returns
单位矩阵。
The identity matrix.
Defined in
api.d.ts:7327
createIdentityMatrix4
▸ createIdentityMatrix4(): KMatrix4
创建四阶单位矩阵。
Create an identity matrix.
Returns
单位矩阵。
The identity matrix.
Defined in
api.d.ts:7393
createInterval
▸ createInterval(start
, end
): KInterval
根据起点和终点创建一个区间。
Create an interval by start and end points.
Parameters
Name | Type | Description |
---|---|---|
start | number | 输入区间起点。 The input start. |
end | number | 输入区间终点。 The input end. |
Returns
返回区间。
Return the interval.
Defined in
api.d.ts:8610
createIntervalFromValues
▸ createIntervalFromValues(values
, numTol
): KInterval
创建一个包含输入数值的最小区间。
Create an union interval from the input values.
Parameters
Name | Type | Description |
---|---|---|
values | number [] | 用于创建区间的数值。 The values has to be contained by the interval. |
numTol | number | 用于比较数值大小的容差。 A tolerance for number comparison. |
Returns
一个区间。
An interval contains all the values.
Defined in
api.d.ts:8638
createInvalidInterval
▸ createInvalidInterval(): KInterval
创建一个默认的非法区间。
Create a default invalid interval.
Returns
返回区间。
Return interval.
Defined in
api.d.ts:8620
createLine2d
▸ createLine2d(point
, direction
): KLine2d
创建一个KLine2d对象。
Creates an instance of KLine2d.
Parameters
Name | Type | Description |
---|---|---|
point | KPoint2d | 二维直线的原点。 The origin point of the 2D line. |
direction | KVector2d | 二维直线的方向。 The direction of the 2D line. |
Returns
二维直线。
The 2D line.
Defined in
api.d.ts:7505
createLine3d
▸ createLine3d(point
, direction
): KLine3d
创建一个KLine3d对象。
Creates an instance of KLine3d.
Parameters
Name | Type | Description |
---|---|---|
point | KPoint3d | 三维直线的原点。 The origin point of the 3D line. |
direction | KVector3d | 三维直线的方向。 The direction of the 3D line. |
Returns
三维直线。
The 3D line.
Defined in
api.d.ts:7523
createLineSegment2d
▸ createLineSegment2d(startPoint
, endPoint
): KLineSegment2d
创建一个KLineSegment2d对象。
Creates an instance KLineSegment2d
Parameters
Name | Type | Description |
---|---|---|
startPoint | KPoint2d | 二维线段的起点。 The start point of the 2D line segment. |
endPoint | KPoint2d | 二维线段的终点。 The end point of the 2D line segment. |
Returns
二维线段。
The 2D line segment.
Defined in
api.d.ts:7541
createLineSegment3d
▸ createLineSegment3d(startPoint
, endPoint
): KLineSegment3d
创建一个KLineSegment3d对象。
Creates an instance KLineSegment3d
Parameters
Name | Type | Description |
---|---|---|
startPoint | KPoint3d | 二维线段的起点。 The start point of the 3D line segment. |
endPoint | KPoint3d | 二维线段的终点。 The end point of the 3D line segment. |
Returns
三维线段。
The 3D line segment.
Defined in
api.d.ts:7559
createNurbsCurve2d
▸ createNurbsCurve2d(degree
, knots
, controlPoints
, weights
): KNurbsCurve2d
通过给定阶数、节点向量、控制点以及权重构建一条非均匀有理样条曲线。
Create a nurbs curve by degree, knots, control points and weights.
Parameters
Name | Type | Description |
---|---|---|
degree | number | 阶数。 The degree of the 2d nurbs curve. |
knots | number [] | 节点向量。 The knots of the 2d nurbs curve. |
controlPoints | KPoint2d [] | 控制顶点。 The control points of the 2d nurbs curve. |
weights | number [] | 权重。 the weights of the 2d nurbs curve. |
Returns
二维非均匀有理样条曲线。
The 2D nurbs curve.
Defined in
api.d.ts:8135
createPlaneByPointNormal
▸ createPlaneByPointNormal(point
, normal
, xDirection?
): KPlane
通过一个点和一个法向来创建平面。
Create a plane from a point and normal.
Parameters
Name | Type | Description |
---|---|---|
point | KPoint3d | 平面的原点。 The origin point of the plane. |
normal | KVector3d | 平面的法向。 The normal of the plane. |
xDirection? | KVector3d | 平面的x方向,该参数为可选参数,如给出了,则需要保证是不平行于法向。 Candidate x direction of the plane, if it's not null, the caller need to make sure it's not parallel to normal. |
Returns
三维平面。
The 3D plane.
Defined in
api.d.ts:8182
createPlaneByThreePoints
▸ createPlaneByThreePoints(point1
, point2
, point3
): KPlane
通过三点创建一个平面。 平面的原点时第一个点,平面的法向是p1到p2向量与p1到p3向量的叉乘,x轴是p1到p2向量的单位向量。
Create a plane from three points. The generated plane's origin is point1, the normal is the cross production of (point2 - point1) and (point3 - point1), the x axis is (point2 - point1).normalize().
Parameters
Name | Type | Description |
---|---|---|
point1 | KPoint3d | 输入点p1。 The input p1. |
point2 | KPoint3d | 输入点p2。 The input p2. |
point3 | KPoint3d | 输入点p3。 The input p3. |
Returns
由三点构造的平面,若三点共线则范围null。
The plane constructed by the three points or null (if three points are colinear).
Defined in
api.d.ts:8160
createPoint2d
▸ createPoint2d(x
, y
): KPoint2d
创建一个kpoint2d对象。
Creates an instance of KPoint2d.
Parameters
Name | Type | Description |
---|---|---|
x | number | 二维点的x坐标。 The x value of the 2D point. |
y | number | 二维点的y坐标。 The y value of the 2D point. |
Returns
二维点。
The 2D point.
Defined in
api.d.ts:7219
createPoint3d
▸ createPoint3d(x
, y
, z
): KPoint3d
创建一个kpoint3d对象。
Creates an instance of KPoint3d.
Parameters
Name | Type | Description |
---|---|---|
x | number | 三维点的x坐标。 The x value of the 3D point. |
y | number | 三维点的y坐标。 The y value of the 3D point. |
z | number | 三维点的z坐标。 The z value of the 3D point. |
Returns
三维点。
The 3D point.
Defined in
api.d.ts:7241
createPolylineCurve2d
▸ createPolylineCurve2d(points
): KPolylineCurve2d
通过点列创建一个二维折线段。
Create a 2D polyline by a list of points.
Parameters
Name | Type | Description |
---|---|---|
points | KPoint2d [] | 折线段的顶点序列。 The vertice of the polyline. |
Returns
二维折线段。
The 2D polyline.
Defined in
api.d.ts:7573
createPolylineCurve3d
▸ createPolylineCurve3d(points
): KPolylineCurve3d
通过点列创建一个三维折线段。
Create a 3D polyline by a list of points.
Parameters
Name | Type | Description |
---|---|---|
points | KPoint3d [] | 折线段的顶点序列。 The vertice of the polyline. |
Returns
三维折线段。
The 3D polyline.
Defined in
api.d.ts:7587
createQuaternion
▸ createQuaternion(x?
, y?
, z?
, w?
): KQuaternion
创建一个表示旋转变换的四元数对象。
Create a quaternion which represents a rotational transformation.
Parameters
Name | Type | Description |
---|---|---|
x? | number | 四元数的x虚部,默认为0。 The quaternion's x value, use 0 by default. |
y? | number | 四元数的y虚部,默认为0。 The quaternion's y value, use 0 by default. |
z? | number | 四元数的z虚部,默认为0。 The quaternion's z value, use 0 by default. |
w? | number | 四元数的w实部, 默认为1。 The quaternion's w value, use 1 by default. |
Returns
四元数
The quaternion defining the rotations.
Defined in
api.d.ts:8556
createRotateMatrix3
▸ createRotateMatrix3(angle
, center
): KMatrix3
创建围绕轴旋转的变换矩阵。 旋转轴由一点定义,旋转角度由弧度值给出。
Create an transform matrix that does rotation about an axis. The axis is defined by a point. The angle is given in radians.
Parameters
Name | Type | Description |
---|---|---|
angle | number | 旋转角弧度。 The angle of rotation in radians. |
center | KPoint2d | 定义旋转轴的点。 The point to define the axis. |
Returns
旋转变换矩阵。
The rotation transform matrix.
Defined in
api.d.ts:7365
createRotateMatrix4
▸ createRotateMatrix4(angle
, a
, center
): KMatrix4
创建围绕轴旋转的变换矩阵。 旋转轴由一点和一向量定义,旋转角度由弧度值给出。
Create an transform matrix that does rotation about an axis. The axis is defined by a point and a vector. The angle is given in radians.
Parameters
Name | Type | Description |
---|---|---|
angle | number | 旋转角弧度。 The angle of rotation in radians. |
a | KVector3d | 用于定义旋转轴的向量。 The vector to define the axis. |
center | KPoint3d | 用于定义旋转轴的点。 The point to define the axis. |
Returns
旋转矩阵。
The rotation transform matrix.
Defined in
api.d.ts:7439
createRotateMatrix4FromEuler
▸ createRotateMatrix4FromEuler(euler
): KMatrix4
创建一个由欧拉角定义的旋转变换矩阵。
Create a rotation matrix by the euler angles.
Parameters
Name | Type | Description |
---|---|---|
euler | KEuler | 欧拉角和顺序 The euler angles and order |
Returns
返回旋转矩阵。
Return a rotation matrix.
Defined in
api.d.ts:8486
createRotateMatrix4FromQuaternion
▸ createRotateMatrix4FromQuaternion(q
): KMatrix4
创建一个由四元数定义的旋转变换矩阵。
Create a rotation matrix by the quaternion.
Parameters
Name | Type | Description |
---|---|---|
q | KQuaternion | 四元数 The quaternion defining the rotations. |
Returns
返回旋转矩阵。
Return a rotation matrix.
Defined in
api.d.ts:8500
createScaleMatrix3
▸ createScaleMatrix3(x
, y
): KMatrix3
创建缩放矩阵。
Create a matrix as scale transform.
Parameters
Name | Type | Description |
---|---|---|
x | number | x方向缩放分量。 The amount to scale in the X axis. |
y | number | y方向缩放分量。 The amount to scale in the Y axis. |
Returns
缩放矩阵。
The scale transform matrix.
Defined in
api.d.ts:7383
createScaleMatrix4
▸ createScaleMatrix4(x
, y
, z
): KMatrix4
创建缩放矩阵。
Create a matrix as scale transform.
Parameters
Name | Type | Description |
---|---|---|
x | number | x方向缩放分量。 The amount to scale in the X axis. |
y | number | y方向缩放分量。 The amount to scale in the Y axis. |
z | number | z方向缩放分量。 The amount to scale in the Z axis. |
Returns
缩放矩阵。
The scale transform matrix.
Defined in
api.d.ts:7461
createTranslationMatrix3
▸ createTranslationMatrix3(x
, y
): KMatrix3
创建平移变换矩阵。
Create an translation transform matrix.
Parameters
Name | Type | Description |
---|---|---|
x | number | x方向平移分量。 The amount to translate in the X axis. |
y | number | y方向平移分量。 The amount to translate in the Y axis. |
Returns
平移变换矩阵。
The translation transform matrix.
Defined in
api.d.ts:7345
createTranslationMatrix4
▸ createTranslationMatrix4(x
, y
, z
): KMatrix4
创建平移变换矩阵。
Create an translation transform matrix.
Parameters
Name | Type | Description |
---|---|---|
x | number | x方向平移分量。 The amount to translate in the X axis. |
y | number | y方向平移分量。 The amount to translate in the Y axis. |
z | number | z方向平移分量。 The amount to translate in the Z axis. |
Returns
平移变换矩阵。
The translation transform matrix.
Defined in
api.d.ts:7415
createVector2d
▸ createVector2d(x
, y
): KVector2d
创建一个kVector2d对象。
Creates an instance of KVector2d
Parameters
Name | Type | Description |
---|---|---|
x | number | 二维向量的x分量。 The x value of the 2D vector |
y | number | 二维向量的y分量。 The y value of the 2D vector |
Returns
二维向量。
The 2D vector.
Defined in
api.d.ts:7259
createVector3d
▸ createVector3d(x
, y
, z
): KVector3d
创建一个kVector3d对象。
Creates an instance of KVector3d.
Parameters
Name | Type | Description |
---|---|---|
x | number | 三维向量的x分量。 The x value of the 3D vector. |
y | number | 三维向量的y分量。 The y value of the 3D vector. |
z | number | 三维向量的z分量。 The z value of the 3D vector. |
Returns
三维向量。
The 3D vector.
Defined in
api.d.ts:7281
curve2dsFromJson
▸ curve2dsFromJson(jsonString
): KCurve2d
[]
从Json string中读取curve2d数据并创建相应对象。 加这个接口函数的目的是方便内部写测试用例来测试math apaas接口。 Note: 我们永远不应该加XXXToJson()这样的apaas接口。
Read curve2d data and create corresponding curve2d object from the Json string. The only purpose of adding this api is to add internal test cases more conveniently. Note: We will never add Json writing api like XXXToJson().
Parameters
Name | Type |
---|---|
jsonString | string |
Returns
KCurve2d
[]
返回二维曲线对象集合。
Return curve2d objects.
Defined in
api.d.ts:8716
curveIntersectCurve
▸ curveIntersectCurve(curve1
, curve2
, tolerance?
): KCurvesIntersectRet
[]
对两条曲线求交。 如果两曲线完全重合,该方法返回的是空数组。 所以areCurvesTotallyOverlap方法需要在使用该方法之前使用。 对于部分重合的情况,结果是返回重叠的部分的两个端点。
Get the intersection of curve and curve. The method returns an empty array for two completely overlap curves, so the function "areCurvesTotallyOverlap" should be called before calling the interface to determine whether it is completely overlap or not. For two bounding curves, if there is a partial overlap, the return result is two endpoints of the overlap segment.
Parameters
Name | Type | Description |
---|---|---|
curve1 | KCurve3d | 第一条曲线。 The first curve. |
curve2 | KCurve3d | 第二条曲线。 The second curve. |
tolerance? | number | 特定容差,默认值是1e-6。 The specified tolerance.The default value is 1e-6. |
Returns
返回是一个KCurvesIntersectRet数组,包含交点信息和重合信息。
The array of KCurvesIntersectRet include status of overlap, intersection point.
Defined in
api.d.ts:8305
curveIntersectSurface
▸ curveIntersectSurface(curve
, surface
, tolerance?
): KCurveSurfaceIntersectRet
[]
曲线与曲面求交。
Get the intersection of a curve and a surface.
Parameters
Name | Type | Description |
---|---|---|
curve | KCurve3d | 求交的曲线。 The curve to intersect. |
surface | KSurface | 求交的曲面。 The surface to intersect. |
tolerance? | number | 特定容差,默认值是1e-6。 The specified tolerance.The default value is 1e-6. |
Returns
返回是一个KCurveSurfaceIntersectRet数组,包含交点信息或者交线信息或重合信息。
The array of KCurveSurfaceIntersectRet include intersect type, intersection point or curve.
Defined in
api.d.ts:8327
faces2dBoolean
▸ faces2dBoolean(faces1
, faces2
, type
): KFaceBooleanRet
对两组面进行布尔操作。
Calculate the boolean result between blank faces and tool faces.
Parameters
Name | Type | Description |
---|---|---|
faces1 | KFace2d [] | 第一组面。 the blank faces |
faces2 | KFace2d [] | 第二组面。 the tool faces |
type | KFaceBooleanType | 布尔操作类型。 the boolean type |
Returns
返回KFaceBooleanRet,包含布尔结果的面数组和布尔操作是否成功的状态。
The KFaceBooleanRet includes result faces and success status.
Defined in
api.d.ts:8472
intersectIntervals
▸ intersectIntervals(intervals1
, intervals2
): KInterval
[]
求出两组区间的所有重叠部分。
Get the common parts of the two groups of interval.
Parameters
Name | Type | Description |
---|---|---|
intervals1 | KInterval [] | 输入区间集合1。 The input first interval array. |
intervals2 | KInterval [] | 输入区间集合2。 The input second interval array. |
Returns
返回两组区间的所有重叠部分。
Return the common parts of the two groups of interval.
Defined in
api.d.ts:8670
loop2DInLoop2D
▸ loop2DInLoop2D(checkLoop
, baseLoop
, bIncludeOn?
, tolerance?
): boolean
判断环是否落在另一环内。
Check loop2d is inside of base loop2d.
Parameters
Name | Type | Description |
---|---|---|
checkLoop | KLoop2d | 被判断的环。 The check loop2d. |
baseLoop | KLoop2d | 另一个环。 The base loop2d. |
bIncludeOn? | boolean | 结果是否包含两环有重叠区域的情况。 Result include check loop2d is overlap with base loop2d. |
tolerance? | number | 特定容差,默认值是1e-6。 The specified tolerance.The default value is 1e-6. |
Returns
boolean
如果位于环内则返回true。
Return true if inside, otherwise return false.
Defined in
api.d.ts:8428
offsetPath2dWithDistances
▸ offsetPath2dWithDistances(path
, deltas
, disTol?
, cosTol?
): KPath2dOffsetRet
偏移一组有序的2d曲线,每条曲线的偏移值单独设置 若 delta 大于零,曲线偏移方向为左边;若 delta 小于零,曲线偏移方向为右边 例如:考虑一条逆时针绕向的 path,若 delta 皆大于零,则 path 将向外扩张;若 delta 皆小于零,则 path 将向内收缩
Offset a 2d path with different distances. If the delta > 0, the path will be offset at right side, else if delta < 0, the path will be offset at left side. For example: A CCW path, if delta > 0, the path will be enlarged. if delta < 0, the path will be shrinked.
Parameters
Name | Type | Description |
---|---|---|
path | KBoundedCurve2d [] | 输入一组有序的2d曲线集合。 Input 2d curves in order. |
deltas | number [] | 输入2d曲线集合对应的偏移量。 Input each 2d curve offset delta. |
disTol? | number | 输入距离容差,默认1.0e-6。 Input distance tolerance, use 1.0e-6 by default. |
cosTol? | number | 输入角度容差,默认1.0e-6。 Input cosine tolerance, use 1.0e-6 by default. |
Returns
返回偏移结果。
Return offset path result.
Defined in
api.d.ts:8699
planeIntersectPlane
▸ planeIntersectPlane(plane1
, plane2
, tolerance?
): KLine3d
两平面求交。
Get the intersection of two planes.
Parameters
Name | Type | Description |
---|---|---|
plane1 | KPlane | 第一个平面。 The first plane. |
plane2 | KPlane | 第二个平面。 The second plane. |
tolerance? | number | 特定容差,默认值是1e-6。 The specified tolerance.The default value is 1e-6. |
Returns
返回一条直线,也有可能返回null(当两个平面不相交时)。
A line where the planes intersect if successful. Returns null if the planes do not intersect.
Defined in
api.d.ts:8349
pointInFace2D
▸ pointInFace2D(point
, faceLoops
, tolerance?
): KPtInLoopResult
以特定容差判断点是否在面中。
Check whether a point is in loops or not with specified tolerance.
Parameters
Name | Type | Description |
---|---|---|
point | KPoint2d | 要判断的点。 The point to compare with the faceLoops. |
faceLoops | KFace2d | 面是由环数组构成。由二维轮廓线集合组成的环,需要保证环的每一个的末点与下一个的起点时相同的,最后一个的末点与第一个的起点时相同的。 还必须确保环没有自相交。 face's loops composed by bounded curve2ds, the first bounded curve array is outer loop and other is inner loop. The caller need to make sure each curve's end point is equal to next one's start point, and last curve's end point is equal to the first one's start point. The caller also need to make sure the bounded curve array is not self-intersected. |
tolerance? | number | 特定容差,默认值是1e-6。 The specified tolerance.The default value is 1e-6. |
Returns
返回KPtInLoopResult,包含点与环的位置关系信息。
The KPtInLoopResult include intersect type, etc.
Defined in
api.d.ts:8402
pointInLoop2D
▸ pointInLoop2D(point
, loop
, tolerance?
): KPtInLoopResult
以特定容差检查一点是否在环中。
Check whether a point is in a loop or not with specified tolerance.
Parameters
Name | Type | Description |
---|---|---|
point | KPoint2d | 要判断的点。 The point to compare with the loop. |
loop | KLoop2d | 由二维轮廓线集合组成的环,需要保证环的每一个的末点与下一个的起点时相同的,最后一个的末点与第一个的起点时相同的。 还必须确保环没有自相交。 The loop composed by bounded curve2ds. The caller need to make sure each curve's end point is equal to next one's start point, and last curve's end point is equal to the first one's start point. The caller also need to make sure the loop is not self-intersected. |
tolerance? | number | 特定容差,默认值是1e-6。 The specified tolerance.The default value is 1e-6. |
Returns
返回KPtInLoopResult,包含点与环的位置关系信息。
The KPtInLoopResult include intersect type, etc.
Defined in
api.d.ts:8376
slerpFlatQuaternion
▸ slerpFlatQuaternion(q1
, offset1
, q2
, offset2
, t
): number
[]
不同于KQuaternion的slerp函数,这个函数直接基于展平的数组做球面线性插值。
这里我们没有像Math2的Quaternion.slerpFlat函数那样把destination array当作参数传入,让slerp结果直接写到 destination array当中,这是因为如果经过了quickjs虚拟机,那样写入并不能同时改变插件侧的数组对象,修改的 仅仅是math-apaas-impl所在的应用程序侧的数组对象。反过来应用程序“传递”给插件的数组对象,插件可以修改成功, 但是再传回应用程序时,则还是那个没有被改动过的应用程序侧的数组对象。quickjs不能监听对数组的修改去同步两边对应 的数组数据。
Do a slerp operates directly on flat arrays of numbers.
Parameters
Name | Type | Description |
---|---|---|
q1 | number [] | 输入第一个四元数数组。 The array representation of the first quaternion. |
offset1 | number | 输入第一个四元数数组的起始索引。 The offset index in the array where the first quanternion starts. |
q2 | number [] | 输入第二个四元数数组。 The array representation of the second quaternion. |
offset2 | number | 输入第二个四元数数组的起始索引。 The offset index in the array where the second quanternion starts. |
t | number | 输入插值比例。 Normalized interpolation factor (between 0 and 1). |
Returns
number
[]
返回数组,存储插值后的四元数[x, y, z, w]。
The array representation of the result quaternion.
Defined in
api.d.ts:8592
uniteIntervals
▸ uniteIntervals(intervals
): KInterval
[]
对一组区间中重叠的区间进行合并简化。合并简化后的区间序列和原始区间序列覆盖相同的区域。
Simplify the intervals by uniting the intersected intervals.
Parameters
Name | Type | Description |
---|---|---|
intervals | KInterval [] | 输入区间集合。 The input interval array. |
Returns
返回合并简化后的区间集合。
Return the simplified intervals.
Defined in
api.d.ts:8652