Skip to main content

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

Methods

areCurvesOverlap

areCurvesOverlap(curve1, curve2, tolerance?): boolean

在特定容差下,检查两曲线是否有重合部分(包括完全重合)。

Get the overlap status of two curves, include totally and partial overlap.

Parameters

NameTypeDescription
curve1KCurve3d第一条曲线。 The first curve.
curve2KCurve3d第二条曲线。 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

NameTypeDescription
curve1KCurve3d第一条曲线。 The first curve.
curve2KCurve3d第二条曲线。 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

NameTypeDescription
checkCurveKBoundedCurve2d被判断的轮廓线。 The bounded curve to check.
baseLoopKLoop2d环。 The base loop2d.
tolerance?number特定容差,默认值是1e-6。 The specified tolerance.The default value is 1e-6.

Returns

KCurveInLoopType

返回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

NameTypeDescription
xKVector3d给定坐标系的x方向。 The x direction of the given coordinate system.
yKVector3d给定坐标系的y方向。 The y direction of the given coordinate system.
zKVector3d给定坐标系的z方向。 The z direction of the given coordinate system.
originKPoint3d给定坐标系的原点。 The origin of the given coordinate system.

Returns

KMatrix4

变换矩阵。

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

NameTypeDescription
centerKPoint2d圆心。 The center point of the 2D arc.
radiusnumber圆弧半径。 The radius of the 2D arc.
startAnglenumber圆弧的起始角度。 The start angle of the arc.
arcAnglenumber圆弧的角度。 正的圆弧角度值表示从圆弧起始角度沿逆时针方向转动这个角度为圆弧终点。 负的圆弧角度值表示从圆弧起始角度沿顺时针方向转动这个角度为圆弧终点。 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

KArc2d

二维圆弧。

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

NameTypeDescription
chordKLineSegment2d圆弧的弦。 The chord of the 2d arc.
signedBulgenumber圆弧的突起比例。 The bulge ratio of the arc.

Returns

KArc2d

圆弧。

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

NameTypeDescription
startKPoint2d圆弧起点。 The start point of the 2d arc.
endKPoint2d圆弧终点。 The end point of the 2d arc.
startTangentKVector2d圆弧起点的切向量(单位向量)。 切向量的方向决定了圆弧是逆时针的还是顺时针的。 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

KArc2d

圆弧。

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

NameTypeDescription
centerKPoint2d圆心。 The center point of the 2D arc.
radiusnumber圆弧半径。 The radius of the 2D arc.
startAnglenumber圆弧的起始角度。 The start angle of the arc.
endAnglenumber圆弧的终止角度。 The end angle of the arc.
isCCWboolean圆弧是否是逆时针方向。 如果圆弧是逆时针方向,则表示圆弧是圆上从起始角开始沿逆时针方向到达终止角的那一段圆,反之则表示圆上另外一侧的一段。 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

KArc2d

二维圆弧。

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

NameTypeDescription
centerKPoint2d圆心。 The center point of the 2D arc.
startPointKPoint2d圆弧的起点,需要注意,该点需要在圆弧上。 The startPoint point of the 2D arc. The caller need to make sure it's on the arc.
endPointKPoint2d圆弧的末点,需要注意,该点需要在圆弧上。 The end point of the 2D arc. The caller need to make sure it's on the arc.
isCCWboolean圆弧是否是逆时针方向。 如果圆弧是逆时针方向,则表示圆弧是圆上从起点开始沿逆时针方向到达终点的那一段圆,反之则表示圆上另外一侧的一段。 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

KArc2d

二维圆弧。

The 2D arc.

Defined in

api.d.ts:7721


createArc2dByThreePoints

createArc2dByThreePoints(startPoint, midPoint, endPoint): KArc2d

通过三个点创建一个圆弧。 Create an arc by input three points.

Parameters

NameTypeDescription
startPointKPoint2d圆弧的起点。 The start point of the 2D arc.
midPointKPoint2d圆弧的中点。 The middle point of the 2D arc.
endPointKPoint2d圆弧的末点。 The end point of the 2D arc.

Returns

KArc2d

返回一个圆弧或者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

NameTypeDescription
startPointKPoint2d圆弧的起点。 The startPoint point of the 2D arc.
endPointKPoint2d圆弧的终点。 The end point of the 2D arc.
radiusnumber圆弧半径。 如果半径小于起点和终点之间距离的一半,则取这个距离的一半。也就是圆弧会是经过起点和终点的一个半圆弧。 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.
isMinorArcboolean当值为true时,表示的是起点和终点之间小的那两段圆弧其中之一。当值为false时,表示的是起点和终点之间大的那两段圆弧其中之一。 true: minor arc; false: major arc
isCCWboolean圆弧是否是逆时针方向。 如果圆弧是逆时针方向,则表示圆弧是圆上从起点开始沿逆时针方向到达终点的那一段圆,反之则表示圆上另外一侧的一段。 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

KArc2d

圆弧。

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

NameTypeDescription
centerKPoint3d圆心。 The center point of the 3D arc.
normalKVector3d法向。 The normal of the 3D arc.
radiusnumber圆弧半径。 The radius of the 3D arc.
startPointKPoint3d圆弧的起点,需要注意,该点需要在圆弧上。 The startPoint point of the 3D arc. The caller need to make sure it's on the arc.
endPointKPoint3d圆弧的末点,需要注意,该点需要在圆弧上。 The end point of the 3D arc. The caller need to make sure it's on the arc.

Returns

KArc3d

三维圆弧。

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

NameTypeDescription
centerKPoint3d圆心。 The center point of the 3D arc.
xDirKVector3d圆弧局部标架的X轴方向。 X direction of the arc's local coordinate system, must be normalized.
yDirKVector3d圆弧局部标架的Y轴方向。 Y direction of the arc's local coordinate system, must be normalized.
radiusnumber圆弧半径。 The radius of the 3D arc.
startAnglenumber圆弧的起始角度。 The start angle of the arc, will be clamped to [0, 2PI).
endAnglenumber圆弧的终止角度。 The end angle of the arc, will be clamped to [0, 2PI).

Returns

KArc3d

三维圆弧。

The 3D arc.

Defined in

api.d.ts:7975


createArc3dByThreePoints

createArc3dByThreePoints(startPoint, midPoint, endPoint): KArc3d

通过三个点创建一个圆弧。 Create an arc by input three points.

Parameters

NameTypeDescription
startPointKPoint3d圆弧的起点。 The start point of the 3D arc.
midPointKPoint3d圆弧的中点。 The middle point of the 3D arc.
endPointKPoint3d圆弧的末点。 The end point of the 3D arc.

Returns

KArc3d

返回一个圆弧或者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

NameTypeDescription
minPointKPoint2d二维包围盒的左下角点。 The minimum point of the bounding box.
maxPointKPoint2d二维包围盒的右上顶点。 The maximum point of the bounding box.

Returns

KBoundingBox2d

包围盒。

The bounding box.

Defined in

api.d.ts:7299


createBoundingBox3d

createBoundingBox3d(minPoint, maxPoint): KBoundingBox3d

创建一个KBoundingBox3d对象。

Creates an instance of KBoundingBox3d.

Parameters

NameTypeDescription
minPointKPoint3d三维包围盒的左下角点。 The minimum point of the bounding box.
maxPointKPoint3d三维包围盒的右上顶点。 The maximum point of the bounding box.

Returns

KBoundingBox3d

包围盒。

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

NameTypeDescription
centerKPoint2d圆心。 The origin of the circle.
pointOnCircleKPoint2d圆上一点。 A point on the circle.

Returns

KCircle2d

返回一个圆,也可能是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

NameTypeDescription
centerKPoint2d圆心。 Origin of the circle.
radiusnumber半径。 Radius of the circle.

Returns

KCircle2d

返回一个圆。

The 2D circle.

Defined in

api.d.ts:8033


createCircle2dByThreePoints

createCircle2dByThreePoints(startPoint, midPoint, endPoint): KCircle2d

通过三点来创建一圆。

Create an circle by input three points.

Parameters

NameTypeDescription
startPointKPoint2d圆上第一个点。 The start point of the 2D circle.
midPointKPoint2d圆上第二个点。 The middle point of the 2D circle.
endPointKPoint2d圆上第三个点。 The end point of the 2D circle.

Returns

KCircle2d

返回一个圆,也可能是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

NameTypeDescription
centerKPoint3d圆心。 The center point of the 3D circle.
normalKVector3d法向。 The normal of the 3D circle.
radiusnumber半径。 The radius of the 3D circle.
xDir?KVector3d圆的X轴方向(可选参数)。 The X direction of the local coordinate system of the circle.

Returns

KCircle3d

圆。

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

NameTypeDescription
centerKPoint3d圆心。 The origin of the 3D circle.
xDirKVector3d圆的X轴方向。 The direction of the X axis of the circle.
yDirKVector3d圆的Y轴方向。 The direction of the Y axis of the circle.
radiusnumber半径。 The radius of the 3D circle.

Returns

KCircle3d

圆。

The 3D circle.

Defined in

api.d.ts:8109


createCircle3dByThreePoints

createCircle3dByThreePoints(startPoint, midPoint, endPoint): KCircle3d

通过三点来创建一圆。

Create an circle by input three points.

Parameters

NameTypeDescription
startPointKPoint3d圆上第一个点。 The start point of the 3D circle.
midPointKPoint3d圆上第二个点。 The middle point of the 3D circle.
endPointKPoint3d圆上第三个点。 The end point of the 3D circle.

Returns

KCircle3d

返回一个圆,也可能是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

NameTypeDescription
centerKPoint2d椭圆圆心。 The center point of the 2D elliptical arc.
xDirectionKVector2d椭圆长轴方向(X 方向)。 X direction of the 2D elliptical arc.
majorRadiusnumber椭圆长轴半径。 Major radius of the elliptical arc.
minorRadiusnumber椭圆短轴半径。 Minor radius of the elliptical arc.
startParamnumber椭圆弧的起点参数。 The start parameter of the 2D arc.
endParamnumber椭圆弧的终点参数。 The end parameter of the 2D arc.
isCCWboolean圆弧是否是逆时针方向。 如果圆弧是逆时针方向,则表示圆弧是圆上从起点开始沿逆时针方向到达终点的那一段圆,反之则表示圆上另外一侧的一段。 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

KEllipticalArc2d

二维椭圆弧。

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

NameTypeDescription
centerKPoint2d椭圆圆心。 The center point of the 2D elliptical arc.
xDirectionKVector2d椭圆长轴方向(X 方向)。 X direction of the 2D elliptical arc.
majorRadiusnumber椭圆长轴半径。 Major radius of the elliptical arc.
minorRadiusnumber椭圆短轴半径。 Minor radius of the elliptical arc.
startPointKPoint2d椭圆弧的起点,需要注意,该点需要在圆弧上。 The start point of the 2D arc. The caller need to make sure it's on the arc.
endPointKPoint2d椭圆弧的末点,需要注意,该点需要在圆弧上。 The end point of the 2D arc. The caller need to make sure it's on the arc.
isCCWboolean圆弧是否是逆时针方向。 如果圆弧是逆时针方向,则表示圆弧是圆上从起点开始沿逆时针方向到达终点的那一段圆,反之则表示圆上另外一侧的一段。 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

KEllipticalArc2d

二维椭圆弧。

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

NameTypeDescription
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

KEuler

欧拉角

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

NameTypeDescription
contourKGeomLoop2d面的外轮廓。 The contour (outer loop) of the face
holes?KGeomLoop2d[]面的内轮廓。 The holes (inner loops) of the face.

Returns

KGeomFace2d

返回二维面对象。

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

NameTypeDescription
curvesKBoundedCurve2d[]输入轮廓线数组。 The input curves of a loop2d.

Returns

KGeomLoop2d

返回二维环对象。

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

NameTypeDescription
pointsKPoint2d[]环的顶点集合。 The vertex points of the loop.

Returns

KGeomLoop2d

返回二维环对象。

Return a loop2d object.

Defined in

api.d.ts:8212


createIdentityMatrix3

createIdentityMatrix3(): KMatrix3

创建一个单位矩阵。

Create an identity matrix.

Returns

KMatrix3

单位矩阵。

The identity matrix.

Defined in

api.d.ts:7327


createIdentityMatrix4

createIdentityMatrix4(): KMatrix4

创建四阶单位矩阵。

Create an identity matrix.

Returns

KMatrix4

单位矩阵。

The identity matrix.

Defined in

api.d.ts:7393


createInterval

createInterval(start, end): KInterval

根据起点和终点创建一个区间。

Create an interval by start and end points.

Parameters

NameTypeDescription
startnumber输入区间起点。 The input start.
endnumber输入区间终点。 The input end.

Returns

KInterval

返回区间。

Return the interval.

Defined in

api.d.ts:8610


createIntervalFromValues

createIntervalFromValues(values, numTol): KInterval

创建一个包含输入数值的最小区间。

Create an union interval from the input values.

Parameters

NameTypeDescription
valuesnumber[]用于创建区间的数值。 The values has to be contained by the interval.
numTolnumber用于比较数值大小的容差。 A tolerance for number comparison.

Returns

KInterval

一个区间。

An interval contains all the values.

Defined in

api.d.ts:8638


createInvalidInterval

createInvalidInterval(): KInterval

创建一个默认的非法区间。

Create a default invalid interval.

Returns

KInterval

返回区间。

Return interval.

Defined in

api.d.ts:8620


createLine2d

createLine2d(point, direction): KLine2d

创建一个KLine2d对象。

Creates an instance of KLine2d.

Parameters

NameTypeDescription
pointKPoint2d二维直线的原点。 The origin point of the 2D line.
directionKVector2d二维直线的方向。 The direction of the 2D line.

Returns

KLine2d

二维直线。

The 2D line.

Defined in

api.d.ts:7505


createLine3d

createLine3d(point, direction): KLine3d

创建一个KLine3d对象。

Creates an instance of KLine3d.

Parameters

NameTypeDescription
pointKPoint3d三维直线的原点。 The origin point of the 3D line.
directionKVector3d三维直线的方向。 The direction of the 3D line.

Returns

KLine3d

三维直线。

The 3D line.

Defined in

api.d.ts:7523


createLineSegment2d

createLineSegment2d(startPoint, endPoint): KLineSegment2d

创建一个KLineSegment2d对象。

Creates an instance KLineSegment2d

Parameters

NameTypeDescription
startPointKPoint2d二维线段的起点。 The start point of the 2D line segment.
endPointKPoint2d二维线段的终点。 The end point of the 2D line segment.

Returns

KLineSegment2d

二维线段。

The 2D line segment.

Defined in

api.d.ts:7541


createLineSegment3d

createLineSegment3d(startPoint, endPoint): KLineSegment3d

创建一个KLineSegment3d对象。

Creates an instance KLineSegment3d

Parameters

NameTypeDescription
startPointKPoint3d二维线段的起点。 The start point of the 3D line segment.
endPointKPoint3d二维线段的终点。 The end point of the 3D line segment.

Returns

KLineSegment3d

三维线段。

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

NameTypeDescription
degreenumber阶数。 The degree of the 2d nurbs curve.
knotsnumber[]节点向量。 The knots of the 2d nurbs curve.
controlPointsKPoint2d[]控制顶点。 The control points of the 2d nurbs curve.
weightsnumber[]权重。 the weights of the 2d nurbs curve.

Returns

KNurbsCurve2d

二维非均匀有理样条曲线。

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

NameTypeDescription
pointKPoint3d平面的原点。 The origin point of the plane.
normalKVector3d平面的法向。 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

KPlane

三维平面。

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

NameTypeDescription
point1KPoint3d输入点p1。 The input p1.
point2KPoint3d输入点p2。 The input p2.
point3KPoint3d输入点p3。 The input p3.

Returns

KPlane

由三点构造的平面,若三点共线则范围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

NameTypeDescription
xnumber二维点的x坐标。 The x value of the 2D point.
ynumber二维点的y坐标。 The y value of the 2D point.

Returns

KPoint2d

二维点。

The 2D point.

Defined in

api.d.ts:7219


createPoint3d

createPoint3d(x, y, z): KPoint3d

创建一个kpoint3d对象。

Creates an instance of KPoint3d.

Parameters

NameTypeDescription
xnumber三维点的x坐标。 The x value of the 3D point.
ynumber三维点的y坐标。 The y value of the 3D point.
znumber三维点的z坐标。 The z value of the 3D point.

Returns

KPoint3d

三维点。

The 3D point.

Defined in

api.d.ts:7241


createPolylineCurve2d

createPolylineCurve2d(points): KPolylineCurve2d

通过点列创建一个二维折线段。

Create a 2D polyline by a list of points.

Parameters

NameTypeDescription
pointsKPoint2d[]折线段的顶点序列。 The vertice of the polyline.

Returns

KPolylineCurve2d

二维折线段。

The 2D polyline.

Defined in

api.d.ts:7573


createPolylineCurve3d

createPolylineCurve3d(points): KPolylineCurve3d

通过点列创建一个三维折线段。

Create a 3D polyline by a list of points.

Parameters

NameTypeDescription
pointsKPoint3d[]折线段的顶点序列。 The vertice of the polyline.

Returns

KPolylineCurve3d

三维折线段。

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

NameTypeDescription
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

KQuaternion

四元数

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

NameTypeDescription
anglenumber旋转角弧度。 The angle of rotation in radians.
centerKPoint2d定义旋转轴的点。 The point to define the axis.

Returns

KMatrix3

旋转变换矩阵。

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

NameTypeDescription
anglenumber旋转角弧度。 The angle of rotation in radians.
aKVector3d用于定义旋转轴的向量。 The vector to define the axis.
centerKPoint3d用于定义旋转轴的点。 The point to define the axis.

Returns

KMatrix4

旋转矩阵。

The rotation transform matrix.

Defined in

api.d.ts:7439


createRotateMatrix4FromEuler

createRotateMatrix4FromEuler(euler): KMatrix4

创建一个由欧拉角定义的旋转变换矩阵。

Create a rotation matrix by the euler angles.

Parameters

NameTypeDescription
eulerKEuler欧拉角和顺序 The euler angles and order

Returns

KMatrix4

返回旋转矩阵。

Return a rotation matrix.

Defined in

api.d.ts:8486


createRotateMatrix4FromQuaternion

createRotateMatrix4FromQuaternion(q): KMatrix4

创建一个由四元数定义的旋转变换矩阵。

Create a rotation matrix by the quaternion.

Parameters

NameTypeDescription
qKQuaternion四元数 The quaternion defining the rotations.

Returns

KMatrix4

返回旋转矩阵。

Return a rotation matrix.

Defined in

api.d.ts:8500


createScaleMatrix3

createScaleMatrix3(x, y): KMatrix3

创建缩放矩阵。

Create a matrix as scale transform.

Parameters

NameTypeDescription
xnumberx方向缩放分量。 The amount to scale in the X axis.
ynumbery方向缩放分量。 The amount to scale in the Y axis.

Returns

KMatrix3

缩放矩阵。

The scale transform matrix.

Defined in

api.d.ts:7383


createScaleMatrix4

createScaleMatrix4(x, y, z): KMatrix4

创建缩放矩阵。

Create a matrix as scale transform.

Parameters

NameTypeDescription
xnumberx方向缩放分量。 The amount to scale in the X axis.
ynumbery方向缩放分量。 The amount to scale in the Y axis.
znumberz方向缩放分量。 The amount to scale in the Z axis.

Returns

KMatrix4

缩放矩阵。

The scale transform matrix.

Defined in

api.d.ts:7461


createTranslationMatrix3

createTranslationMatrix3(x, y): KMatrix3

创建平移变换矩阵。

Create an translation transform matrix.

Parameters

NameTypeDescription
xnumberx方向平移分量。 The amount to translate in the X axis.
ynumbery方向平移分量。 The amount to translate in the Y axis.

Returns

KMatrix3

平移变换矩阵。

The translation transform matrix.

Defined in

api.d.ts:7345


createTranslationMatrix4

createTranslationMatrix4(x, y, z): KMatrix4

创建平移变换矩阵。

Create an translation transform matrix.

Parameters

NameTypeDescription
xnumberx方向平移分量。 The amount to translate in the X axis.
ynumbery方向平移分量。 The amount to translate in the Y axis.
znumberz方向平移分量。 The amount to translate in the Z axis.

Returns

KMatrix4

平移变换矩阵。

The translation transform matrix.

Defined in

api.d.ts:7415


createVector2d

createVector2d(x, y): KVector2d

创建一个kVector2d对象。

Creates an instance of KVector2d

Parameters

NameTypeDescription
xnumber二维向量的x分量。 The x value of the 2D vector
ynumber二维向量的y分量。 The y value of the 2D vector

Returns

KVector2d

二维向量。

The 2D vector.

Defined in

api.d.ts:7259


createVector3d

createVector3d(x, y, z): KVector3d

创建一个kVector3d对象。

Creates an instance of KVector3d.

Parameters

NameTypeDescription
xnumber三维向量的x分量。 The x value of the 3D vector.
ynumber三维向量的y分量。 The y value of the 3D vector.
znumber三维向量的z分量。 The z value of the 3D vector.

Returns

KVector3d

三维向量。

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

NameType
jsonStringstring

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

NameTypeDescription
curve1KCurve3d第一条曲线。 The first curve.
curve2KCurve3d第二条曲线。 The second curve.
tolerance?number特定容差,默认值是1e-6。 The specified tolerance.The default value is 1e-6.

Returns

KCurvesIntersectRet[]

返回是一个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

NameTypeDescription
curveKCurve3d求交的曲线。 The curve to intersect.
surfaceKSurface求交的曲面。 The surface to intersect.
tolerance?number特定容差,默认值是1e-6。 The specified tolerance.The default value is 1e-6.

Returns

KCurveSurfaceIntersectRet[]

返回是一个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

NameTypeDescription
faces1KFace2d[]第一组面。 the blank faces
faces2KFace2d[]第二组面。 the tool faces
typeKFaceBooleanType布尔操作类型。 the boolean type

Returns

KFaceBooleanRet

返回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

NameTypeDescription
intervals1KInterval[]输入区间集合1。 The input first interval array.
intervals2KInterval[]输入区间集合2。 The input second interval array.

Returns

KInterval[]

返回两组区间的所有重叠部分。

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

NameTypeDescription
checkLoopKLoop2d被判断的环。 The check loop2d.
baseLoopKLoop2d另一个环。 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

NameTypeDescription
pathKBoundedCurve2d[]输入一组有序的2d曲线集合。 Input 2d curves in order.
deltasnumber[]输入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

KPath2dOffsetRet

返回偏移结果。

Return offset path result.

Defined in

api.d.ts:8699


planeIntersectPlane

planeIntersectPlane(plane1, plane2, tolerance?): KLine3d

两平面求交。

Get the intersection of two planes.

Parameters

NameTypeDescription
plane1KPlane第一个平面。 The first plane.
plane2KPlane第二个平面。 The second plane.
tolerance?number特定容差,默认值是1e-6。 The specified tolerance.The default value is 1e-6.

Returns

KLine3d

返回一条直线,也有可能返回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

NameTypeDescription
pointKPoint2d要判断的点。 The point to compare with the faceLoops.
faceLoopsKFace2d面是由环数组构成。由二维轮廓线集合组成的环,需要保证环的每一个的末点与下一个的起点时相同的,最后一个的末点与第一个的起点时相同的。 还必须确保环没有自相交。 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

返回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

NameTypeDescription
pointKPoint2d要判断的点。 The point to compare with the loop.
loopKLoop2d由二维轮廓线集合组成的环,需要保证环的每一个的末点与下一个的起点时相同的,最后一个的末点与第一个的起点时相同的。 还必须确保环没有自相交。 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

返回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

NameTypeDescription
q1number[]输入第一个四元数数组。 The array representation of the first quaternion.
offset1number输入第一个四元数数组的起始索引。 The offset index in the array where the first quanternion starts.
q2number[]输入第二个四元数数组。 The array representation of the second quaternion.
offset2number输入第二个四元数数组的起始索引。 The offset index in the array where the second quanternion starts.
tnumber输入插值比例。 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

NameTypeDescription
intervalsKInterval[]输入区间集合。 The input interval array.

Returns

KInterval[]

返回合并简化后的区间集合。

Return the simplified intervals.

Defined in

api.d.ts:8652