export type P2 = readonly [number, number]; export declare function toM(p: readonly [number, number]): [number, number]; export declare const sub: (a: P2, b: P2) => [number, number]; export declare const add: (a: P2, b: P2) => [number, number]; export declare const scale: (a: P2, k: number) => [number, number]; export declare const dot: (a: P2, b: P2) => number; export declare const cross: (a: P2, b: P2) => number; export declare const len: (a: P2) => number; export declare const dist: (a: P2, b: P2) => number; export declare const lerp2: (a: P2, b: P2, t: number) => [number, number]; export declare function unit(a: P2): [number, number]; /** Rotate +90 degrees (counter-clockwise in M): the LEFT of a direction. */ export declare const left: (d: P2) => [number, number]; /** Angle of a direction in [0, 2pi). */ export declare function angleOf(d: P2): number; /** Counter-clockwise angle from direction a to direction b in [0, 2pi). */ export declare function ccwAngle(a: P2, b: P2): number; /** * Intersection of lines p + s*d and q + t*e. Returns [s, t], or null when the lines are (nearly) parallel. */ export declare function intersectLines(p: P2, d: P2, q: P2, e: P2): [number, number] | null; export declare function signedArea(poly: readonly P2[]): number; /** A sampled station along a polyline. */ export interface Station { s: number; p: [number, number]; /** Unit tangent (direction of increasing s). */ t: [number, number]; /** Unit left normal. */ n: [number, number]; /** Mitre factor: offsets along `n` are multiplied by this to keep the strip width constant round a bend. */ miter: number; } export declare class Polyline { readonly pts: Array<[number, number]>; /** Cumulative arclength per point. */ readonly cum: number[]; readonly length: number; constructor(pts: ReadonlyArray); /** Index i such that cum[i] <= s < cum[i+1], clamped. */ private segment; private segDir; pointAt(s: number): [number, number]; /** Station at arclength s; at a polyline vertex the tangent is the mean of both sides and the offset is mitred. */ stationAt(s: number): Station; /** Sub-polyline between arclengths [s0, s1] (inclusive of the cut points). */ slice(s0: number, s1: number): Polyline; } /** Turn angle in degrees at interior vertex i. */ export declare function turnDegrees(pts: ReadonlyArray, i: number): number; /** Convex hull (Andrew), counter-clockwise, no duplicate points. Deterministic. */ export declare function convexHull(points: ReadonlyArray): Array<[number, number]>; /** * Ear-clipping triangulation of a simple polygon given counter-clockwise (in M). Returns index triples. Tolerates collinear * and repeated vertices (they become zero-area ears that are dropped). If it cannot make progress it fans what is left. */ export declare function triangulate(poly: ReadonlyArray): Array<[number, number, number]>;