@antv/g-math
Advanced tools
Comparing version 0.1.0-beta.4 to 0.1.0
@@ -0,1 +1,2 @@ | ||
import { Point, BBox } from './types'; | ||
declare const _default: { | ||
@@ -11,10 +12,5 @@ /** | ||
* @param {number} endAngle 结束角度 | ||
* @returns {object} 包围盒对象 | ||
* @return {object} 包围盒对象 | ||
*/ | ||
box(cx: any, cy: any, rx: any, ry: any, xRotation: any, startAngle: any, endAngle: any): { | ||
x: number; | ||
y: number; | ||
width: number; | ||
height: number; | ||
}; | ||
box(cx: number, cy: number, rx: number, ry: number, xRotation: number, startAngle: number, endAngle: number): BBox; | ||
/** | ||
@@ -31,3 +27,3 @@ * 获取圆弧的长度,计算圆弧长度时不考虑旋转角度, | ||
*/ | ||
length(cx: any, cy: any, rx: any, ry: any, xRotation: any, startAngle: any, endAngle: any): void; | ||
length(cx: number, cy: number, rx: number, ry: number, xRotation: number, startAngle: number, endAngle: number): void; | ||
/** | ||
@@ -42,15 +38,14 @@ * 获取指定点到圆弧的最近距离的点 | ||
* @param {number} endAngle 结束角度 | ||
* @returns {object} 到指定点最近距离的点 | ||
* @param {number} x0 指定点的 x | ||
* @param {number} y0 指定点的 y | ||
* @return {object} 到指定点最近距离的点 | ||
*/ | ||
nearestPoint(cx: any, cy: any, rx: any, ry: any, xRotation: any, startAngle: any, endAngle: any, x0: any, y0: any): { | ||
x: any; | ||
y: any; | ||
nearestPoint(cx: number, cy: number, rx: number, ry: number, xRotation: number, startAngle: number, endAngle: number, x0: number, y0: number): { | ||
x: number; | ||
y: number; | ||
}; | ||
pointDistance(cx: any, cy: any, rx: any, ry: any, xRotation: any, startAngle: any, endAngle: any, x0: any, y0: any): number; | ||
pointAt(cx: any, cy: any, rx: any, ry: any, xRotation: any, startAngle: any, endAngle: any, t: any): { | ||
x: any; | ||
y: any; | ||
}; | ||
tangentAngle(cx: any, cy: any, rx: any, ry: any, xRotation: any, startAngle: any, endAngle: any, t: any): number; | ||
pointDistance(cx: number, cy: number, rx: number, ry: number, xRotation: number, startAngle: number, endAngle: number, x0: number, y0: number): number; | ||
pointAt(cx: number, cy: number, rx: number, ry: number, xRotation: number, startAngle: number, endAngle: number, t: number): Point; | ||
tangentAngle(cx: number, cy: number, rx: number, ry: number, xRotation: number, startAngle: number, endAngle: number, t: number): number; | ||
}; | ||
export default _default; |
@@ -56,3 +56,3 @@ import { distance, piMod } from './util'; | ||
* @param {number} endAngle 结束角度 | ||
* @returns {object} 包围盒对象 | ||
* @return {object} 包围盒对象 | ||
*/ | ||
@@ -140,3 +140,5 @@ box: function (cx, cy, rx, ry, xRotation, startAngle, endAngle) { | ||
* @param {number} endAngle 结束角度 | ||
* @returns {object} 到指定点最近距离的点 | ||
* @param {number} x0 指定点的 x | ||
* @param {number} y0 指定点的 y | ||
* @return {object} 到指定点最近距离的点 | ||
*/ | ||
@@ -143,0 +145,0 @@ nearestPoint: function (cx, cy, rx, ry, xRotation, startAngle, endAngle, x0, y0) { |
@@ -0,1 +1,2 @@ | ||
import { Point } from './types'; | ||
/** | ||
@@ -9,6 +10,3 @@ * 使用牛顿切割法求最近的点 | ||
*/ | ||
export declare function nearestPoint(xArr: number[], yArr: number[], x: number, y: number, tCallback: Function): { | ||
x: any; | ||
y: any; | ||
}; | ||
export declare function snapLength(xArr: any, yArr: any): number; | ||
export declare function nearestPoint(xArr: number[], yArr: number[], x: number, y: number, tCallback: (...arr: number[]) => number): Point; | ||
export declare function snapLength(xArr: number[], yArr: number[]): number; |
@@ -0,1 +1,2 @@ | ||
import { BBox, Point } from './types'; | ||
declare const _default: { | ||
@@ -7,10 +8,5 @@ /** | ||
* @param {number} r 半径 | ||
* @returns {object} 包围盒 | ||
* @return {object} 包围盒 | ||
*/ | ||
box(x: number, y: number, r: number): { | ||
x: number; | ||
y: number; | ||
width: number; | ||
height: number; | ||
}; | ||
box(x: number, y: number, r: number): BBox; | ||
/** | ||
@@ -21,3 +17,3 @@ * 计算周长 | ||
* @param {number} r 半径 | ||
* @returns {number} 周长 | ||
* @return {number} 周长 | ||
*/ | ||
@@ -31,8 +27,5 @@ length(x: number, y: number, r: number): number; | ||
* @param {number} t 指定比例,x轴方向为 0 | ||
* @returns {object} 点 | ||
* @return {object} 点 | ||
*/ | ||
pointAt(x: number, y: number, r: number, t: number): { | ||
x: number; | ||
y: number; | ||
}; | ||
pointAt(x: number, y: number, r: number, t: number): Point; | ||
/** | ||
@@ -45,5 +38,5 @@ * 点到圆的距离 | ||
* @param {number} y0 指定的点 y | ||
* @returns {number} 距离 | ||
* @return {number} 距离 | ||
*/ | ||
pointDistance(x: number, y: number, r: number, x0: any, y0: any): number; | ||
pointDistance(x: number, y: number, r: number, x0: number, y0: number): number; | ||
/** | ||
@@ -55,3 +48,3 @@ * 根据比例计算切线角度 | ||
* @param {number} t 指定比例 0 - 1 之间,x轴方向为 0。在 0-1 范围之外是循环还是返回 null,还需要调整 | ||
* @returns {number} 角度,在 0 - 2PI 之间 | ||
* @return {number} 角度,在 0 - 2PI 之间 | ||
*/ | ||
@@ -58,0 +51,0 @@ tangentAngle(x: number, y: number, r: number, t: any): number; |
@@ -8,3 +8,3 @@ import { distance, piMod } from './util'; | ||
* @param {number} r 半径 | ||
* @returns {object} 包围盒 | ||
* @return {object} 包围盒 | ||
*/ | ||
@@ -14,3 +14,3 @@ box: function (x, y, r) { | ||
x: x - r, | ||
y: x - r, | ||
y: y - r, | ||
width: 2 * r, | ||
@@ -25,3 +25,3 @@ height: 2 * r, | ||
* @param {number} r 半径 | ||
* @returns {number} 周长 | ||
* @return {number} 周长 | ||
*/ | ||
@@ -37,3 +37,3 @@ length: function (x, y, r) { | ||
* @param {number} t 指定比例,x轴方向为 0 | ||
* @returns {object} 点 | ||
* @return {object} 点 | ||
*/ | ||
@@ -54,3 +54,3 @@ pointAt: function (x, y, r, t) { | ||
* @param {number} y0 指定的点 y | ||
* @returns {number} 距离 | ||
* @return {number} 距离 | ||
*/ | ||
@@ -66,3 +66,3 @@ pointDistance: function (x, y, r, x0, y0) { | ||
* @param {number} t 指定比例 0 - 1 之间,x轴方向为 0。在 0-1 范围之外是循环还是返回 null,还需要调整 | ||
* @returns {number} 角度,在 0 - 2PI 之间 | ||
* @return {number} 角度,在 0 - 2PI 之间 | ||
*/ | ||
@@ -69,0 +69,0 @@ tangentAngle: function (x, y, r, t) { |
@@ -1,25 +0,15 @@ | ||
declare function cubicAt(p0: any, p1: any, p2: any, p3: any, t: any): number; | ||
declare function extrema(p0: any, p1: any, p2: any, p3: any): any[]; | ||
import { Point } from './types'; | ||
declare function cubicAt(p0: number, p1: number, p2: number, p3: number, t: number): number; | ||
declare function extrema(p0: number, p1: number, p2: number, p3: number): any[]; | ||
declare const _default: { | ||
extrema: typeof extrema; | ||
box(x1: any, y1: any, x2: any, y2: any, x3: any, y3: any, x4: any, y4: any): { | ||
x: any; | ||
y: any; | ||
width: number; | ||
height: number; | ||
}; | ||
length(x1: any, y1: any, x2: any, y2: any, x3: any, y3: any, x4: any, y4: any): any; | ||
nearestPoint(x1: any, y1: any, x2: any, y2: any, x3: any, y3: any, x4: any, y4: any, x0: any, y0: any): { | ||
x: any; | ||
y: any; | ||
}; | ||
pointDistance(x1: any, y1: any, x2: any, y2: any, x3: any, y3: any, x4: any, y4: any, x0: any, y0: any): number; | ||
box(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, x4: number, y4: number): import("./types").BBox; | ||
length(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, x4: number, y4: number): any; | ||
nearestPoint(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, x4: number, y4: number, x0: number, y0: number): Point; | ||
pointDistance(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, x4: number, y4: number, x0: number, y0: number): number; | ||
interpolationAt: typeof cubicAt; | ||
pointAt(x1: any, y1: any, x2: any, y2: any, x3: any, y3: any, x4: any, y4: any, t: any): { | ||
x: number; | ||
y: number; | ||
}; | ||
divide(x1: any, y1: any, x2: any, y2: any, x3: any, y3: any, x4: any, y4: any, t: any): any[][]; | ||
tangentAngle(x1: any, y1: any, x2: any, y2: any, x3: any, y3: any, x4: any, y4: any, t: any): number; | ||
pointAt(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, x4: number, y4: number, t: number): Point; | ||
divide(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, x4: number, y4: number, t: number): number[][]; | ||
tangentAngle(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, x4: number, y4: number, t: number): number; | ||
}; | ||
export default _default; |
@@ -58,3 +58,6 @@ import { distance, isNumberEqual, getBBoxByArray, piMod } from './util'; | ||
var c23 = line.pointAt(c2.x, c2.y, c3.x, c3.y, t); | ||
return [[x1, y1, c1.x, c1.y, c12.x, c12.y, xt, yt], [xt, yt, c23.x, c23.y, c3.x, c3.y, x4, y4]]; | ||
return [ | ||
[x1, y1, c1.x, c1.y, c12.x, c12.y, xt, yt], | ||
[xt, yt, c23.x, c23.y, c3.x, c3.y, x4, y4], | ||
]; | ||
} | ||
@@ -61,0 +64,0 @@ // 使用迭代法取贝塞尔曲线的长度,二阶和三阶分开写,更清晰和便于调试 |
@@ -7,2 +7,3 @@ /** | ||
*/ | ||
import { Point, BBox } from './types'; | ||
declare const _default: { | ||
@@ -15,10 +16,5 @@ /** | ||
* @param {number} ry 椭圆 y 方向半径 | ||
* @returns {object} 包围盒 | ||
* @return {object} 包围盒 | ||
*/ | ||
box(x: number, y: number, rx: number, ry: number): { | ||
x: number; | ||
y: number; | ||
width: number; | ||
height: number; | ||
}; | ||
box(x: number, y: number, rx: number, ry: number): BBox; | ||
/** | ||
@@ -30,3 +26,3 @@ * 计算周长,使用近似法 | ||
* @param {number} ry 椭圆 y 方向半径 | ||
* @returns {number} 椭圆周长 | ||
* @return {number} 椭圆周长 | ||
*/ | ||
@@ -42,3 +38,3 @@ length(x: number, y: number, rx: number, ry: number): number; | ||
* @param {number} y0 指定的点 y | ||
* @returns {object} 椭圆上距离指定点最近的点 | ||
* @return {object} 椭圆上距离指定点最近的点 | ||
*/ | ||
@@ -57,5 +53,5 @@ nearestPoint(x: number, y: number, rx: number, ry: number, x0: number, y0: number): { | ||
* @param {number} y0 指定的点 y | ||
* @returns {number} 点到椭圆的距离 | ||
* @return {number} 点到椭圆的距离 | ||
*/ | ||
pointDistance(x: any, y: any, rx: any, ry: any, x0: any, y0: any): number; | ||
pointDistance(x: number, y: number, rx: number, ry: number, x0: number, y0: number): number; | ||
/** | ||
@@ -68,8 +64,5 @@ * 根据比例获取点 | ||
* @param {number} t 指定比例,x轴方向为 0 | ||
* @returns {object} 点 | ||
* @return {object} 点 | ||
*/ | ||
pointAt(x: any, y: any, rx: any, ry: any, t: any): { | ||
x: any; | ||
y: any; | ||
}; | ||
pointAt(x: number, y: number, rx: number, ry: number, t: number): Point; | ||
/** | ||
@@ -82,6 +75,6 @@ * 根据比例计算切线角度 | ||
* @param {number} t 指定比例 0 - 1 之间,x轴方向为 0。在 0-1 范围之外是循环还是返回 null,还需要调整 | ||
* @returns {number} 角度,在 0 - 2PI 之间 | ||
* @return {number} 角度,在 0 - 2PI 之间 | ||
*/ | ||
tangentAngle(x: any, y: any, rx: any, ry: any, t: any): number; | ||
tangentAngle(x: number, y: number, rx: number, ry: number, t: number): number; | ||
}; | ||
export default _default; |
@@ -19,3 +19,3 @@ /** | ||
* @param {number} ry 椭圆 y 方向半径 | ||
* @returns {object} 包围盒 | ||
* @return {object} 包围盒 | ||
*/ | ||
@@ -36,3 +36,3 @@ box: function (x, y, rx, ry) { | ||
* @param {number} ry 椭圆 y 方向半径 | ||
* @returns {number} 椭圆周长 | ||
* @return {number} 椭圆周长 | ||
*/ | ||
@@ -50,3 +50,3 @@ length: function (x, y, rx, ry) { | ||
* @param {number} y0 指定的点 y | ||
* @returns {object} 椭圆上距离指定点最近的点 | ||
* @return {object} 椭圆上距离指定点最近的点 | ||
*/ | ||
@@ -104,3 +104,3 @@ nearestPoint: function (x, y, rx, ry, x0, y0) { | ||
* @param {number} y0 指定的点 y | ||
* @returns {number} 点到椭圆的距离 | ||
* @return {number} 点到椭圆的距离 | ||
*/ | ||
@@ -118,3 +118,3 @@ pointDistance: function (x, y, rx, ry, x0, y0) { | ||
* @param {number} t 指定比例,x轴方向为 0 | ||
* @returns {object} 点 | ||
* @return {object} 点 | ||
*/ | ||
@@ -135,3 +135,3 @@ pointAt: function (x, y, rx, ry, t) { | ||
* @param {number} t 指定比例 0 - 1 之间,x轴方向为 0。在 0-1 范围之外是循环还是返回 null,还需要调整 | ||
* @returns {number} 角度,在 0 - 2PI 之间 | ||
* @return {number} 角度,在 0 - 2PI 之间 | ||
*/ | ||
@@ -138,0 +138,0 @@ tangentAngle: function (x, y, rx, ry, t) { |
@@ -0,4 +1,5 @@ | ||
import { BBox, Point } from './types'; | ||
declare const _default: { | ||
/** | ||
* 线段的长度 | ||
* 计算线段的包围盒 | ||
* @param {number} x1 起始点 x | ||
@@ -8,10 +9,5 @@ * @param {number} y1 起始点 y | ||
* @param {number} y2 结束点 y | ||
* @returns {number} 距离 | ||
* @return {object} 包围盒对象 | ||
*/ | ||
box(x1: number, y1: number, x2: number, y2: number): { | ||
x: number; | ||
y: number; | ||
width: number; | ||
height: number; | ||
}; | ||
box(x1: number, y1: number, x2: number, y2: number): BBox; | ||
/** | ||
@@ -23,3 +19,3 @@ * 线段的长度 | ||
* @param {number} y2 结束点 y | ||
* @returns {number} 距离 | ||
* @return {number} 距离 | ||
*/ | ||
@@ -35,8 +31,4 @@ length(x1: number, y1: number, x2: number, y2: number): number; | ||
* @return {object} 包含 x, y 的点 | ||
* | ||
*/ | ||
pointAt(x1: number, y1: number, x2: number, y2: number, t: number): { | ||
x: number; | ||
y: number; | ||
}; | ||
pointAt(x1: number, y1: number, x2: number, y2: number, t: number): Point; | ||
/** | ||
@@ -50,5 +42,5 @@ * 点到线段的距离 | ||
* @param {number} y 测试点 y | ||
* @returns {number} 距离 | ||
* @return {number} 距离 | ||
*/ | ||
pointDistance(x1: number, y1: number, x2: number, y2: number, x: number, y: number): any; | ||
pointDistance(x1: number, y1: number, x2: number, y2: number, x: number, y: number): number; | ||
/** | ||
@@ -62,3 +54,3 @@ * 点到直线的距离,而不是点到线段的距离 | ||
* @param {number} y 测试点 y | ||
* @returns {number} 距离 | ||
* @return {number} 距离 | ||
*/ | ||
@@ -72,3 +64,3 @@ pointToLine(x1: number, y1: number, x2: number, y2: number, x: number, y: number): number; | ||
* @param {number} y2 结束点 y | ||
* @returns {number} 导数 | ||
* @return {number} 导数 | ||
*/ | ||
@@ -75,0 +67,0 @@ tangentAngle(x1: number, y1: number, x2: number, y2: number): number; |
@@ -5,3 +5,3 @@ import { distance } from './util'; | ||
/** | ||
* 线段的长度 | ||
* 计算线段的包围盒 | ||
* @param {number} x1 起始点 x | ||
@@ -11,3 +11,3 @@ * @param {number} y1 起始点 y | ||
* @param {number} y2 结束点 y | ||
* @returns {number} 距离 | ||
* @return {object} 包围盒对象 | ||
*/ | ||
@@ -32,3 +32,3 @@ box: function (x1, y1, x2, y2) { | ||
* @param {number} y2 结束点 y | ||
* @returns {number} 距离 | ||
* @return {number} 距离 | ||
*/ | ||
@@ -46,3 +46,2 @@ length: function (x1, y1, x2, y2) { | ||
* @return {object} 包含 x, y 的点 | ||
* | ||
*/ | ||
@@ -63,3 +62,3 @@ pointAt: function (x1, y1, x2, y2, t) { | ||
* @param {number} y 测试点 y | ||
* @returns {number} 距离 | ||
* @return {number} 距离 | ||
*/ | ||
@@ -87,3 +86,3 @@ pointDistance: function (x1, y1, x2, y2, x, y) { | ||
* @param {number} y 测试点 y | ||
* @returns {number} 距离 | ||
* @return {number} 距离 | ||
*/ | ||
@@ -107,3 +106,3 @@ pointToLine: function (x1, y1, x2, y2, x, y) { | ||
* @param {number} y2 结束点 y | ||
* @returns {number} 导数 | ||
* @return {number} 导数 | ||
*/ | ||
@@ -110,0 +109,0 @@ tangentAngle: function (x1, y1, x2, y2) { |
@@ -0,1 +1,2 @@ | ||
import { PointTuple } from './types'; | ||
declare const _default: { | ||
@@ -5,16 +6,11 @@ /** | ||
* @param {array} points 点的集合 [x,y] 的形式 | ||
* @returns {object} 包围盒 | ||
* @return {object} 包围盒 | ||
*/ | ||
box(points: any): { | ||
x: any; | ||
y: any; | ||
width: number; | ||
height: number; | ||
}; | ||
box(points: PointTuple[]): import("./types").BBox; | ||
/** | ||
* 计算多边形的长度 | ||
* @param {array} points 点的集合 [x,y] 的形式 | ||
* @returns {object} 多边形边的长度 | ||
* @return {object} 多边形边的长度 | ||
*/ | ||
length(points: any): number; | ||
length(points: PointTuple[]): number; | ||
/** | ||
@@ -24,5 +20,5 @@ * 根据比例获取多边形的点 | ||
* @param {number} t 在多边形的长度上的比例 | ||
* @returns {object} 根据比例值计算出来的点 | ||
* @return {object} 根据比例值计算出来的点 | ||
*/ | ||
pointAt(points: any, t: any): any; | ||
pointAt(points: PointTuple[], t: number): import("./types").Point; | ||
/** | ||
@@ -33,5 +29,5 @@ * 指定点到多边形的距离 | ||
* @param {number} y 指定点的 y | ||
* @returns {number} 点到多边形的距离 | ||
* @return {number} 点到多边形的距离 | ||
*/ | ||
pointDistance(points: any, x: any, y: any): number; | ||
pointDistance(points: PointTuple[], x: number, y: number): number; | ||
/** | ||
@@ -41,6 +37,6 @@ * 根据比例获取多边形的切线角度 | ||
* @param {number} t 在多边形的长度上的比例 | ||
* @returns {object} 根据比例值计算出来的角度 | ||
* @return {object} 根据比例值计算出来的角度 | ||
*/ | ||
tangentAngle(points: any, t: any): number; | ||
tangentAngle(points: PointTuple[], t: number): number; | ||
}; | ||
export default _default; |
@@ -14,3 +14,3 @@ import { pointAtSegments, angleAtSegments, distanceAtSegment, lengthOfSegment } from './segments'; | ||
* @param {array} points 点的集合 [x,y] 的形式 | ||
* @returns {object} 包围盒 | ||
* @return {object} 包围盒 | ||
*/ | ||
@@ -23,3 +23,3 @@ box: function (points) { | ||
* @param {array} points 点的集合 [x,y] 的形式 | ||
* @returns {object} 多边形边的长度 | ||
* @return {object} 多边形边的长度 | ||
*/ | ||
@@ -33,3 +33,3 @@ length: function (points) { | ||
* @param {number} t 在多边形的长度上的比例 | ||
* @returns {object} 根据比例值计算出来的点 | ||
* @return {object} 根据比例值计算出来的点 | ||
*/ | ||
@@ -44,3 +44,3 @@ pointAt: function (points, t) { | ||
* @param {number} y 指定点的 y | ||
* @returns {number} 点到多边形的距离 | ||
* @return {number} 点到多边形的距离 | ||
*/ | ||
@@ -54,3 +54,3 @@ pointDistance: function (points, x, y) { | ||
* @param {number} t 在多边形的长度上的比例 | ||
* @returns {object} 根据比例值计算出来的角度 | ||
* @return {object} 根据比例值计算出来的角度 | ||
*/ | ||
@@ -57,0 +57,0 @@ tangentAngle: function (points, t) { |
@@ -0,1 +1,2 @@ | ||
import { PointTuple, BBox } from './types'; | ||
declare const _default: { | ||
@@ -5,16 +6,11 @@ /** | ||
* @param {array} points 点的集合 [x,y] 的形式 | ||
* @returns {object} 包围盒 | ||
* @return {object} 包围盒 | ||
*/ | ||
box(points: any[]): { | ||
x: any; | ||
y: any; | ||
width: number; | ||
height: number; | ||
}; | ||
box(points: PointTuple[]): BBox; | ||
/** | ||
* 计算多折线的长度 | ||
* @param {array} points 点的集合 [x,y] 的形式 | ||
* @returns {object} 多条边的长度 | ||
* @return {object} 多条边的长度 | ||
*/ | ||
length(points: any[]): number; | ||
length(points: PointTuple[]): number; | ||
/** | ||
@@ -24,5 +20,5 @@ * 根据比例获取多折线的点 | ||
* @param {number} t 在多折线的长度上的比例 | ||
* @returns {object} 根据比例值计算出来的点 | ||
* @return {object} 根据比例值计算出来的点 | ||
*/ | ||
pointAt(points: any[], t: number): any; | ||
pointAt(points: PointTuple[], t: number): import("./types").Point; | ||
/** | ||
@@ -33,5 +29,5 @@ * 指定点到多折线的距离 | ||
* @param {number} y 指定点的 y | ||
* @returns {number} 点到多折线的距离 | ||
* @return {number} 点到多折线的距离 | ||
*/ | ||
pointDistance(points: any[], x: number, y: number): number; | ||
pointDistance(points: PointTuple[], x: number, y: number): number; | ||
/** | ||
@@ -41,6 +37,6 @@ * 根据比例获取多折线的切线角度 | ||
* @param {number} t 在多折线的长度上的比例 | ||
* @returns {object} 根据比例值计算出来的角度 | ||
* @return {object} 根据比例值计算出来的角度 | ||
*/ | ||
tangentAngle(points: any[], t: number): number; | ||
tangentAngle(points: PointTuple[], t: number): number; | ||
}; | ||
export default _default; |
@@ -7,3 +7,3 @@ import { pointAtSegments, angleAtSegments, distanceAtSegment, lengthOfSegment } from './segments'; | ||
* @param {array} points 点的集合 [x,y] 的形式 | ||
* @returns {object} 包围盒 | ||
* @return {object} 包围盒 | ||
*/ | ||
@@ -23,3 +23,3 @@ box: function (points) { | ||
* @param {array} points 点的集合 [x,y] 的形式 | ||
* @returns {object} 多条边的长度 | ||
* @return {object} 多条边的长度 | ||
*/ | ||
@@ -33,3 +33,3 @@ length: function (points) { | ||
* @param {number} t 在多折线的长度上的比例 | ||
* @returns {object} 根据比例值计算出来的点 | ||
* @return {object} 根据比例值计算出来的点 | ||
*/ | ||
@@ -44,3 +44,3 @@ pointAt: function (points, t) { | ||
* @param {number} y 指定点的 y | ||
* @returns {number} 点到多折线的距离 | ||
* @return {number} 点到多折线的距离 | ||
*/ | ||
@@ -54,3 +54,3 @@ pointDistance: function (points, x, y) { | ||
* @param {number} t 在多折线的长度上的比例 | ||
* @returns {object} 根据比例值计算出来的角度 | ||
* @return {object} 根据比例值计算出来的角度 | ||
*/ | ||
@@ -57,0 +57,0 @@ tangentAngle: function (points, t) { |
@@ -1,23 +0,13 @@ | ||
declare function quadraticAt(p0: any, p1: any, p2: any, t: any): number; | ||
import { Point } from './types'; | ||
declare function quadraticAt(p0: number, p1: number, p2: number, t: number): number; | ||
declare const _default: { | ||
box(x1: any, y1: any, x2: any, y2: any, x3: any, y3: any): { | ||
x: any; | ||
y: any; | ||
width: number; | ||
height: number; | ||
}; | ||
length(x1: any, y1: any, x2: any, y2: any, x3: any, y3: any): any; | ||
nearestPoint(x1: any, y1: any, x2: any, y2: any, x3: any, y3: any, x0: any, y0: any): { | ||
x: any; | ||
y: any; | ||
}; | ||
pointDistance(x1: any, y1: any, x2: any, y2: any, x3: any, y3: any, x0: any, y0: any): number; | ||
box(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number): import("./types").BBox; | ||
length(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number): any; | ||
nearestPoint(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, x0: number, y0: number): Point; | ||
pointDistance(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, x0: number, y0: number): number; | ||
interpolationAt: typeof quadraticAt; | ||
pointAt(x1: any, y1: any, x2: any, y2: any, x3: any, y3: any, t: any): { | ||
x: number; | ||
y: number; | ||
}; | ||
divide(x1: any, y1: any, x2: any, y2: any, x3: any, y3: any, t: any): any[][]; | ||
tangentAngle(x1: any, y1: any, x2: any, y2: any, x3: any, y3: any, t: any): number; | ||
pointAt(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, t: number): Point; | ||
divide(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, t: number): number[][]; | ||
tangentAngle(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, t: number): number; | ||
}; | ||
export default _default; |
@@ -33,3 +33,6 @@ import line from './line'; | ||
var controlPoint2 = line.pointAt(x2, y2, x3, y3, t); | ||
return [[x1, y1, controlPoint1.x, controlPoint1.y, xt, yt], [xt, yt, controlPoint2.x, controlPoint2.y, x3, y3]]; | ||
return [ | ||
[x1, y1, controlPoint1.x, controlPoint1.y, xt, yt], | ||
[xt, yt, controlPoint2.x, controlPoint2.y, x3, y3], | ||
]; | ||
} | ||
@@ -36,0 +39,0 @@ // 使用迭代法取贝塞尔曲线的长度 |
@@ -0,1 +1,2 @@ | ||
import { Point, BBox } from './types'; | ||
declare const _default: { | ||
@@ -8,10 +9,5 @@ /** | ||
* @param {number} height 高度 | ||
* @returns {object} 包围盒 | ||
* @return {object} 包围盒 | ||
*/ | ||
box(x: number, y: number, width: number, height: number): { | ||
x: number; | ||
y: number; | ||
width: number; | ||
height: number; | ||
}; | ||
box(x: number, y: number, width: number, height: number): BBox; | ||
/** | ||
@@ -33,3 +29,3 @@ * 长度,矩形不需要传入 x, y 即可计算周长,但是避免出错 | ||
* @param {number} y0 指定点的 y | ||
* @returns {number} 最短距离 | ||
* @return {number} 最短距离 | ||
*/ | ||
@@ -44,5 +40,5 @@ pointDistance(x: number, y: number, width: number, height: number, x0: number, y0: number): number; | ||
* @param {number} t 比例 0-1 之间的值 | ||
* @returns {object} 计算出来的点信息,包含 x,y | ||
* @return {object} 计算出来的点信息,包含 x,y | ||
*/ | ||
pointAt(x: number, y: number, width: number, height: number, t: number): any; | ||
pointAt(x: number, y: number, width: number, height: number, t: number): Point; | ||
/** | ||
@@ -55,6 +51,6 @@ * 获取对应点的切线角度 | ||
* @param {number} t 比例 0-1 之间的值 | ||
* @returns {number} 切线的角度 | ||
* @return {number} 切线的角度 | ||
*/ | ||
tangentAngle(x: any, y: any, width: any, height: any, t: any): number; | ||
tangentAngle(x: number, y: number, width: number, height: number, t: number): number; | ||
}; | ||
export default _default; |
import { pointAtSegments, angleAtSegments, distanceAtSegment } from './segments'; | ||
function getPoints(x, y, width, height) { | ||
return [[x, y], [x + width, y], [x + width, y + height], [x, y + height], [x, y]]; | ||
return [ | ||
[x, y], | ||
[x + width, y], | ||
[x + width, y + height], | ||
[x, y + height], | ||
[x, y], | ||
]; | ||
} | ||
@@ -12,3 +18,3 @@ export default { | ||
* @param {number} height 高度 | ||
* @returns {object} 包围盒 | ||
* @return {object} 包围盒 | ||
*/ | ||
@@ -41,3 +47,3 @@ box: function (x, y, width, height) { | ||
* @param {number} y0 指定点的 y | ||
* @returns {number} 最短距离 | ||
* @return {number} 最短距离 | ||
*/ | ||
@@ -55,3 +61,3 @@ pointDistance: function (x, y, width, height, x0, y0) { | ||
* @param {number} t 比例 0-1 之间的值 | ||
* @returns {object} 计算出来的点信息,包含 x,y | ||
* @return {object} 计算出来的点信息,包含 x,y | ||
*/ | ||
@@ -73,3 +79,3 @@ pointAt: function (x, y, width, height, t) { | ||
* @param {number} t 比例 0-1 之间的值 | ||
* @returns {number} 切线的角度 | ||
* @return {number} 切线的角度 | ||
*/ | ||
@@ -76,0 +82,0 @@ tangentAngle: function (x, y, width, height, t) { |
@@ -1,2 +0,3 @@ | ||
export declare function lengthOfSegment(points: any): number; | ||
import { Point, PointTuple } from './types'; | ||
export declare function lengthOfSegment(points: PointTuple[]): number; | ||
/** | ||
@@ -6,5 +7,5 @@ * 按照比例在数据片段中获取点 | ||
* @param {number} t 百分比 0-1 | ||
* @returns {object} 点的坐标 | ||
* @return {object} 点的坐标 | ||
*/ | ||
export declare function pointAtSegments(points: any[], t: number): any; | ||
export declare function pointAtSegments(points: PointTuple[], t: number): Point; | ||
/** | ||
@@ -15,3 +16,3 @@ * 按照比例在数据片段中获取切线的角度 | ||
*/ | ||
export declare function angleAtSegments(points: any[], t: number): number; | ||
export declare function distanceAtSegment(points: any, x: any, y: any): number; | ||
export declare function angleAtSegments(points: PointTuple[], t: number): number; | ||
export declare function distanceAtSegment(points: PointTuple[], x: number, y: number): number; |
@@ -37,3 +37,3 @@ import line from './line'; | ||
* @param {number} t 百分比 0-1 | ||
* @returns {object} 点的坐标 | ||
* @return {object} 点的坐标 | ||
*/ | ||
@@ -40,0 +40,0 @@ export function pointAtSegments(points, t) { |
@@ -0,1 +1,2 @@ | ||
import { BBox } from './types'; | ||
/** | ||
@@ -7,12 +8,7 @@ * 两点之间的距离 | ||
* @param {number} y2 结束点 y | ||
* @returns {number} 距离 | ||
* @return {number} 距离 | ||
*/ | ||
export declare function distance(x1: number, y1: number, x2: number, y2: number): number; | ||
export declare function isNumberEqual(v1: any, v2: any): boolean; | ||
export declare function getBBoxByArray(xArr: any, yArr: any): { | ||
x: any; | ||
y: any; | ||
width: number; | ||
height: number; | ||
}; | ||
export declare function piMod(angle: any): number; | ||
export declare function isNumberEqual(v1: number, v2: number): boolean; | ||
export declare function getBBoxByArray(xArr: number[], yArr: number[]): BBox; | ||
export declare function piMod(angle: number): number; |
@@ -7,3 +7,3 @@ /** | ||
* @param {number} y2 结束点 y | ||
* @returns {number} 距离 | ||
* @return {number} 距离 | ||
*/ | ||
@@ -10,0 +10,0 @@ export function distance(x1, y1, x2, y2) { |
@@ -0,1 +1,2 @@ | ||
import { Point, BBox } from './types'; | ||
declare const _default: { | ||
@@ -11,10 +12,5 @@ /** | ||
* @param {number} endAngle 结束角度 | ||
* @returns {object} 包围盒对象 | ||
* @return {object} 包围盒对象 | ||
*/ | ||
box(cx: any, cy: any, rx: any, ry: any, xRotation: any, startAngle: any, endAngle: any): { | ||
x: number; | ||
y: number; | ||
width: number; | ||
height: number; | ||
}; | ||
box(cx: number, cy: number, rx: number, ry: number, xRotation: number, startAngle: number, endAngle: number): BBox; | ||
/** | ||
@@ -31,3 +27,3 @@ * 获取圆弧的长度,计算圆弧长度时不考虑旋转角度, | ||
*/ | ||
length(cx: any, cy: any, rx: any, ry: any, xRotation: any, startAngle: any, endAngle: any): void; | ||
length(cx: number, cy: number, rx: number, ry: number, xRotation: number, startAngle: number, endAngle: number): void; | ||
/** | ||
@@ -42,15 +38,14 @@ * 获取指定点到圆弧的最近距离的点 | ||
* @param {number} endAngle 结束角度 | ||
* @returns {object} 到指定点最近距离的点 | ||
* @param {number} x0 指定点的 x | ||
* @param {number} y0 指定点的 y | ||
* @return {object} 到指定点最近距离的点 | ||
*/ | ||
nearestPoint(cx: any, cy: any, rx: any, ry: any, xRotation: any, startAngle: any, endAngle: any, x0: any, y0: any): { | ||
x: any; | ||
y: any; | ||
nearestPoint(cx: number, cy: number, rx: number, ry: number, xRotation: number, startAngle: number, endAngle: number, x0: number, y0: number): { | ||
x: number; | ||
y: number; | ||
}; | ||
pointDistance(cx: any, cy: any, rx: any, ry: any, xRotation: any, startAngle: any, endAngle: any, x0: any, y0: any): number; | ||
pointAt(cx: any, cy: any, rx: any, ry: any, xRotation: any, startAngle: any, endAngle: any, t: any): { | ||
x: any; | ||
y: any; | ||
}; | ||
tangentAngle(cx: any, cy: any, rx: any, ry: any, xRotation: any, startAngle: any, endAngle: any, t: any): number; | ||
pointDistance(cx: number, cy: number, rx: number, ry: number, xRotation: number, startAngle: number, endAngle: number, x0: number, y0: number): number; | ||
pointAt(cx: number, cy: number, rx: number, ry: number, xRotation: number, startAngle: number, endAngle: number, t: number): Point; | ||
tangentAngle(cx: number, cy: number, rx: number, ry: number, xRotation: number, startAngle: number, endAngle: number, t: number): number; | ||
}; | ||
export default _default; |
@@ -58,3 +58,3 @@ "use strict"; | ||
* @param {number} endAngle 结束角度 | ||
* @returns {object} 包围盒对象 | ||
* @return {object} 包围盒对象 | ||
*/ | ||
@@ -142,3 +142,5 @@ box: function (cx, cy, rx, ry, xRotation, startAngle, endAngle) { | ||
* @param {number} endAngle 结束角度 | ||
* @returns {object} 到指定点最近距离的点 | ||
* @param {number} x0 指定点的 x | ||
* @param {number} y0 指定点的 y | ||
* @return {object} 到指定点最近距离的点 | ||
*/ | ||
@@ -145,0 +147,0 @@ nearestPoint: function (cx, cy, rx, ry, xRotation, startAngle, endAngle, x0, y0) { |
@@ -0,1 +1,2 @@ | ||
import { Point } from './types'; | ||
/** | ||
@@ -9,6 +10,3 @@ * 使用牛顿切割法求最近的点 | ||
*/ | ||
export declare function nearestPoint(xArr: number[], yArr: number[], x: number, y: number, tCallback: Function): { | ||
x: any; | ||
y: any; | ||
}; | ||
export declare function snapLength(xArr: any, yArr: any): number; | ||
export declare function nearestPoint(xArr: number[], yArr: number[], x: number, y: number, tCallback: (...arr: number[]) => number): Point; | ||
export declare function snapLength(xArr: number[], yArr: number[]): number; |
@@ -0,1 +1,2 @@ | ||
import { BBox, Point } from './types'; | ||
declare const _default: { | ||
@@ -7,10 +8,5 @@ /** | ||
* @param {number} r 半径 | ||
* @returns {object} 包围盒 | ||
* @return {object} 包围盒 | ||
*/ | ||
box(x: number, y: number, r: number): { | ||
x: number; | ||
y: number; | ||
width: number; | ||
height: number; | ||
}; | ||
box(x: number, y: number, r: number): BBox; | ||
/** | ||
@@ -21,3 +17,3 @@ * 计算周长 | ||
* @param {number} r 半径 | ||
* @returns {number} 周长 | ||
* @return {number} 周长 | ||
*/ | ||
@@ -31,8 +27,5 @@ length(x: number, y: number, r: number): number; | ||
* @param {number} t 指定比例,x轴方向为 0 | ||
* @returns {object} 点 | ||
* @return {object} 点 | ||
*/ | ||
pointAt(x: number, y: number, r: number, t: number): { | ||
x: number; | ||
y: number; | ||
}; | ||
pointAt(x: number, y: number, r: number, t: number): Point; | ||
/** | ||
@@ -45,5 +38,5 @@ * 点到圆的距离 | ||
* @param {number} y0 指定的点 y | ||
* @returns {number} 距离 | ||
* @return {number} 距离 | ||
*/ | ||
pointDistance(x: number, y: number, r: number, x0: any, y0: any): number; | ||
pointDistance(x: number, y: number, r: number, x0: number, y0: number): number; | ||
/** | ||
@@ -55,3 +48,3 @@ * 根据比例计算切线角度 | ||
* @param {number} t 指定比例 0 - 1 之间,x轴方向为 0。在 0-1 范围之外是循环还是返回 null,还需要调整 | ||
* @returns {number} 角度,在 0 - 2PI 之间 | ||
* @return {number} 角度,在 0 - 2PI 之间 | ||
*/ | ||
@@ -58,0 +51,0 @@ tangentAngle(x: number, y: number, r: number, t: any): number; |
@@ -10,3 +10,3 @@ "use strict"; | ||
* @param {number} r 半径 | ||
* @returns {object} 包围盒 | ||
* @return {object} 包围盒 | ||
*/ | ||
@@ -16,3 +16,3 @@ box: function (x, y, r) { | ||
x: x - r, | ||
y: x - r, | ||
y: y - r, | ||
width: 2 * r, | ||
@@ -27,3 +27,3 @@ height: 2 * r, | ||
* @param {number} r 半径 | ||
* @returns {number} 周长 | ||
* @return {number} 周长 | ||
*/ | ||
@@ -39,3 +39,3 @@ length: function (x, y, r) { | ||
* @param {number} t 指定比例,x轴方向为 0 | ||
* @returns {object} 点 | ||
* @return {object} 点 | ||
*/ | ||
@@ -56,3 +56,3 @@ pointAt: function (x, y, r, t) { | ||
* @param {number} y0 指定的点 y | ||
* @returns {number} 距离 | ||
* @return {number} 距离 | ||
*/ | ||
@@ -68,3 +68,3 @@ pointDistance: function (x, y, r, x0, y0) { | ||
* @param {number} t 指定比例 0 - 1 之间,x轴方向为 0。在 0-1 范围之外是循环还是返回 null,还需要调整 | ||
* @returns {number} 角度,在 0 - 2PI 之间 | ||
* @return {number} 角度,在 0 - 2PI 之间 | ||
*/ | ||
@@ -71,0 +71,0 @@ tangentAngle: function (x, y, r, t) { |
@@ -1,25 +0,15 @@ | ||
declare function cubicAt(p0: any, p1: any, p2: any, p3: any, t: any): number; | ||
declare function extrema(p0: any, p1: any, p2: any, p3: any): any[]; | ||
import { Point } from './types'; | ||
declare function cubicAt(p0: number, p1: number, p2: number, p3: number, t: number): number; | ||
declare function extrema(p0: number, p1: number, p2: number, p3: number): any[]; | ||
declare const _default: { | ||
extrema: typeof extrema; | ||
box(x1: any, y1: any, x2: any, y2: any, x3: any, y3: any, x4: any, y4: any): { | ||
x: any; | ||
y: any; | ||
width: number; | ||
height: number; | ||
}; | ||
length(x1: any, y1: any, x2: any, y2: any, x3: any, y3: any, x4: any, y4: any): any; | ||
nearestPoint(x1: any, y1: any, x2: any, y2: any, x3: any, y3: any, x4: any, y4: any, x0: any, y0: any): { | ||
x: any; | ||
y: any; | ||
}; | ||
pointDistance(x1: any, y1: any, x2: any, y2: any, x3: any, y3: any, x4: any, y4: any, x0: any, y0: any): number; | ||
box(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, x4: number, y4: number): import("./types").BBox; | ||
length(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, x4: number, y4: number): any; | ||
nearestPoint(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, x4: number, y4: number, x0: number, y0: number): Point; | ||
pointDistance(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, x4: number, y4: number, x0: number, y0: number): number; | ||
interpolationAt: typeof cubicAt; | ||
pointAt(x1: any, y1: any, x2: any, y2: any, x3: any, y3: any, x4: any, y4: any, t: any): { | ||
x: number; | ||
y: number; | ||
}; | ||
divide(x1: any, y1: any, x2: any, y2: any, x3: any, y3: any, x4: any, y4: any, t: any): any[][]; | ||
tangentAngle(x1: any, y1: any, x2: any, y2: any, x3: any, y3: any, x4: any, y4: any, t: any): number; | ||
pointAt(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, x4: number, y4: number, t: number): Point; | ||
divide(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, x4: number, y4: number, t: number): number[][]; | ||
tangentAngle(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, x4: number, y4: number, t: number): number; | ||
}; | ||
export default _default; |
@@ -60,3 +60,6 @@ "use strict"; | ||
var c23 = line_1.default.pointAt(c2.x, c2.y, c3.x, c3.y, t); | ||
return [[x1, y1, c1.x, c1.y, c12.x, c12.y, xt, yt], [xt, yt, c23.x, c23.y, c3.x, c3.y, x4, y4]]; | ||
return [ | ||
[x1, y1, c1.x, c1.y, c12.x, c12.y, xt, yt], | ||
[xt, yt, c23.x, c23.y, c3.x, c3.y, x4, y4], | ||
]; | ||
} | ||
@@ -63,0 +66,0 @@ // 使用迭代法取贝塞尔曲线的长度,二阶和三阶分开写,更清晰和便于调试 |
@@ -7,2 +7,3 @@ /** | ||
*/ | ||
import { Point, BBox } from './types'; | ||
declare const _default: { | ||
@@ -15,10 +16,5 @@ /** | ||
* @param {number} ry 椭圆 y 方向半径 | ||
* @returns {object} 包围盒 | ||
* @return {object} 包围盒 | ||
*/ | ||
box(x: number, y: number, rx: number, ry: number): { | ||
x: number; | ||
y: number; | ||
width: number; | ||
height: number; | ||
}; | ||
box(x: number, y: number, rx: number, ry: number): BBox; | ||
/** | ||
@@ -30,3 +26,3 @@ * 计算周长,使用近似法 | ||
* @param {number} ry 椭圆 y 方向半径 | ||
* @returns {number} 椭圆周长 | ||
* @return {number} 椭圆周长 | ||
*/ | ||
@@ -42,3 +38,3 @@ length(x: number, y: number, rx: number, ry: number): number; | ||
* @param {number} y0 指定的点 y | ||
* @returns {object} 椭圆上距离指定点最近的点 | ||
* @return {object} 椭圆上距离指定点最近的点 | ||
*/ | ||
@@ -57,5 +53,5 @@ nearestPoint(x: number, y: number, rx: number, ry: number, x0: number, y0: number): { | ||
* @param {number} y0 指定的点 y | ||
* @returns {number} 点到椭圆的距离 | ||
* @return {number} 点到椭圆的距离 | ||
*/ | ||
pointDistance(x: any, y: any, rx: any, ry: any, x0: any, y0: any): number; | ||
pointDistance(x: number, y: number, rx: number, ry: number, x0: number, y0: number): number; | ||
/** | ||
@@ -68,8 +64,5 @@ * 根据比例获取点 | ||
* @param {number} t 指定比例,x轴方向为 0 | ||
* @returns {object} 点 | ||
* @return {object} 点 | ||
*/ | ||
pointAt(x: any, y: any, rx: any, ry: any, t: any): { | ||
x: any; | ||
y: any; | ||
}; | ||
pointAt(x: number, y: number, rx: number, ry: number, t: number): Point; | ||
/** | ||
@@ -82,6 +75,6 @@ * 根据比例计算切线角度 | ||
* @param {number} t 指定比例 0 - 1 之间,x轴方向为 0。在 0-1 范围之外是循环还是返回 null,还需要调整 | ||
* @returns {number} 角度,在 0 - 2PI 之间 | ||
* @return {number} 角度,在 0 - 2PI 之间 | ||
*/ | ||
tangentAngle(x: any, y: any, rx: any, ry: any, t: any): number; | ||
tangentAngle(x: number, y: number, rx: number, ry: number, t: number): number; | ||
}; | ||
export default _default; |
@@ -21,3 +21,3 @@ "use strict"; | ||
* @param {number} ry 椭圆 y 方向半径 | ||
* @returns {object} 包围盒 | ||
* @return {object} 包围盒 | ||
*/ | ||
@@ -38,3 +38,3 @@ box: function (x, y, rx, ry) { | ||
* @param {number} ry 椭圆 y 方向半径 | ||
* @returns {number} 椭圆周长 | ||
* @return {number} 椭圆周长 | ||
*/ | ||
@@ -52,3 +52,3 @@ length: function (x, y, rx, ry) { | ||
* @param {number} y0 指定的点 y | ||
* @returns {object} 椭圆上距离指定点最近的点 | ||
* @return {object} 椭圆上距离指定点最近的点 | ||
*/ | ||
@@ -106,3 +106,3 @@ nearestPoint: function (x, y, rx, ry, x0, y0) { | ||
* @param {number} y0 指定的点 y | ||
* @returns {number} 点到椭圆的距离 | ||
* @return {number} 点到椭圆的距离 | ||
*/ | ||
@@ -120,3 +120,3 @@ pointDistance: function (x, y, rx, ry, x0, y0) { | ||
* @param {number} t 指定比例,x轴方向为 0 | ||
* @returns {object} 点 | ||
* @return {object} 点 | ||
*/ | ||
@@ -137,3 +137,3 @@ pointAt: function (x, y, rx, ry, t) { | ||
* @param {number} t 指定比例 0 - 1 之间,x轴方向为 0。在 0-1 范围之外是循环还是返回 null,还需要调整 | ||
* @returns {number} 角度,在 0 - 2PI 之间 | ||
* @return {number} 角度,在 0 - 2PI 之间 | ||
*/ | ||
@@ -140,0 +140,0 @@ tangentAngle: function (x, y, rx, ry, t) { |
@@ -0,4 +1,5 @@ | ||
import { BBox, Point } from './types'; | ||
declare const _default: { | ||
/** | ||
* 线段的长度 | ||
* 计算线段的包围盒 | ||
* @param {number} x1 起始点 x | ||
@@ -8,10 +9,5 @@ * @param {number} y1 起始点 y | ||
* @param {number} y2 结束点 y | ||
* @returns {number} 距离 | ||
* @return {object} 包围盒对象 | ||
*/ | ||
box(x1: number, y1: number, x2: number, y2: number): { | ||
x: number; | ||
y: number; | ||
width: number; | ||
height: number; | ||
}; | ||
box(x1: number, y1: number, x2: number, y2: number): BBox; | ||
/** | ||
@@ -23,3 +19,3 @@ * 线段的长度 | ||
* @param {number} y2 结束点 y | ||
* @returns {number} 距离 | ||
* @return {number} 距离 | ||
*/ | ||
@@ -35,8 +31,4 @@ length(x1: number, y1: number, x2: number, y2: number): number; | ||
* @return {object} 包含 x, y 的点 | ||
* | ||
*/ | ||
pointAt(x1: number, y1: number, x2: number, y2: number, t: number): { | ||
x: number; | ||
y: number; | ||
}; | ||
pointAt(x1: number, y1: number, x2: number, y2: number, t: number): Point; | ||
/** | ||
@@ -50,5 +42,5 @@ * 点到线段的距离 | ||
* @param {number} y 测试点 y | ||
* @returns {number} 距离 | ||
* @return {number} 距离 | ||
*/ | ||
pointDistance(x1: number, y1: number, x2: number, y2: number, x: number, y: number): any; | ||
pointDistance(x1: number, y1: number, x2: number, y2: number, x: number, y: number): number; | ||
/** | ||
@@ -62,3 +54,3 @@ * 点到直线的距离,而不是点到线段的距离 | ||
* @param {number} y 测试点 y | ||
* @returns {number} 距离 | ||
* @return {number} 距离 | ||
*/ | ||
@@ -72,3 +64,3 @@ pointToLine(x1: number, y1: number, x2: number, y2: number, x: number, y: number): number; | ||
* @param {number} y2 结束点 y | ||
* @returns {number} 导数 | ||
* @return {number} 导数 | ||
*/ | ||
@@ -75,0 +67,0 @@ tangentAngle(x1: number, y1: number, x2: number, y2: number): number; |
@@ -7,3 +7,3 @@ "use strict"; | ||
/** | ||
* 线段的长度 | ||
* 计算线段的包围盒 | ||
* @param {number} x1 起始点 x | ||
@@ -13,3 +13,3 @@ * @param {number} y1 起始点 y | ||
* @param {number} y2 结束点 y | ||
* @returns {number} 距离 | ||
* @return {object} 包围盒对象 | ||
*/ | ||
@@ -34,3 +34,3 @@ box: function (x1, y1, x2, y2) { | ||
* @param {number} y2 结束点 y | ||
* @returns {number} 距离 | ||
* @return {number} 距离 | ||
*/ | ||
@@ -48,3 +48,2 @@ length: function (x1, y1, x2, y2) { | ||
* @return {object} 包含 x, y 的点 | ||
* | ||
*/ | ||
@@ -65,3 +64,3 @@ pointAt: function (x1, y1, x2, y2, t) { | ||
* @param {number} y 测试点 y | ||
* @returns {number} 距离 | ||
* @return {number} 距离 | ||
*/ | ||
@@ -89,3 +88,3 @@ pointDistance: function (x1, y1, x2, y2, x, y) { | ||
* @param {number} y 测试点 y | ||
* @returns {number} 距离 | ||
* @return {number} 距离 | ||
*/ | ||
@@ -109,3 +108,3 @@ pointToLine: function (x1, y1, x2, y2, x, y) { | ||
* @param {number} y2 结束点 y | ||
* @returns {number} 导数 | ||
* @return {number} 导数 | ||
*/ | ||
@@ -112,0 +111,0 @@ tangentAngle: function (x1, y1, x2, y2) { |
@@ -0,1 +1,2 @@ | ||
import { PointTuple } from './types'; | ||
declare const _default: { | ||
@@ -5,16 +6,11 @@ /** | ||
* @param {array} points 点的集合 [x,y] 的形式 | ||
* @returns {object} 包围盒 | ||
* @return {object} 包围盒 | ||
*/ | ||
box(points: any): { | ||
x: any; | ||
y: any; | ||
width: number; | ||
height: number; | ||
}; | ||
box(points: PointTuple[]): import("./types").BBox; | ||
/** | ||
* 计算多边形的长度 | ||
* @param {array} points 点的集合 [x,y] 的形式 | ||
* @returns {object} 多边形边的长度 | ||
* @return {object} 多边形边的长度 | ||
*/ | ||
length(points: any): number; | ||
length(points: PointTuple[]): number; | ||
/** | ||
@@ -24,5 +20,5 @@ * 根据比例获取多边形的点 | ||
* @param {number} t 在多边形的长度上的比例 | ||
* @returns {object} 根据比例值计算出来的点 | ||
* @return {object} 根据比例值计算出来的点 | ||
*/ | ||
pointAt(points: any, t: any): any; | ||
pointAt(points: PointTuple[], t: number): import("./types").Point; | ||
/** | ||
@@ -33,5 +29,5 @@ * 指定点到多边形的距离 | ||
* @param {number} y 指定点的 y | ||
* @returns {number} 点到多边形的距离 | ||
* @return {number} 点到多边形的距离 | ||
*/ | ||
pointDistance(points: any, x: any, y: any): number; | ||
pointDistance(points: PointTuple[], x: number, y: number): number; | ||
/** | ||
@@ -41,6 +37,6 @@ * 根据比例获取多边形的切线角度 | ||
* @param {number} t 在多边形的长度上的比例 | ||
* @returns {object} 根据比例值计算出来的角度 | ||
* @return {object} 根据比例值计算出来的角度 | ||
*/ | ||
tangentAngle(points: any, t: any): number; | ||
tangentAngle(points: PointTuple[], t: number): number; | ||
}; | ||
export default _default; |
@@ -16,3 +16,3 @@ "use strict"; | ||
* @param {array} points 点的集合 [x,y] 的形式 | ||
* @returns {object} 包围盒 | ||
* @return {object} 包围盒 | ||
*/ | ||
@@ -25,3 +25,3 @@ box: function (points) { | ||
* @param {array} points 点的集合 [x,y] 的形式 | ||
* @returns {object} 多边形边的长度 | ||
* @return {object} 多边形边的长度 | ||
*/ | ||
@@ -35,3 +35,3 @@ length: function (points) { | ||
* @param {number} t 在多边形的长度上的比例 | ||
* @returns {object} 根据比例值计算出来的点 | ||
* @return {object} 根据比例值计算出来的点 | ||
*/ | ||
@@ -46,3 +46,3 @@ pointAt: function (points, t) { | ||
* @param {number} y 指定点的 y | ||
* @returns {number} 点到多边形的距离 | ||
* @return {number} 点到多边形的距离 | ||
*/ | ||
@@ -56,3 +56,3 @@ pointDistance: function (points, x, y) { | ||
* @param {number} t 在多边形的长度上的比例 | ||
* @returns {object} 根据比例值计算出来的角度 | ||
* @return {object} 根据比例值计算出来的角度 | ||
*/ | ||
@@ -59,0 +59,0 @@ tangentAngle: function (points, t) { |
@@ -0,1 +1,2 @@ | ||
import { PointTuple, BBox } from './types'; | ||
declare const _default: { | ||
@@ -5,16 +6,11 @@ /** | ||
* @param {array} points 点的集合 [x,y] 的形式 | ||
* @returns {object} 包围盒 | ||
* @return {object} 包围盒 | ||
*/ | ||
box(points: any[]): { | ||
x: any; | ||
y: any; | ||
width: number; | ||
height: number; | ||
}; | ||
box(points: PointTuple[]): BBox; | ||
/** | ||
* 计算多折线的长度 | ||
* @param {array} points 点的集合 [x,y] 的形式 | ||
* @returns {object} 多条边的长度 | ||
* @return {object} 多条边的长度 | ||
*/ | ||
length(points: any[]): number; | ||
length(points: PointTuple[]): number; | ||
/** | ||
@@ -24,5 +20,5 @@ * 根据比例获取多折线的点 | ||
* @param {number} t 在多折线的长度上的比例 | ||
* @returns {object} 根据比例值计算出来的点 | ||
* @return {object} 根据比例值计算出来的点 | ||
*/ | ||
pointAt(points: any[], t: number): any; | ||
pointAt(points: PointTuple[], t: number): import("./types").Point; | ||
/** | ||
@@ -33,5 +29,5 @@ * 指定点到多折线的距离 | ||
* @param {number} y 指定点的 y | ||
* @returns {number} 点到多折线的距离 | ||
* @return {number} 点到多折线的距离 | ||
*/ | ||
pointDistance(points: any[], x: number, y: number): number; | ||
pointDistance(points: PointTuple[], x: number, y: number): number; | ||
/** | ||
@@ -41,6 +37,6 @@ * 根据比例获取多折线的切线角度 | ||
* @param {number} t 在多折线的长度上的比例 | ||
* @returns {object} 根据比例值计算出来的角度 | ||
* @return {object} 根据比例值计算出来的角度 | ||
*/ | ||
tangentAngle(points: any[], t: number): number; | ||
tangentAngle(points: PointTuple[], t: number): number; | ||
}; | ||
export default _default; |
@@ -9,3 +9,3 @@ "use strict"; | ||
* @param {array} points 点的集合 [x,y] 的形式 | ||
* @returns {object} 包围盒 | ||
* @return {object} 包围盒 | ||
*/ | ||
@@ -25,3 +25,3 @@ box: function (points) { | ||
* @param {array} points 点的集合 [x,y] 的形式 | ||
* @returns {object} 多条边的长度 | ||
* @return {object} 多条边的长度 | ||
*/ | ||
@@ -35,3 +35,3 @@ length: function (points) { | ||
* @param {number} t 在多折线的长度上的比例 | ||
* @returns {object} 根据比例值计算出来的点 | ||
* @return {object} 根据比例值计算出来的点 | ||
*/ | ||
@@ -46,3 +46,3 @@ pointAt: function (points, t) { | ||
* @param {number} y 指定点的 y | ||
* @returns {number} 点到多折线的距离 | ||
* @return {number} 点到多折线的距离 | ||
*/ | ||
@@ -56,3 +56,3 @@ pointDistance: function (points, x, y) { | ||
* @param {number} t 在多折线的长度上的比例 | ||
* @returns {object} 根据比例值计算出来的角度 | ||
* @return {object} 根据比例值计算出来的角度 | ||
*/ | ||
@@ -59,0 +59,0 @@ tangentAngle: function (points, t) { |
@@ -1,23 +0,13 @@ | ||
declare function quadraticAt(p0: any, p1: any, p2: any, t: any): number; | ||
import { Point } from './types'; | ||
declare function quadraticAt(p0: number, p1: number, p2: number, t: number): number; | ||
declare const _default: { | ||
box(x1: any, y1: any, x2: any, y2: any, x3: any, y3: any): { | ||
x: any; | ||
y: any; | ||
width: number; | ||
height: number; | ||
}; | ||
length(x1: any, y1: any, x2: any, y2: any, x3: any, y3: any): any; | ||
nearestPoint(x1: any, y1: any, x2: any, y2: any, x3: any, y3: any, x0: any, y0: any): { | ||
x: any; | ||
y: any; | ||
}; | ||
pointDistance(x1: any, y1: any, x2: any, y2: any, x3: any, y3: any, x0: any, y0: any): number; | ||
box(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number): import("./types").BBox; | ||
length(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number): any; | ||
nearestPoint(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, x0: number, y0: number): Point; | ||
pointDistance(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, x0: number, y0: number): number; | ||
interpolationAt: typeof quadraticAt; | ||
pointAt(x1: any, y1: any, x2: any, y2: any, x3: any, y3: any, t: any): { | ||
x: number; | ||
y: number; | ||
}; | ||
divide(x1: any, y1: any, x2: any, y2: any, x3: any, y3: any, t: any): any[][]; | ||
tangentAngle(x1: any, y1: any, x2: any, y2: any, x3: any, y3: any, t: any): number; | ||
pointAt(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, t: number): Point; | ||
divide(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, t: number): number[][]; | ||
tangentAngle(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, t: number): number; | ||
}; | ||
export default _default; |
@@ -35,3 +35,6 @@ "use strict"; | ||
var controlPoint2 = line_1.default.pointAt(x2, y2, x3, y3, t); | ||
return [[x1, y1, controlPoint1.x, controlPoint1.y, xt, yt], [xt, yt, controlPoint2.x, controlPoint2.y, x3, y3]]; | ||
return [ | ||
[x1, y1, controlPoint1.x, controlPoint1.y, xt, yt], | ||
[xt, yt, controlPoint2.x, controlPoint2.y, x3, y3], | ||
]; | ||
} | ||
@@ -38,0 +41,0 @@ // 使用迭代法取贝塞尔曲线的长度 |
@@ -0,1 +1,2 @@ | ||
import { Point, BBox } from './types'; | ||
declare const _default: { | ||
@@ -8,10 +9,5 @@ /** | ||
* @param {number} height 高度 | ||
* @returns {object} 包围盒 | ||
* @return {object} 包围盒 | ||
*/ | ||
box(x: number, y: number, width: number, height: number): { | ||
x: number; | ||
y: number; | ||
width: number; | ||
height: number; | ||
}; | ||
box(x: number, y: number, width: number, height: number): BBox; | ||
/** | ||
@@ -33,3 +29,3 @@ * 长度,矩形不需要传入 x, y 即可计算周长,但是避免出错 | ||
* @param {number} y0 指定点的 y | ||
* @returns {number} 最短距离 | ||
* @return {number} 最短距离 | ||
*/ | ||
@@ -44,5 +40,5 @@ pointDistance(x: number, y: number, width: number, height: number, x0: number, y0: number): number; | ||
* @param {number} t 比例 0-1 之间的值 | ||
* @returns {object} 计算出来的点信息,包含 x,y | ||
* @return {object} 计算出来的点信息,包含 x,y | ||
*/ | ||
pointAt(x: number, y: number, width: number, height: number, t: number): any; | ||
pointAt(x: number, y: number, width: number, height: number, t: number): Point; | ||
/** | ||
@@ -55,6 +51,6 @@ * 获取对应点的切线角度 | ||
* @param {number} t 比例 0-1 之间的值 | ||
* @returns {number} 切线的角度 | ||
* @return {number} 切线的角度 | ||
*/ | ||
tangentAngle(x: any, y: any, width: any, height: any, t: any): number; | ||
tangentAngle(x: number, y: number, width: number, height: number, t: number): number; | ||
}; | ||
export default _default; |
@@ -5,3 +5,9 @@ "use strict"; | ||
function getPoints(x, y, width, height) { | ||
return [[x, y], [x + width, y], [x + width, y + height], [x, y + height], [x, y]]; | ||
return [ | ||
[x, y], | ||
[x + width, y], | ||
[x + width, y + height], | ||
[x, y + height], | ||
[x, y], | ||
]; | ||
} | ||
@@ -15,3 +21,3 @@ exports.default = { | ||
* @param {number} height 高度 | ||
* @returns {object} 包围盒 | ||
* @return {object} 包围盒 | ||
*/ | ||
@@ -44,3 +50,3 @@ box: function (x, y, width, height) { | ||
* @param {number} y0 指定点的 y | ||
* @returns {number} 最短距离 | ||
* @return {number} 最短距离 | ||
*/ | ||
@@ -58,3 +64,3 @@ pointDistance: function (x, y, width, height, x0, y0) { | ||
* @param {number} t 比例 0-1 之间的值 | ||
* @returns {object} 计算出来的点信息,包含 x,y | ||
* @return {object} 计算出来的点信息,包含 x,y | ||
*/ | ||
@@ -76,3 +82,3 @@ pointAt: function (x, y, width, height, t) { | ||
* @param {number} t 比例 0-1 之间的值 | ||
* @returns {number} 切线的角度 | ||
* @return {number} 切线的角度 | ||
*/ | ||
@@ -79,0 +85,0 @@ tangentAngle: function (x, y, width, height, t) { |
@@ -1,2 +0,3 @@ | ||
export declare function lengthOfSegment(points: any): number; | ||
import { Point, PointTuple } from './types'; | ||
export declare function lengthOfSegment(points: PointTuple[]): number; | ||
/** | ||
@@ -6,5 +7,5 @@ * 按照比例在数据片段中获取点 | ||
* @param {number} t 百分比 0-1 | ||
* @returns {object} 点的坐标 | ||
* @return {object} 点的坐标 | ||
*/ | ||
export declare function pointAtSegments(points: any[], t: number): any; | ||
export declare function pointAtSegments(points: PointTuple[], t: number): Point; | ||
/** | ||
@@ -15,3 +16,3 @@ * 按照比例在数据片段中获取切线的角度 | ||
*/ | ||
export declare function angleAtSegments(points: any[], t: number): number; | ||
export declare function distanceAtSegment(points: any, x: any, y: any): number; | ||
export declare function angleAtSegments(points: PointTuple[], t: number): number; | ||
export declare function distanceAtSegment(points: PointTuple[], x: number, y: number): number; |
@@ -40,3 +40,3 @@ "use strict"; | ||
* @param {number} t 百分比 0-1 | ||
* @returns {object} 点的坐标 | ||
* @return {object} 点的坐标 | ||
*/ | ||
@@ -43,0 +43,0 @@ function pointAtSegments(points, t) { |
@@ -0,1 +1,2 @@ | ||
import { BBox } from './types'; | ||
/** | ||
@@ -7,12 +8,7 @@ * 两点之间的距离 | ||
* @param {number} y2 结束点 y | ||
* @returns {number} 距离 | ||
* @return {number} 距离 | ||
*/ | ||
export declare function distance(x1: number, y1: number, x2: number, y2: number): number; | ||
export declare function isNumberEqual(v1: any, v2: any): boolean; | ||
export declare function getBBoxByArray(xArr: any, yArr: any): { | ||
x: any; | ||
y: any; | ||
width: number; | ||
height: number; | ||
}; | ||
export declare function piMod(angle: any): number; | ||
export declare function isNumberEqual(v1: number, v2: number): boolean; | ||
export declare function getBBoxByArray(xArr: number[], yArr: number[]): BBox; | ||
export declare function piMod(angle: number): number; |
@@ -9,3 +9,3 @@ "use strict"; | ||
* @param {number} y2 结束点 y | ||
* @returns {number} 距离 | ||
* @return {number} 距离 | ||
*/ | ||
@@ -12,0 +12,0 @@ function distance(x1, y1, x2, y2) { |
{ | ||
"name": "@antv/g-math", | ||
"version": "0.1.0-beta.4", | ||
"version": "0.1.0", | ||
"description": "geometry math", | ||
@@ -55,3 +55,3 @@ "main": "lib/index.js", | ||
}, | ||
"gitHead": "dfe406eabeb080b0200809ee347c03a555f4af91" | ||
"gitHead": "6804098ea6cc26dadf16615e755d27430ae9f8fd" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
191155
86
3188