import { Sampled } from './types'; export interface Similarity { theta: number; sigma: number; res: number; } export interface Alignment extends Similarity { ca: readonly [number, number]; cb: readonly [number, number]; /** A with the chosen correspondence (re-indexed only if A is the closed loop). */ a: Float64Array; /** B with the chosen correspondence (orientation and circular offset). */ b: Float64Array; } export interface PlanItem { /** Points of A with the chosen correspondence (if A is a closed loop it * may come circularly re-indexed: same points, different cut). */ a: Float64Array; /** A centered on its centroid. */ aC: Float64Array; /** B brought into A's frame: R(−θ)·(b − c_B)/σ. */ bT: Float64Array; /** B oriented, raw (for linear mode and for exact t=1). */ bO: Float64Array; ca: readonly [number, number]; cb: readonly [number, number]; theta: number; lnSigma: number; res: number; /** true if both endpoints are closed loops: the subpath flies with Z. * Closed → open flies open: the loop opens at the chosen cut. */ closed: boolean; /** Block transport (set by the global hybrid, else null): mid-flight the * centroid rides the shared similarity around the global centroid instead * of lerping — off = c_A − g_A; drift closes c(1) = c_B exactly. */ block: { off: readonly [number, number]; drift: readonly [number, number]; } | null; } export interface MorphPlan { items: PlanItem[]; n: number; } export declare function centroid(p: Float64Array): [number, number]; export declare function polyLen(p: Float64Array): number; export declare function reversePts(p: Float64Array): Float64Array; /** Circular re-indexing of a loop: out[i] = p[(i+off) mod n]. Same point * set, different cut point — the circular degree of freedom of closed paths. */ export declare function rotatePts(p: Float64Array, off: number): Float64Array; /** Optimal similarity (θ, σ) minimizing Σ|σ·R(θ)·(a−c_A) − (b−c_B)|². * θ* = atan2(S_xy − S_yx, S_xx + S_yy); σ* by zero derivative. * res = RMS residual normalized by b's energy (0 → same shape). */ export declare function procrustes(a: Float64Array, b: Float64Array, ca: readonly [number, number], cb: readonly [number, number]): Similarity; /** Best index-to-index correspondence between a and b: tries both traversal * directions and, if there is a closed loop, its N circular offsets, * scoring with score = res + λ·|θ|/π. The freedom is applied to ONE cloud * — the closed one (b if both are); varying both at once would be * redundant. */ export declare function alignPair(aPts: Float64Array, bPts: Float64Array, aClosed?: boolean, bClosed?: boolean): Alignment; /** Builds the morph plan between two lists of sampled subpaths. The plan is * cacheable and serializable; it accepts any list — including intermediate * shapes (interruptions). */ export declare function buildPlan(srcSubs: readonly Sampled[], dstSubs: readonly Sampled[]): MorphPlan;