IDP.Math.KGeomLib interface
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.
Signature:
export interface KGeomLib
Methods
Method | Description |
---|---|
在特定容差下,检查两曲线是否有重合部分(包括完全重合)。 Get the overlap status of two curves, include totally and partial overlap. | |
在特定容差下,检查两曲线是否完全重合。 Get the totally overlap status of two curves with specified tolerance. | |
以特定容差判断轮廓线是否落在另一环内。 Check if bounded curve is inside of base loop2d with specified tolerance. | |
创建一个变换矩阵,是从全局坐标系到局部坐标系的变换。 Create a transformation matrix which align global ccs to the given ccs. | |
通过圆弧的圆心、半径、起始角度和圆弧角度来创建一段圆弧。 Create an arc by center, radius, start angle and arc angle. | |
通过圆弧的弦和圆弧突起的高度比例来创建圆弧。 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. | |
createArc2dByPointsAndStartTangent(start, end, startTangent, cosTol) | 通过圆弧起点、终点以及起点切向来创建圆弧。 Create an arc by start point, end point and tangent at start point. |
createArc2dByStartEndAngles(center, radius, startAngle, endAngle, isCCW) | 通过圆弧的圆心、半径、起始角度和终止角度来创建一段圆弧。 Create an arc by center, radius, start angle and end angle. |
createArc2dByStartEndPoints(center, startPoint, endPoint, isCCW) | 通过圆心、圆弧起点和末点来创建圆弧。 Create an arc by start and end points. |
通过三个点创建一个圆弧。 Create an arc by input three points. | |
createArc2dByTwoPointsAndRadius(startPoint, endPoint, radius, isMinorArc, isCCW) | 创建给定半径并经过给定起点和终点的圆弧。 当给定圆弧起点、终点和半径之后,总共有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. |
createArc3dByCenterNormalRadius(center, normal, radius, startPoint, endPoint) | 通过圆心和法向和半径和起点末点来创建圆弧。 注意:这种方式创建的圆弧始终时围绕着法向逆时针的。 Create an arc by start and end points. NOTE: the created arc is always counter-clockwise around the normal. |
createArc3dByStartEndAngles(center, xDir, yDir, radius, startAngle, endAngle) | 通过圆弧的圆心、X轴、Y轴、半径、起始角度和终止角度来创建一段圆弧。 Create an arc by center, x direction, y direction, radius, start angle and end angle. |
通过三个点创建一个圆弧。 Create an arc by input three points. | |
创建一个KBoundingBox2d对象。 Creates an instance of KBoundingBox2d. | |
创建一个KBoundingBox3d对象。 Creates an instance of KBoundingBox3d. | |
通过圆心和圆上一点创建一个二维空间的圆。 Create a 2d circle by the origin of the circle and a point on the circle. | |
通过圆心和半径创建一个二维空间的圆。 Create a 2d circle by the origin and radius. | |
通过三点来创建一圆。 Create an circle by input three points. | |
createCircle3dByCenterNormalRadius(center, normal, radius, xDir) | 通过圆心、半径和法向来创建圆。 注意:创建的圆围绕着·法向时逆时针的。 Create an circle by center, normal, radius. NOTE: the created arc is always counter-clockwise around the normal. |
通过圆心、X轴方向、Y轴方向和半径来创建圆。 Create an circle by origin, direction of X axis, direction of Y axis and radius. | |
通过三点来创建一圆。 Create an circle by input three points. | |
通过椭圆心、椭圆长轴方向、椭圆长轴半径、椭圆短轴半径、圆弧起点和末点来创建圆弧。 Create an elliptical arc by center, x direction, major radius, minor radius, start and end points. | |
通过椭圆心、椭圆长轴方向、椭圆长轴半径、椭圆短轴半径、圆弧起点和末点来创建圆弧。 Create an elliptical arc by center, x direction, major radius, minor radius, start and end points. | |
创建一个表示旋转变换的欧拉角对象。 Create an Euler object which represents a rotational transformation. | |
通过内轮廓和外轮廓创建面。 注意:需要保证内轮廓与外轮廓方向相反。 Create a face2d by contour and holes. NOTE: the caller need to make sure the contour and holes have opposite ccw direction | |
通过轮廓线数组来创建二维环。 需要保证轮廓线数组首尾相连。 Create a loop2d by bounded curves. The caller need to make sure the input curves are connected tail to head and closed. | |
通过点集合来创建二维loop。loop将只含线段。 Create a loop2d by points, the result loop contains only line segments. | |
创建一个单位矩阵。 Create an identity matrix. | |
创建四阶单位矩阵。 Create an identity matrix. | |
根据起点和终点创建一个区间。 Create an interval by start and end points. | |
创建一个包含输入数值的最小区间。 Create an union interval from the input values. | |
创建一个默认的非法区间。 Create a default invalid interval. | |
创建一个KLine2d对象。 Creates an instance of KLine2d. | |
创建一个KLine3d对象。 Creates an instance of KLine3d. | |
创建一个KLineSegment2d对象。 Creates an instance KLineSegment2d | |
创建一个KLineSegment3d对象。 Creates an instance KLineSegment3d | |
通过给定阶数、节点向量、控制点以及权重构建一条非均匀有理样条曲线。 Create a nurbs curve by degree, knots, control points and weights. | |
通过一个点和一个法向来创建平面。 Create a plane from a point and normal. | |
通过三点创建一个平面。 平面的原点时第一个点,平面的法向是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(). | |
创建一个kpoint2d对象。 Creates an instance of KPoint2d. | |
创建一个kpoint3d对象。 Creates an instance of KPoint3d. | |
通过点列创建一个二维折线段。 Create a 2D polyline by a list of points. | |
通过点列创建一个三维折线段。 Create a 3D polyline by a list of points. | |
创建一个表示旋转变换的四元数对象。 Create a quaternion which represents a rotational transformation. | |
创建围绕轴旋转的变换矩阵。 旋转轴由一点定义,旋转角度由弧度值给出。 Create an transform matrix that does rotation about an axis. The axis is defined by a point. The angle is given in radians. | |
创建围绕轴旋转的变换矩阵。 旋转轴由一点和一向量定义,旋转角度由弧度值给出。 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. | |
创建一个由欧拉角定义的旋转变换矩阵。 Create a rotation matrix by the euler angles. | |
创建一个由四元数定义的旋转变换矩阵。 Create a rotation matrix by the quaternion. | |
创建缩放矩阵。 Create a matrix as scale transform. | |
创建缩放矩阵。 Create a matrix as scale transform. | |
创建平移变换矩阵。 Create an translation transform matrix. | |
创建平移变换矩阵。 Create an translation transform matrix. | |
创建一个kVector2d对象。 Creates an instance of KVector2d | |
创建一个kVector3d对象。 Creates an instance of KVector3d. | |
从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(). | |
对两条曲线求交。 如果两曲线完全重合,该方法返回的是空数组。 所以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. | |
曲线与曲面求交。 Get the intersection of a curve and a surface. | |
对两组面进行布尔操作。 Calculate the boolean result between blank faces and tool faces. | |
求出两组区间的所有重叠部分。 Get the common parts of the two groups of interval. | |
判断环是否落在另一环内。 Check loop2d is inside of base loop2d. | |
偏移一组有序的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. | |
两平面求交。 Get the intersection of two planes. | |
以特定容差判断点是否在面中。 Check whether a point is in loops or not with specified tolerance. | |
以特定容差检查一点是否在环中。 Check whether a point is in a loop or not with specified tolerance. | |
不同于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. | |
对一组区间中重叠的区间进行合并简化。合并简化后的区间序列和原始区间序列覆盖相同的区域。 Simplify the intervals by uniting the intersected intervals. |