import type { AABB } from '@antv/g'; import type { Point, PointObject } from '../types'; import type { LineSegment } from './line'; /** * 将对象坐标转换为数组坐标 * Convert object coordinates to array coordinates * @param point - 对象坐标 | object coordinates * @returns 数组坐标 | array coordinates */ export declare function parsePoint(point: PointObject): Point; /** * 将数组坐标转换为对象坐标 * * Convert array coordinates to object coordinates * @param point - 数组坐标 | array coordinates * @returns 对象坐标 | object coordinates */ export declare function toPointObject(point: Point): PointObject; /** * 根据 X 轴坐标排序 * Sort by X-axis coordinates * @param points - 点集 | point set * @returns 排序后的点集 | sorted point set */ export declare function sortByX(points: Point[]): Point[]; /** * 点集去重 * * Deduplicate point set * @param points - 点集 | pointset * @returns 去重后的点集 | deduplicated pointset */ export declare function deduplicate(points: Point[]): Point[]; /** * 对点格式化,精确到 `digits` 位的数字 * * Round the point to the given precision * @param point - 要舍入的点 | the point to round * @param digits - 小数点后的位数 | the number of digits after the decimal point * @returns 舍入后的点 | the rounded point */ export declare function round(point: Point, digits?: number): Point; /** * 移动点,将点朝向参考点移动一定的距离 * * Move `p` point along the line starting from `ref` to this point by a certain `distance` * @param p - 要移动的点 | the point to move * @param ref - 参考点 | the reference point * @param distance - 移动的距离 | the distance to move * @param reverse * @returns 移动后的点 | the moved point */ export declare function moveTo(p: Point, ref: Point, distance: number, reverse?: boolean): Point; /** * 判断两个点是否在同一水平线上 * * whether two points are on the same horizontal line * @param p1 - 第一个点 | the first point * @param p2 - 第二个点 | the second point * @returns 返回两个点是否在同一水平线上 | is horizontal or not */ export declare function isHorizontal(p1: Point, p2: Point): boolean; /** * 判断两个点是否在同一垂直线上 * * whether two points are on the same vertical line * @param p1 - 第一个点 | the first point * @param p2 - 第二个点 | the second point * @returns 返回两个点是否在同一垂直线上 | is vertical or not */ export declare function isVertical(p1: Point, p2: Point): boolean; /** * 判断两个点是否正交,即是否在同一水平线或垂直线上 * * Judges whether two points are orthogonal, that is, whether they are on the same horizontal or vertical line * @param p1 - 第一个点 | the first point * @param p2 - 第二个点 | the second point * @returns 是否正交 | whether orthogonal or not */ export declare function isOrthogonal(p1: Point, p2: Point): boolean; /** * 判断是否三点共线 * * Judge whether three points are collinear * @param p1 - 第一个点 | the first point * @param p2 - 第二个点 | the second point * @param p3 - 第三个点 | the third point * @returns 是否三点共线 | whether three points are collinear */ export declare function isCollinear(p1: Point, p2: Point, p3: Point): boolean; /** * 计算一个点相对于另一个点的中心对称点 * * Calculate the center symmetric point of a point relative to another point * @param p - 要计算的点 | the point to calculate * @param center - 中心点 | the center point * @returns 中心对称点 | the center symmetric point */ export declare function getSymmetricPoint(p: Point, center: Point): Point; /** * 获取从多边形中心到给定点的连线与多边形边缘的交点 * * Gets the intersection point between the line from the center of a polygon to a given point and the polygon's edge * @param p - 从多边形中心到多边形边缘的连线的外部点 | The point outside the polygon from which the line to the polygon's center is drawn * @param center - 多边形中心 | the center of the polygon * @param points - 多边形顶点 | the vertices of the polygon * @param isRelativePos - 顶点坐标是否相对中心点 | whether the vertex coordinates are relative to the center point * @param useExtendedLine - 是否使用延长线 | whether to use the extended line * @returns 交点与相交线段 | intersection and intersecting line segment */ export declare function getPolygonIntersectPoint(p: Point, center: Point, points: Point[], isRelativePos?: boolean, useExtendedLine?: boolean): { point: Point; line?: LineSegment; }; /** * 判断点是否在多边形内部 * * Whether point is inside the polygon (ray algo) * @param point - 点 | point * @param points - 多边形顶点 | polygon vertices * @param start - 起始索引 | start index * @param end - 结束索引 | end index * @returns 是否在多边形内部 | whether inside the polygon */ export declare function isPointInPolygon(point: Point, points: Point[], start?: number, end?: number): boolean; /** * 获取给定点到矩形中心的连线与矩形边缘的交点 * * Gets the intersection point between the line from the center of a rectangle to a given point and the rectangle's edge * @param p - 从矩形中心到矩形边缘的连线的外部点 | The point outside the rectangle from which the line to the rectangle's center is drawn * @param bbox - 矩形包围盒 | the bounding box of the rectangle * @param useExtendedLine - 是否使用延长线 | whether to use the extended line * @returns 交点 | intersection */ export declare function getRectIntersectPoint(p: Point, bbox: AABB, useExtendedLine?: boolean): Point; /** * 获取给定点到椭圆中心的连线与椭圆边缘的交点 * * Gets the intersection point between the line from the center of an ellipse to a given point and the ellipse's edge * @param p - 从椭圆中心到椭圆边缘的连线的外部点 | The point outside the ellipse from which the line to the ellipse's center is drawn * The point outside the ellipse from which the line to the ellipse's center is drawn. * @param bbox - 椭圆包围盒 | the bounding box of the ellipse * @param useExtendedLine - 是否使用延长线 | whether to use the extended line * @returns 交点 | intersection */ export declare function getEllipseIntersectPoint(p: Point, bbox: AABB, useExtendedLine?: boolean): Point; /** * 从两组点中找到距离最近的两个点 * @param group1 - 第一组点 | the first group of points * @param group2 - 第二组点 | the second group of points * @returns 距离最近的两个点 | the nearest two points */ export declare function findNearestPoints(group1: Point[], group2: Point[]): [Point, Point]; /** * 从一组线段中找到距离给定点最近的线段 * * Find the line segment closest to the given point from a group of line segments * @param point - 给定点 | the given point * @param lines - 一组线段 | a group of line segments * @returns 距离最近的线段 | the nearest line segment */ export declare function findNearestLine(point: Point, lines: LineSegment[]): [Point, Point]; /** * 获取点到线段的距离 * * Get the distance from a point to a line segment * @param point - 点 | the point * @param line - 线段 | the line segment * @returns 点到线段的距离 | the distance from the point to the line segment */ export declare function getDistanceToLine(point: Point, line: LineSegment): number; /** * 获取线段上距离给定点最近的点 * * Get the point on the line segment closest to the given point * @param point - 给定点 | the given point * @param line - 线段 | the line segment * @returns 线段上距离给定点最近的点 | the point on the line segment closest to the given point */ export declare function findNearestPointOnLine(point: Point, line: LineSegment): Point; /** * 获取点集的中心点 * * Get the center point of a set of points * @param points - 点集 | point set * @returns 中心点 | center point */ export declare function centerOf(points: Point[]): Point; /** * 按顺时针或逆时针方向对点集排序 * * Sort the point set in a clockwise or counterclockwise direction * @param points - 点集 | point set * @param clockwise - 是否顺时针 | whether clockwise * @returns 排序后的点集 | sorted point set */ export declare function sortByClockwise(points: Point[], clockwise?: boolean): Point[]; /** * 给定的起点和终点,返回一个由这两个点和它们的对角点组成的数组 * @param start - 起点 | start point * @param end - 终点 | end point * @returns 由这两个点和它们的对角点组成的数组 | an array consisting of these two points and their diagonal points */ export declare function getBoundingPoints(start: Point, end: Point): Point[];