curvy 2.0.0-alpha.12 → 2.0.0-alpha.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/characteristic/index.mjs +1 -1
- package/dist/curve/index.mjs +1 -1
- package/dist/curve/rationalCubic2d.d.ts +195 -11
- package/dist/interval/index.mjs +1 -1
- package/dist/monotonicity/index.d.ts +4 -0
- package/dist/monotonicity/index.mjs +2 -0
- package/dist/monotonicity/monotonicity.d.ts +80 -0
- package/dist/path/index.mjs +5 -5
- package/dist/path/rationalCubic2d.d.ts +27 -0
- package/dist/polynomial/cubic.d.ts +2 -2
- package/dist/polynomial/index.mjs +2 -2
- package/dist/polynomial/linear.d.ts +7 -7
- package/dist/polynomial/quadratic.d.ts +2 -2
- package/dist/shared/{characteristic-Hb7F8SBw.mjs → characteristic-BkEr-rr8.mjs} +2 -2
- package/dist/shared/{characteristic-Hb7F8SBw.mjs.map → characteristic-BkEr-rr8.mjs.map} +1 -1
- package/dist/shared/{cubic-DHJrzZJN.mjs → cubic-BL6dpuHh.mjs} +18 -30
- package/dist/shared/cubic-BL6dpuHh.mjs.map +1 -0
- package/dist/shared/{interval2d-DPmvk_Qe.mjs → interval2d-AtneyI45.mjs} +1 -1
- package/dist/shared/{interval2d-DPmvk_Qe.mjs.map → interval2d-AtneyI45.mjs.map} +1 -1
- package/dist/shared/monotonicity-BdebFOtv.mjs +34 -0
- package/dist/shared/monotonicity-BdebFOtv.mjs.map +1 -0
- package/dist/shared/{quadratic-BZmfZE71.mjs → quadratic-DPrUsFCp.mjs} +9 -9
- package/dist/shared/quadratic-DPrUsFCp.mjs.map +1 -0
- package/dist/shared/{rationalCubic2d-D5g3_hTV.mjs → rationalCubic2d-CeHgpNht.mjs} +373 -79
- package/dist/shared/rationalCubic2d-CeHgpNht.mjs.map +1 -0
- package/dist/shared/{rationalCubic2d-MojACId0.mjs → rationalCubic2d-H1J2Fjyy.mjs} +25 -16
- package/dist/shared/rationalCubic2d-H1J2Fjyy.mjs.map +1 -0
- package/dist/shared/{solution-B6KY1E7M.mjs → solution-B2JdOZpe.mjs} +1 -1
- package/dist/shared/{solution-B6KY1E7M.mjs.map → solution-B2JdOZpe.mjs.map} +1 -1
- package/dist/solution/index.mjs +1 -1
- package/dist/splines/index.mjs +4 -4
- package/package.json +5 -1
- package/dist/polynomial/monotonicity.d.ts +0 -3
- package/dist/shared/cubic-DHJrzZJN.mjs.map +0 -1
- package/dist/shared/quadratic-BZmfZE71.mjs.map +0 -1
- package/dist/shared/rationalCubic2d-D5g3_hTV.mjs.map +0 -1
- package/dist/shared/rationalCubic2d-MojACId0.mjs.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rationalCubic2d-D5g3_hTV.mjs","names":["fromPolynomials","fromCoefficients","LinearPolynomial.make","fromEndpoints","isLinearCurve2d","derivative","Vector2.make","solve","LinearPolynomial.solve","solveAtX","Solution.match","LinearPolynomial.solveInverse","Solution.none","Solution.one","solveAtY","length","boundingBox","Interval2d.make","LinearPolynomial.unitRange","isMonotonic","LinearPolynomial.isMonotonic","isIncreasing","LinearPolynomial.isIncreasing","isDecreasing","LinearPolynomial.isDecreasing","fail","asMonotonic","asIncreasing","asDecreasing","fromPolynomials","internal.fromPolynomials","fromCoefficients","internal.fromCoefficients","internal.fromEndpoints","internal.isLinearCurve2d","derivative","internal.derivative","solve","internal.solve","length","internal.length","boundingBox","internal.boundingBox","solveAtX","internal.solveAtX","solveAtY","internal.solveAtY","isMonotonic","internal.isMonotonic","isIncreasing","internal.isIncreasing","isDecreasing","internal.isDecreasing","asMonotonic","internal.asMonotonic","asIncreasing","internal.asIncreasing","asDecreasing","internal.asDecreasing","fromPolynomials","fromCoefficients","QuadraticPolynomial.make","fromBezierPoints","isQuadraticCurve2d","solve","Vector2.make","QuadraticPolynomial.solve","solveAtX","Solution.clip","QuadraticPolynomial.solveInverse","Interval.unit","Solution.map","solveAtY","derivative","LinearCurve2d.fromPolynomials","QuadraticPolynomial.derivative","length","Interval.size","LinearCurve2d.length","LinearPolynomial.make","Interval.scaleShift","Interval.biunit","Vector2.magnitude","LinearCurve2d.solve","curvature","LinearCurve2d.derivative","Vector2.cross","boundingBox","Interval2d.make","QuadraticPolynomial.unitRange","isMonotonic","QuadraticPolynomial.isMonotonic","isIncreasing","QuadraticPolynomial.isIncreasing","isDecreasing","QuadraticPolynomial.isDecreasing","fail","asMonotonic","asIncreasing","asDecreasing","fromPolynomials","internal.fromPolynomials","fromCoefficients","internal.fromCoefficients","fromBezierPoints","internal.fromBezierPoints","internal.isQuadraticCurve2d","solve","internal.solve","length","internal.length","solveAtX","internal.solveAtX","solveAtY","internal.solveAtY","derivative","internal.derivative","curvature","internal.curvature","boundingBox","internal.boundingBox","isMonotonic","internal.isMonotonic","isIncreasing","internal.isIncreasing","isDecreasing","internal.isDecreasing","asMonotonic","internal.asMonotonic","asIncreasing","internal.asIncreasing","asDecreasing","internal.asDecreasing","fromPolynomials","fromCoefficients","CubicPolynomial.make","fromBezierPoints","Vector4.transpose","Characteristic.apply","Characteristic.cubicBezier","isCubicCurve2d","solve","Vector2.make","CubicPolynomial.solve","solveAtX","Solution.clip","CubicPolynomial.solveInverse","Interval.unit","Solution.map","solveAtY","QuadraticCurve2d.fromPolynomials","CubicPolynomial.derivative","length","Interval.size","QuadraticCurve2d.length","QuadraticPolynomial.make","Interval.scaleShift","Interval.biunit","Vector2.magnitude","QuadraticCurve2d.solve","curvature","LinearCurve2d.solve","QuadraticCurve2d.derivative","Vector2.cross","boundingBox","Interval2d.make","CubicPolynomial.unitRange","isMonotonic","CubicPolynomial.isMonotonic","isIncreasing","CubicPolynomial.isIncreasing","isDecreasing","CubicPolynomial.isDecreasing","asMonotonic","asIncreasing","asDecreasing","fromPolynomials","internal.fromPolynomials","internal.fromCoefficients","fromBezierPoints","internal.fromBezierPoints","internal.isCubicCurve2d","solve","internal.solve","internal.length","solveAtX","internal.solveAtX","solveAtY","internal.solveAtY","internal.curvature","boundingBox","internal.boundingBox","internal.isMonotonic","internal.isIncreasing","internal.isDecreasing","internal.asMonotonic","internal.asIncreasing","internal.asDecreasing","isRationalCubicCurve2d","fromPolynomials","fromBezierPoints","Characteristic.apply","Characteristic.cubicBezier","Vector4.transpose","makeMonotonicEasing","CubicPolynomial.make","CubicPolynomial.roots","Solution.clip","Interval.unitOpen","CubicPolynomial.solve","solve","Vector2.make","solveAtX","Interval.unit","Solution.map","solveAtY","CubicCurve2d.fromBezierPoints","subdivide","CubicPolynomial.subdivide","boundingBox","Interval2d.fromVectors","CubicCurve2d.fromPolynomials","CubicCurve2d.boundingBox","Interval2d.maxDistance","approximateAsCubicCurves","internal.isRationalCubicCurve2d","internal.fromPolynomials","internal.fromBezierPoints","internal.makeMonotonicEasing","internal.solve","internal.solveAtX","internal.solveAtY","internal.subdivide","internal.boundingBox","internal.approximateAsCubicCurves"],"sources":["../../src/curve/linear2d.internal.ts","../../src/curve/linear2d.ts","../../src/curve/quadratic2d.internal.ts","../../src/curve/quadratic2d.ts","../../src/curve/cubic2d.internal.ts","../../src/curve/cubic2d.ts","../../src/curve/rationalCubic2d.internal.ts","../../src/curve/rationalCubic2d.ts"],"sourcesContent":["import * as Interval2d from '../interval/interval2d.ts'\nimport type * as Interval from '../interval/interval.ts'\nimport { dual, Pipeable } from '../utils.ts'\nimport * as LinearPolynomial from '../polynomial/linear.ts'\nimport type { Decreasing, Increasing, Monotonic } from '../polynomial/traits.ts'\nimport * as Solution from '../solution/solution.ts'\nimport * as Vector2 from '../vector/vector2.ts'\nimport type { LinearCurve2d } from './linear2d.ts'\n\nexport const LinearCurve2dTypeId: unique symbol = Symbol('curvy/curve/linear2d')\nexport type LinearCurve2dTypeId = typeof LinearCurve2dTypeId\n\n/** @internal */\nexport class LinearCurve2dImpl extends Pipeable implements LinearCurve2d<unknown, unknown> {\n readonly [LinearCurve2dTypeId]: LinearCurve2dTypeId = LinearCurve2dTypeId\n\n readonly x: LinearPolynomial.LinearPolynomial\n readonly y: LinearPolynomial.LinearPolynomial\n\n constructor(c0: LinearPolynomial.LinearPolynomial, c1: LinearPolynomial.LinearPolynomial) {\n super()\n this.x = c0\n this.y = c1\n }\n\n get [0]() {\n return this.x\n }\n\n get [1]() {\n return this.y\n }\n}\n\n/** @internal */\nexport const fromPolynomials: (\n c0: LinearPolynomial.LinearPolynomial,\n c1: LinearPolynomial.LinearPolynomial,\n) => LinearCurve2d = (c0, c1) => new LinearCurve2dImpl(c0, c1)\n\n/** @internal */\nexport const fromCoefficients: (c0: Vector2.Vector2, c1: Vector2.Vector2) => LinearCurve2d = (\n c0,\n c1,\n) => new LinearCurve2dImpl(LinearPolynomial.make(c0.x, c1.x), LinearPolynomial.make(c0.y, c1.y))\n\n// Linear Bernstein basis: B(t) = (1-t)·p0 + t·p1\n// Expanding to monomial form gives c0 = p0, c1 = p1 - p0.\n/** @internal */\nexport const fromEndpoints: (p0: Vector2.Vector2, p1: Vector2.Vector2) => LinearCurve2d = (\n p0,\n p1,\n) =>\n new LinearCurve2dImpl(\n LinearPolynomial.make(p0.x, p1.x - p0.x),\n LinearPolynomial.make(p0.y, p1.y - p0.y),\n )\n\n/** @internal */\nexport const isLinearCurve2d = (c: unknown): c is LinearCurve2d =>\n typeof c === 'object' && c !== null && LinearCurve2dTypeId in c\n\n/** @internal */\nexport const derivative = (c: LinearCurve2d) => Vector2.make(c.x.c1, c.y.c1)\n\n/** @internal */\nexport const solve = dual<\n (t: number) => (c: LinearCurve2d) => Vector2.Vector2,\n (c: LinearCurve2d, t: number) => Vector2.Vector2\n>(2, (c: LinearCurve2d, t: number) =>\n Vector2.make(LinearPolynomial.solve(c.x, t), LinearPolynomial.solve(c.y, t)),\n)\n\n// solveAtX: invert the x polynomial to find t, then evaluate y at t — only\n// returning the result when t lies in the curve's parameter domain [0, 1].\n// A linear curve crosses any vertical line at most once, so the result is\n// always 0 or 1 element.\n/** @internal */\nexport const solveAtX = dual(2, (c: LinearCurve2d, x: number) =>\n Solution.match(LinearPolynomial.solveInverse(c.x, x), {\n onNone: () => Solution.none,\n onSome: ({ value: t }) =>\n t < 0 || t > 1 ? Solution.none : Solution.one(LinearPolynomial.solve(c.y, t)),\n }),\n)\n\n/** @internal */\nexport const solveAtY = dual(2, (c: LinearCurve2d, y: number) =>\n Solution.match(LinearPolynomial.solveInverse(c.y, y), {\n onNone: () => Solution.none,\n onSome: ({ value: t }) =>\n t < 0 || t > 1 ? Solution.none : Solution.one(LinearPolynomial.solve(c.x, t)),\n }),\n)\n\n/** @internal */\nexport const length = dual(\n 2,\n (c: LinearCurve2d, i: Interval.Interval) =>\n Math.sqrt(c.x.c1 ** 2 + c.y.c1 ** 2) * Math.abs(i.end - i.start),\n)\n\n/** @internal */\nexport const boundingBox = (\n c: LinearCurve2d,\n): Interval2d.Interval2d<Interval.Closed, Interval.Closed> =>\n Interval2d.make(LinearPolynomial.unitRange(c.x), LinearPolynomial.unitRange(c.y))\n\n// Combined trait refiners — fan out the polynomial-level check across both\n// axes. For per-axis checks, users can call `LinearPolynomial.isMonotonic(c.x)`\n// directly.\n/** @internal */\nexport const isMonotonic = <XT, YT>(\n c: LinearCurve2d<XT, YT>,\n): c is LinearCurve2d<XT & Monotonic, YT & Monotonic> =>\n LinearPolynomial.isMonotonic(c.x) && LinearPolynomial.isMonotonic(c.y)\n\n/** @internal */\nexport const isIncreasing = <XT, YT>(\n c: LinearCurve2d<XT, YT>,\n): c is LinearCurve2d<XT & Increasing, YT & Increasing> =>\n LinearPolynomial.isIncreasing(c.x) && LinearPolynomial.isIncreasing(c.y)\n\n/** @internal */\nexport const isDecreasing = <XT, YT>(\n c: LinearCurve2d<XT, YT>,\n): c is LinearCurve2d<XT & Decreasing, YT & Decreasing> =>\n LinearPolynomial.isDecreasing(c.x) && LinearPolynomial.isDecreasing(c.y)\n\nconst fail = (m: string): never => {\n throw new Error(m)\n}\n\n/** @internal */\nexport const asMonotonic = <XT, YT>(\n c: LinearCurve2d<XT, YT>,\n): LinearCurve2d<XT & Monotonic, YT & Monotonic> =>\n isMonotonic(c) ? c : fail('linear curve is not monotonic in both axes')\n\n/** @internal */\nexport const asIncreasing = <XT, YT>(\n c: LinearCurve2d<XT, YT>,\n): LinearCurve2d<XT & Increasing, YT & Increasing> =>\n isIncreasing(c) ? c : fail('linear curve is not increasing in both axes')\n\n/** @internal */\nexport const asDecreasing = <XT, YT>(\n c: LinearCurve2d<XT, YT>,\n): LinearCurve2d<XT & Decreasing, YT & Decreasing> =>\n isDecreasing(c) ? c : fail('linear curve is not decreasing in both axes')\n","import type { Interval2d } from '../interval/interval2d.ts'\nimport type { TwoDimensional } from '../dimensions.ts'\nimport type { Closed, Interval } from '../interval/interval.ts'\nimport type { Pipeable } from '../utils.ts'\nimport type { LinearPolynomial } from '../polynomial/linear.ts'\nimport type { Decreasing, Increasing, Monotonic } from '../polynomial/traits.ts'\nimport type * as Solution from '../solution/solution.ts'\nimport type { Vector2 } from '../vector/vector2.ts'\nimport type { LinearCurve2dTypeId } from './linear2d.internal.ts'\nimport * as internal from './linear2d.internal.ts'\n\nexport type { Monotonic, Increasing, Decreasing } from '../polynomial/traits.ts'\n\n/**\n * A linear curve in 2D space.\n *\n * All fields are readonly and immutable, and all operations create new instances.\n *\n * The two type parameters carry the trait sets of the curve's per-axis\n * polynomials. Refiners like `isMonotonic` lift each axis's monotonicity into\n * the curve's combined trait set.\n *\n * @since 1.0.0\n */\nexport interface LinearCurve2d<out XTraits = unknown, out YTraits = unknown>\n extends Pipeable, TwoDimensional<LinearPolynomial<XTraits>, LinearPolynomial<YTraits>> {\n readonly [LinearCurve2dTypeId]: LinearCurve2dTypeId\n}\n\n/**\n * Creates a new `LinearCurve2d` instance from polynomial parameters.\n *\n * @param x - The x polynomial.\n * @param y - The y polynomial.\n * @returns A new `LinearCurve2d` instance.\n * @since 1.0.0\n */\nexport const fromPolynomials: (x: LinearPolynomial, y: LinearPolynomial) => LinearCurve2d =\n internal.fromPolynomials\n\n/**\n * Creates a new `LinearCurve2d` instance from monomial coefficient vectors.\n *\n * Each argument bundles the per-axis coefficient at the given power: `c0`\n * holds the x⁰ term, `c1` holds the x¹ term. The resulting curve evaluates to\n * `c0 + c1·t` per axis.\n *\n * @param c0 - The x⁰ coefficients (x and y).\n * @param c1 - The x¹ coefficients (x and y).\n * @returns A new `LinearCurve2d` instance.\n * @since 2.0.0\n */\nexport const fromCoefficients: (c0: Vector2, c1: Vector2) => LinearCurve2d =\n internal.fromCoefficients\n\n/**\n * Creates a new `LinearCurve2d` instance from a pair of endpoints.\n *\n * `p0` is the curve at `t = 0`, `p1` is the curve at `t = 1`. The\n * implementation converts to the curve's internal monomial form (slope-form\n * polynomial in `t`) in closed form.\n *\n * @param p0 - The curve's start point.\n * @param p1 - The curve's end point.\n * @returns A new `LinearCurve2d` instance whose curve matches the line from `p0` to `p1`.\n * @since 2.0.0\n */\nexport const fromEndpoints: (p0: Vector2, p1: Vector2) => LinearCurve2d = internal.fromEndpoints\n\n/**\n * Checks if a value is a `LinearCurve2d`.\n *\n * @param c - The value to check.\n * @returns `true` if the value is a `LinearCurve2d`, `false` otherwise.\n * @since 1.0.0\n */\nexport const isLinearCurve2d: (c: unknown) => c is LinearCurve2d = internal.isLinearCurve2d\n\n/**\n * Gets the derivative of a linear curve as a vector\n *\n * @param c - The linear curve to get the derivative of.\n * @returns The derivative of the linear curve as a vector.\n * @since 1.0.0\n */\nexport const derivative: (c: LinearCurve2d) => Vector2 = internal.derivative\n\nexport const solve: {\n /**\n * Solves the linear curve for a given parameter t.\n *\n * @param t - The parameter value.\n * @returns A function that takes a linear curve and returns the point on the curve at parameter t.\n * @since 1.0.0\n */\n (t: number): (c: LinearCurve2d) => Vector2\n /**\n * Solves the linear curve for a given parameter t.\n *\n * @param c - The linear curve to solve.\n * @param t - The parameter value.\n * @returns The point on the curve at parameter t.\n * @since 1.0.0\n */\n (c: LinearCurve2d, t: number): Vector2\n} = internal.solve\n\nexport const length: {\n /**\n * Calculates (approximates) the length of a linear curve.\n *\n * @param c - The linear curve to calculate the length of.\n * @param i - The interval to calculate the length over.\n * @returns The length of the linear curve over the given interval.\n * @since 1.0.0\n */\n (c: LinearCurve2d, i: Interval): number\n /**\n * Calculates (approximates) the length of a linear curve.\n *\n * @param i - The interval to calculate the length over.\n * @returns A function that takes a linear curve and returns the length of the linear curve over the given interval.\n * @since 1.0.0\n */\n (i: Interval): (c: LinearCurve2d) => number\n} = internal.length\n\n/**\n * Computes the axis-aligned bounding box of the curve over its parameter\n * domain `[0, 1]`. For a linear curve this is the closed box enclosing the\n * two endpoints.\n *\n * @param c - The linear curve.\n * @returns A closed `Box2d` enclosing the curve.\n * @since 2.0.0\n */\nexport const boundingBox: (c: LinearCurve2d) => Interval2d<Closed, Closed> = internal.boundingBox\n\nexport const solveAtX: {\n /**\n * Evaluates the curve's y value at a given x. A linear curve crosses any\n * vertical line at most once (within the curve's parameter domain `[0, 1]`),\n * so the result is at most one y. Returns the empty tuple when x is outside\n * the curve's range or when the curve's x polynomial is constant.\n *\n * @param c - The linear curve.\n * @param x - The x coordinate.\n * @returns The y value at x, or empty when x is undefined for this curve.\n * @since 2.0.0\n */\n <XT, YT>(c: LinearCurve2d<XT, YT>, x: number): Solution.AtMostOne<number>\n /** @since 2.0.0 */\n (x: number): <XT, YT>(c: LinearCurve2d<XT, YT>) => Solution.AtMostOne<number>\n} = internal.solveAtX as never\n\nexport const solveAtY: {\n /**\n * Evaluates the curve's x value at a given y. A linear curve crosses any\n * horizontal line at most once (within the curve's parameter domain\n * `[0, 1]`), so the result is at most one x.\n *\n * @param c - The linear curve.\n * @param y - The y coordinate.\n * @returns The x value at y, or empty when y is undefined for this curve.\n * @since 2.0.0\n */\n <XT, YT>(c: LinearCurve2d<XT, YT>, y: number): Solution.AtMostOne<number>\n /** @since 2.0.0 */\n (y: number): <XT, YT>(c: LinearCurve2d<XT, YT>) => Solution.AtMostOne<number>\n} = internal.solveAtY as never\n\n/**\n * Type-narrowing predicate: refines both axes' traits to include `Monotonic`\n * when both the x and y polynomials are strictly monotonic. When both axes\n * are monotonic, the curve is invertible in either direction.\n *\n * For checking only one axis, call the polynomial-level refiner directly:\n * `LinearPolynomial.isMonotonic(curve.x)`.\n *\n * @since 2.0.0\n */\nexport const isMonotonic: <XT, YT>(\n c: LinearCurve2d<XT, YT>,\n) => c is LinearCurve2d<XT & Monotonic, YT & Monotonic> = internal.isMonotonic\n\n/**\n * Type-narrowing predicate: refines both axes' traits to include `Increasing`.\n *\n * @since 2.0.0\n */\nexport const isIncreasing: <XT, YT>(\n c: LinearCurve2d<XT, YT>,\n) => c is LinearCurve2d<XT & Increasing, YT & Increasing> = internal.isIncreasing\n\n/**\n * Type-narrowing predicate: refines both axes' traits to include `Decreasing`.\n *\n * @since 2.0.0\n */\nexport const isDecreasing: <XT, YT>(\n c: LinearCurve2d<XT, YT>,\n) => c is LinearCurve2d<XT & Decreasing, YT & Decreasing> = internal.isDecreasing\n\n/**\n * Asserts monotonicity in both axes, throwing on failure.\n *\n * @since 2.0.0\n */\nexport const asMonotonic: <XT, YT>(\n c: LinearCurve2d<XT, YT>,\n) => LinearCurve2d<XT & Monotonic, YT & Monotonic> = internal.asMonotonic\n\n/**\n * Asserts that both axes are strictly increasing, throwing on failure.\n *\n * @since 2.0.0\n */\nexport const asIncreasing: <XT, YT>(\n c: LinearCurve2d<XT, YT>,\n) => LinearCurve2d<XT & Increasing, YT & Increasing> = internal.asIncreasing\n\n/**\n * Asserts that both axes are strictly decreasing, throwing on failure.\n *\n * @since 2.0.0\n */\nexport const asDecreasing: <XT, YT>(\n c: LinearCurve2d<XT, YT>,\n) => LinearCurve2d<XT & Decreasing, YT & Decreasing> = internal.asDecreasing\n","import * as Interval2d from '../interval/interval2d.ts'\nimport * as Interval from '../interval/interval.ts'\nimport type { Decreasing, Increasing, Monotonic } from '../polynomial/traits.ts'\nimport {\n GL32_W0,\n GL32_W1,\n GL32_W2,\n GL32_W3,\n GL32_W4,\n GL32_W5,\n GL32_W6,\n GL32_W7,\n GL32_W8,\n GL32_W9,\n GL32_W10,\n GL32_W11,\n GL32_W12,\n GL32_W13,\n GL32_W14,\n GL32_W15,\n GL32_X0,\n GL32_X1,\n GL32_X2,\n GL32_X3,\n GL32_X4,\n GL32_X5,\n GL32_X6,\n GL32_X7,\n GL32_X8,\n GL32_X9,\n GL32_X10,\n GL32_X11,\n GL32_X12,\n GL32_X13,\n GL32_X14,\n GL32_X15,\n} from '../length.ts'\nimport { dual, Pipeable } from '../utils.ts'\nimport * as LinearPolynomial from '../polynomial/linear.ts'\nimport * as QuadraticPolynomial from '../polynomial/quadratic.ts'\nimport * as Solution from '../solution/solution.ts'\nimport * as Vector2 from '../vector/vector2.ts'\nimport * as LinearCurve2d from './linear2d.ts'\nimport type { QuadraticCurve2d } from './quadratic2d.ts'\n\nexport const QuadraticCurve2dTypeId: unique symbol = Symbol('curvy/curve/quadratic2d')\nexport type QuadraticCurve2dTypeId = typeof QuadraticCurve2dTypeId\n\n/** @internal */\nexport class QuadraticCurve2dImpl extends Pipeable implements QuadraticCurve2d<unknown, unknown> {\n readonly [QuadraticCurve2dTypeId]: QuadraticCurve2dTypeId = QuadraticCurve2dTypeId\n\n readonly x: QuadraticPolynomial.QuadraticPolynomial\n readonly y: QuadraticPolynomial.QuadraticPolynomial\n\n constructor(\n c0: QuadraticPolynomial.QuadraticPolynomial,\n c1: QuadraticPolynomial.QuadraticPolynomial,\n ) {\n super()\n this.x = c0\n this.y = c1\n }\n\n get [0]() {\n return this.x\n }\n\n get [1]() {\n return this.y\n }\n}\n\n/** @internal */\nexport const fromPolynomials: (\n c0: QuadraticPolynomial.QuadraticPolynomial,\n c1: QuadraticPolynomial.QuadraticPolynomial,\n) => QuadraticCurve2d = (c0, c1) => new QuadraticCurve2dImpl(c0, c1)\n\n/** @internal */\nexport const fromCoefficients: (\n c0: Vector2.Vector2,\n c1: Vector2.Vector2,\n c2: Vector2.Vector2,\n) => QuadraticCurve2d = (c0, c1, c2) =>\n new QuadraticCurve2dImpl(\n QuadraticPolynomial.make(c0.x, c1.x, c2.x),\n QuadraticPolynomial.make(c0.y, c1.y, c2.y),\n )\n\n// Quadratic Bernstein basis: B(t) = (1-t)²·p0 + 2(1-t)t·p1 + t²·p2\n// Expanding to monomial form gives:\n// c0 = p0\n// c1 = -2p0 + 2p1\n// c2 = p0 - 2p1 + p2\n/** @internal */\nexport const fromBezierPoints: (\n p0: Vector2.Vector2,\n p1: Vector2.Vector2,\n p2: Vector2.Vector2,\n) => QuadraticCurve2d = (p0, p1, p2) =>\n new QuadraticCurve2dImpl(\n QuadraticPolynomial.make(p0.x, -2 * p0.x + 2 * p1.x, p0.x - 2 * p1.x + p2.x),\n QuadraticPolynomial.make(p0.y, -2 * p0.y + 2 * p1.y, p0.y - 2 * p1.y + p2.y),\n )\n\n/** @internal */\nexport const isQuadraticCurve2d = (c: unknown): c is QuadraticCurve2d =>\n typeof c === 'object' && c !== null && QuadraticCurve2dTypeId in c\n\n/** @internal */\nexport const solve = dual<\n (t: number) => (c: QuadraticCurve2d) => Vector2.Vector2,\n (c: QuadraticCurve2d, t: number) => Vector2.Vector2\n>(2, (c: QuadraticCurve2d, t: number) =>\n Vector2.make(QuadraticPolynomial.solve(c.x, t), QuadraticPolynomial.solve(c.y, t)),\n)\n\n// solveAtX: invert the x polynomial to find ts within the unit interval, then\n// evaluate y at each surviving t. Result order matches solveInverse order\n// (t-ascending).\n/** @internal */\nexport const solveAtX = dual(2, (c: QuadraticCurve2d, x: number) => {\n const ts = Solution.clip(QuadraticPolynomial.solveInverse(c.x, x), Interval.unit)\n return Solution.map(ts, (t) => QuadraticPolynomial.solve(c.y, t))\n})\n\n/** @internal */\nexport const solveAtY = dual(2, (c: QuadraticCurve2d, y: number) => {\n const ts = Solution.clip(QuadraticPolynomial.solveInverse(c.y, y), Interval.unit)\n return Solution.map(ts, (t) => QuadraticPolynomial.solve(c.x, t))\n})\n\n/** @internal */\nexport const derivative = (c: QuadraticCurve2d) =>\n LinearCurve2d.fromPolynomials(\n QuadraticPolynomial.derivative(c.x),\n QuadraticPolynomial.derivative(c.y),\n )\n\n/** @internal */\nexport const length = dual(2, (c: QuadraticCurve2d, i: Interval.Interval) => {\n if (Interval.size(i) === 0) {\n return 0\n }\n\n if (c.x.c2 === 0 && c.y.c2 === 0) {\n return LinearCurve2d.length(\n LinearCurve2d.fromPolynomials(\n LinearPolynomial.make(c.x.c0, c.x.c1),\n LinearPolynomial.make(c.y.c0, c.y.c1),\n ),\n i,\n )\n }\n\n const d = derivative(c)\n\n const { scale, shift } = Interval.scaleShift(Interval.biunit, i)\n\n return (\n (GL32_W0 * Vector2.magnitude(LinearCurve2d.solve(d, shift + scale * -GL32_X0)) +\n GL32_W0 * Vector2.magnitude(LinearCurve2d.solve(d, shift + scale * GL32_X0)) +\n GL32_W1 * Vector2.magnitude(LinearCurve2d.solve(d, shift + scale * -GL32_X1)) +\n GL32_W1 * Vector2.magnitude(LinearCurve2d.solve(d, shift + scale * GL32_X1)) +\n GL32_W2 * Vector2.magnitude(LinearCurve2d.solve(d, shift + scale * -GL32_X2)) +\n GL32_W2 * Vector2.magnitude(LinearCurve2d.solve(d, shift + scale * GL32_X2)) +\n GL32_W3 * Vector2.magnitude(LinearCurve2d.solve(d, shift + scale * -GL32_X3)) +\n GL32_W3 * Vector2.magnitude(LinearCurve2d.solve(d, shift + scale * GL32_X3)) +\n GL32_W4 * Vector2.magnitude(LinearCurve2d.solve(d, shift + scale * -GL32_X4)) +\n GL32_W4 * Vector2.magnitude(LinearCurve2d.solve(d, shift + scale * GL32_X4)) +\n GL32_W5 * Vector2.magnitude(LinearCurve2d.solve(d, shift + scale * -GL32_X5)) +\n GL32_W5 * Vector2.magnitude(LinearCurve2d.solve(d, shift + scale * GL32_X5)) +\n GL32_W6 * Vector2.magnitude(LinearCurve2d.solve(d, shift + scale * -GL32_X6)) +\n GL32_W6 * Vector2.magnitude(LinearCurve2d.solve(d, shift + scale * GL32_X6)) +\n GL32_W7 * Vector2.magnitude(LinearCurve2d.solve(d, shift + scale * -GL32_X7)) +\n GL32_W7 * Vector2.magnitude(LinearCurve2d.solve(d, shift + scale * GL32_X7)) +\n GL32_W8 * Vector2.magnitude(LinearCurve2d.solve(d, shift + scale * -GL32_X8)) +\n GL32_W8 * Vector2.magnitude(LinearCurve2d.solve(d, shift + scale * GL32_X8)) +\n GL32_W9 * Vector2.magnitude(LinearCurve2d.solve(d, shift + scale * -GL32_X9)) +\n GL32_W9 * Vector2.magnitude(LinearCurve2d.solve(d, shift + scale * GL32_X9)) +\n GL32_W10 * Vector2.magnitude(LinearCurve2d.solve(d, shift + scale * -GL32_X10)) +\n GL32_W10 * Vector2.magnitude(LinearCurve2d.solve(d, shift + scale * GL32_X10)) +\n GL32_W11 * Vector2.magnitude(LinearCurve2d.solve(d, shift + scale * -GL32_X11)) +\n GL32_W11 * Vector2.magnitude(LinearCurve2d.solve(d, shift + scale * GL32_X11)) +\n GL32_W12 * Vector2.magnitude(LinearCurve2d.solve(d, shift + scale * -GL32_X12)) +\n GL32_W12 * Vector2.magnitude(LinearCurve2d.solve(d, shift + scale * GL32_X12)) +\n GL32_W13 * Vector2.magnitude(LinearCurve2d.solve(d, shift + scale * -GL32_X13)) +\n GL32_W13 * Vector2.magnitude(LinearCurve2d.solve(d, shift + scale * GL32_X13)) +\n GL32_W14 * Vector2.magnitude(LinearCurve2d.solve(d, shift + scale * -GL32_X14)) +\n GL32_W14 * Vector2.magnitude(LinearCurve2d.solve(d, shift + scale * GL32_X14)) +\n GL32_W15 * Vector2.magnitude(LinearCurve2d.solve(d, shift + scale * -GL32_X15)) +\n GL32_W15 * Vector2.magnitude(LinearCurve2d.solve(d, shift + scale * GL32_X15))) *\n scale\n )\n})\n\n/** @internal */\nexport const curvature = dual(2, (c: QuadraticCurve2d, t: number) => {\n const d = derivative(c)\n const v = LinearCurve2d.solve(d, t)\n const a = LinearCurve2d.derivative(d)\n\n const vMag = Vector2.magnitude(v)\n\n if (vMag === 0) {\n return 0\n }\n\n return Math.abs(Vector2.cross(v, a)) / vMag ** 3\n})\n\n/** @internal */\nexport const boundingBox = (\n c: QuadraticCurve2d,\n): Interval2d.Interval2d<Interval.Closed, Interval.Closed> =>\n Interval2d.make(QuadraticPolynomial.unitRange(c.x), QuadraticPolynomial.unitRange(c.y))\n\n// Combined trait refiners — fan out the polynomial-level check across both\n// axes, over the unit interval. For per-axis checks, users can call\n// `QuadraticPolynomial.isMonotonic(c.x, Interval.unit)` directly.\n/** @internal */\nexport const isMonotonic = <XT, YT>(\n c: QuadraticCurve2d<XT, YT>,\n): c is QuadraticCurve2d<XT & Monotonic, YT & Monotonic> =>\n QuadraticPolynomial.isMonotonic(c.x, Interval.unit) &&\n QuadraticPolynomial.isMonotonic(c.y, Interval.unit)\n\n/** @internal */\nexport const isIncreasing = <XT, YT>(\n c: QuadraticCurve2d<XT, YT>,\n): c is QuadraticCurve2d<XT & Increasing, YT & Increasing> =>\n QuadraticPolynomial.isIncreasing(c.x, Interval.unit) &&\n QuadraticPolynomial.isIncreasing(c.y, Interval.unit)\n\n/** @internal */\nexport const isDecreasing = <XT, YT>(\n c: QuadraticCurve2d<XT, YT>,\n): c is QuadraticCurve2d<XT & Decreasing, YT & Decreasing> =>\n QuadraticPolynomial.isDecreasing(c.x, Interval.unit) &&\n QuadraticPolynomial.isDecreasing(c.y, Interval.unit)\n\nconst fail = (m: string): never => {\n throw new Error(m)\n}\n\n/** @internal */\nexport const asMonotonic = <XT, YT>(\n c: QuadraticCurve2d<XT, YT>,\n): QuadraticCurve2d<XT & Monotonic, YT & Monotonic> =>\n isMonotonic(c) ? c : fail('quadratic curve is not monotonic in both axes')\n\n/** @internal */\nexport const asIncreasing = <XT, YT>(\n c: QuadraticCurve2d<XT, YT>,\n): QuadraticCurve2d<XT & Increasing, YT & Increasing> =>\n isIncreasing(c) ? c : fail('quadratic curve is not increasing in both axes')\n\n/** @internal */\nexport const asDecreasing = <XT, YT>(\n c: QuadraticCurve2d<XT, YT>,\n): QuadraticCurve2d<XT & Decreasing, YT & Decreasing> =>\n isDecreasing(c) ? c : fail('quadratic curve is not decreasing in both axes')\n","import type { Interval2d } from '../interval/interval2d.ts'\nimport type { TwoDimensional } from '../dimensions.ts'\nimport type { Closed, Interval } from '../interval/interval.ts'\nimport type { Pipeable } from '../utils.ts'\nimport type { QuadraticPolynomial } from '../polynomial/quadratic.ts'\nimport type { Decreasing, Increasing, Monotonic } from '../polynomial/traits.ts'\nimport type * as Solution from '../solution/solution.ts'\nimport type { Vector2 } from '../vector/vector2.ts'\nimport type { LinearCurve2d } from './linear2d.ts'\nimport type { QuadraticCurve2dTypeId } from './quadratic2d.internal.ts'\nimport * as internal from './quadratic2d.internal.ts'\n\nexport type { Monotonic, Increasing, Decreasing } from '../polynomial/traits.ts'\n\n/**\n * A quadratic curve in 2D space.\n *\n * All fields are readonly and immutable, and all operations create new instances.\n *\n * The two type parameters carry the trait sets of the curve's per-axis\n * polynomials. Refiners check monotonicity over the unit interval `[0, 1]` —\n * the curve's natural parameter domain.\n *\n * @since 1.0.0\n */\nexport interface QuadraticCurve2d<out XTraits = unknown, out YTraits = unknown>\n extends Pipeable, TwoDimensional<QuadraticPolynomial<XTraits>, QuadraticPolynomial<YTraits>> {\n readonly [QuadraticCurve2dTypeId]: QuadraticCurve2dTypeId\n}\n\n/**\n * Creates a new `QuadraticCurve2d` instance from polynomial parameters.\n *\n * @param c0 - The x polynomial.\n * @param c1 - The y polynomial.\n * @returns A new `QuadraticCurve2d` instance.\n * @since 1.0.0\n */\nexport const fromPolynomials: (\n c0: QuadraticPolynomial,\n c1: QuadraticPolynomial,\n) => QuadraticCurve2d = internal.fromPolynomials\n\n/**\n * Creates a new `QuadraticCurve2d` instance from monomial coefficient vectors.\n *\n * Each argument bundles the per-axis coefficient at the given power: `c0`\n * holds the x⁰ term, `c1` holds the x¹ term, and so on. The resulting curve\n * evaluates to `c0 + c1·t + c2·t²` per axis.\n *\n * @param c0 - The x⁰ coefficients (x and y).\n * @param c1 - The x¹ coefficients (x and y).\n * @param c2 - The x² coefficients (x and y).\n * @returns A new `QuadraticCurve2d` instance.\n * @since 2.0.0\n */\nexport const fromCoefficients: (c0: Vector2, c1: Vector2, c2: Vector2) => QuadraticCurve2d =\n internal.fromCoefficients\n\n/**\n * Creates a new `QuadraticCurve2d` instance from quadratic Bézier control\n * points.\n *\n * The three arguments are the Bernstein-basis control points: `p0` and `p2`\n * are the curve's endpoints and `p1` is the off-curve control handle. The\n * implementation converts to the curve's internal monomial form in closed\n * form.\n *\n * @param p0 - The first control point (curve start).\n * @param p1 - The second control point (control handle).\n * @param p2 - The third control point (curve end).\n * @returns A new `QuadraticCurve2d` instance whose curve matches the given Bézier.\n * @since 2.0.0\n */\nexport const fromBezierPoints: (p0: Vector2, p1: Vector2, p2: Vector2) => QuadraticCurve2d =\n internal.fromBezierPoints\n\n/**\n * Checks if a value is a `QuadraticCurve2d`.\n *\n * @param c - The value to check.\n * @returns `true` if the value is a `QuadraticCurve2d`, `false` otherwise.\n * @since 1.0.0\n */\nexport const isQuadraticCurve2d: (c: unknown) => c is QuadraticCurve2d = internal.isQuadraticCurve2d\n\nexport const solve: {\n /**\n * Solves the quadratic curve for a given parameter t.\n *\n * @param t - The parameter value.\n * @returns A function that takes a quadratic curve and returns the point on the curve at parameter t.\n * @since 1.0.0\n */\n (t: number): (c: QuadraticCurve2d) => Vector2\n /**\n * Solves the quadratic curve for a given parameter t.\n *\n * @param c - The quadratic curve to solve.\n * @param t - The parameter value.\n * @returns The point on the curve at parameter t.\n * @since 1.0.0\n */\n (c: QuadraticCurve2d, t: number): Vector2\n} = internal.solve\n\nexport const length: {\n /**\n * Computes the length of the quadratic curve over a given interval.\n *\n * @param c - The quadratic curve to compute the length of.\n * @param i - The interval over which to compute the length.\n * @returns The length of the quadratic curve over the interval.\n * @since 1.0.0\n */\n (c: QuadraticCurve2d, i: Interval): number\n /**\n * Computes the length of the quadratic curve over a given interval.\n *\n * @param i - The interval over which to compute the length.\n * @returns A function that takes a quadratic curve and returns the length of the curve over the interval.\n * @since 1.0.0\n */\n (i: Interval): (c: QuadraticCurve2d) => number\n} = internal.length\n\nexport const solveAtX: {\n /**\n * Evaluates the curve's y values at a given x. Because the x polynomial is\n * `Monotonic`, the inverse has at most one solution — at most one y value.\n *\n * @param c - The quadratic curve.\n * @param x - The x coordinate.\n * @returns Zero or one y values, in t-ascending order.\n * @since 2.0.0\n */\n <XT extends Monotonic, YT>(c: QuadraticCurve2d<XT, YT>, x: number): Solution.AtMostOne<number>\n /**\n * Evaluates the curve's y values at a given x. The result is the y values\n * the curve passes through where x(t) = the given x — up to two solutions\n * for a quadratic curve.\n *\n * @param c - The quadratic curve.\n * @param x - The x coordinate.\n * @returns The y values at x, in t-ascending order.\n * @since 2.0.0\n */\n <XT, YT>(c: QuadraticCurve2d<XT, YT>, x: number): Solution.AtMostTwo<number>\n /** @since 2.0.0 */\n (x: number): {\n <XT extends Monotonic, YT>(c: QuadraticCurve2d<XT, YT>): Solution.AtMostOne<number>\n <XT, YT>(c: QuadraticCurve2d<XT, YT>): Solution.AtMostTwo<number>\n }\n} = internal.solveAtX as never\n\nexport const solveAtY: {\n /**\n * Evaluates the curve's x values at a given y. Because the y polynomial is\n * `Monotonic`, the inverse has at most one solution.\n *\n * @param c - The quadratic curve.\n * @param y - The y coordinate.\n * @returns Zero or one x values, in t-ascending order.\n * @since 2.0.0\n */\n <XT, YT extends Monotonic>(c: QuadraticCurve2d<XT, YT>, y: number): Solution.AtMostOne<number>\n /**\n * Evaluates the curve's x values at a given y. The result is the x values\n * the curve passes through where y(t) = the given y — up to two solutions\n * for a quadratic curve.\n *\n * @param c - The quadratic curve.\n * @param y - The y coordinate.\n * @returns The x values at y, in t-ascending order.\n * @since 2.0.0\n */\n <XT, YT>(c: QuadraticCurve2d<XT, YT>, y: number): Solution.AtMostTwo<number>\n /** @since 2.0.0 */\n (y: number): {\n <XT, YT extends Monotonic>(c: QuadraticCurve2d<XT, YT>): Solution.AtMostOne<number>\n <XT, YT>(c: QuadraticCurve2d<XT, YT>): Solution.AtMostTwo<number>\n }\n} = internal.solveAtY as never\n\n/**\n * Computes the derivative of a quadratic curve.\n *\n * @param c - The quadratic curve to compute the derivative of.\n * @returns The derivative of the quadratic curve as a linear curve.\n * @since 1.0.0\n */\nexport const derivative: (c: QuadraticCurve2d) => LinearCurve2d = internal.derivative\n\nexport const curvature: {\n /**\n * Computes the curvature of the quadratic curve at a given parameter t.\n *\n * @param c - The quadratic curve to compute the curvature for.\n * @param t - The parameter value.\n * @returns The curvature of the quadratic curve at parameter t.\n * @since 1.0.0\n */\n (c: QuadraticCurve2d, t: number): number\n /**\n * Computes the curvature of the quadratic curve at a given parameter t.\n *\n * @param t - The parameter value.\n * @returns A function that takes a quadratic curve and returns the curvature of the curve at parameter t.\n * @since 1.0.0\n */\n (t: number): (c: QuadraticCurve2d) => number\n} = internal.curvature\n\n/**\n * Computes the axis-aligned bounding box of the curve over its parameter\n * domain `[0, 1]`. Accounts for interior extrema, so the box is tight against\n * the curve and not just the control polygon.\n *\n * @param c - The quadratic curve.\n * @returns A closed `Box2d` enclosing the curve.\n * @since 2.0.0\n */\nexport const boundingBox: (c: QuadraticCurve2d) => Interval2d<Closed, Closed> = internal.boundingBox\n\n/**\n * Type-narrowing predicate: refines both axes' traits to include `Monotonic`\n * when both x and y polynomials are monotonic over the unit interval `[0, 1]`.\n *\n * For checking only one axis, call the polynomial-level refiner directly:\n * `QuadraticPolynomial.isMonotonic(curve.x, Interval.unit)`.\n *\n * @since 2.0.0\n */\nexport const isMonotonic: <XT, YT>(\n c: QuadraticCurve2d<XT, YT>,\n) => c is QuadraticCurve2d<XT & Monotonic, YT & Monotonic> = internal.isMonotonic\n\n/** @since 2.0.0 */\nexport const isIncreasing: <XT, YT>(\n c: QuadraticCurve2d<XT, YT>,\n) => c is QuadraticCurve2d<XT & Increasing, YT & Increasing> = internal.isIncreasing\n\n/** @since 2.0.0 */\nexport const isDecreasing: <XT, YT>(\n c: QuadraticCurve2d<XT, YT>,\n) => c is QuadraticCurve2d<XT & Decreasing, YT & Decreasing> = internal.isDecreasing\n\n/** @since 2.0.0 */\nexport const asMonotonic: <XT, YT>(\n c: QuadraticCurve2d<XT, YT>,\n) => QuadraticCurve2d<XT & Monotonic, YT & Monotonic> = internal.asMonotonic\n\n/** @since 2.0.0 */\nexport const asIncreasing: <XT, YT>(\n c: QuadraticCurve2d<XT, YT>,\n) => QuadraticCurve2d<XT & Increasing, YT & Increasing> = internal.asIncreasing\n\n/** @since 2.0.0 */\nexport const asDecreasing: <XT, YT>(\n c: QuadraticCurve2d<XT, YT>,\n) => QuadraticCurve2d<XT & Decreasing, YT & Decreasing> = internal.asDecreasing\n","import * as Interval2d from '../interval/interval2d.ts'\nimport * as Characteristic from '../characteristic/characteristic.ts'\nimport * as Interval from '../interval/interval.ts'\nimport {\n GL32_W0,\n GL32_W1,\n GL32_W2,\n GL32_W3,\n GL32_W4,\n GL32_W5,\n GL32_W6,\n GL32_W7,\n GL32_W8,\n GL32_W9,\n GL32_W10,\n GL32_W11,\n GL32_W12,\n GL32_W13,\n GL32_W14,\n GL32_W15,\n GL32_X0,\n GL32_X1,\n GL32_X2,\n GL32_X3,\n GL32_X4,\n GL32_X5,\n GL32_X6,\n GL32_X7,\n GL32_X8,\n GL32_X9,\n GL32_X10,\n GL32_X11,\n GL32_X12,\n GL32_X13,\n GL32_X14,\n GL32_X15,\n} from '../length.ts'\nimport { dual, Pipeable } from '../utils.ts'\nimport * as CubicPolynomial from '../polynomial/cubic.ts'\nimport * as QuadraticPolynomial from '../polynomial/quadratic.ts'\nimport type { Decreasing, Increasing, Monotonic } from '../polynomial/traits.ts'\nimport * as Solution from '../solution/solution.ts'\nimport * as Vector2 from '../vector/vector2.ts'\nimport * as Vector4 from '../vector/vector4.ts'\nimport type { CubicCurve2d } from './cubic2d.ts'\nimport * as LinearCurve2d from './linear2d.ts'\nimport * as QuadraticCurve2d from './quadratic2d.ts'\n\nexport const CubicCurve2dTypeId: unique symbol = Symbol('curvy/curve/cubic2d')\nexport type CubicCurve2dTypeId = typeof CubicCurve2dTypeId\n\n/** @internal */\nexport class CubicCurve2dImpl extends Pipeable implements CubicCurve2d<unknown, unknown> {\n readonly [CubicCurve2dTypeId]: CubicCurve2dTypeId = CubicCurve2dTypeId\n\n readonly x: CubicPolynomial.CubicPolynomial\n readonly y: CubicPolynomial.CubicPolynomial\n\n constructor(c0: CubicPolynomial.CubicPolynomial, c1: CubicPolynomial.CubicPolynomial) {\n super()\n this.x = c0\n this.y = c1\n }\n\n get [0]() {\n return this.x\n }\n\n get [1]() {\n return this.y\n }\n}\n\n/** @internal */\nexport const fromPolynomials: (\n c0: CubicPolynomial.CubicPolynomial,\n c1: CubicPolynomial.CubicPolynomial,\n) => CubicCurve2d = (c0, c1) => new CubicCurve2dImpl(c0, c1)\n\n/** @internal */\nexport const fromCoefficients: (\n c0: Vector2.Vector2,\n c1: Vector2.Vector2,\n c2: Vector2.Vector2,\n c3: Vector2.Vector2,\n) => CubicCurve2d = (c0, c1, c2, c3) =>\n new CubicCurve2dImpl(\n CubicPolynomial.make(c0.x, c1.x, c2.x, c3.x),\n CubicPolynomial.make(c0.y, c1.y, c2.y, c3.y),\n )\n\n// Applies the cubic Bézier characteristic matrix to the per-axis control\n// vectors, producing monomial polynomials. The matrix encodes the cubic\n// Bernstein → monomial expansion `(c₀, c₁, c₂, c₃) = M · (p₀, p₁, p₂, p₃)`\n// for each axis independently.\n/** @internal */\nexport const fromBezierPoints: (\n p0: Vector2.Vector2,\n p1: Vector2.Vector2,\n p2: Vector2.Vector2,\n p3: Vector2.Vector2,\n) => CubicCurve2d = (p0, p1, p2, p3) => {\n const channels = Vector4.transpose([p0, p1, p2, p3], (p) => [p.x, p.y])\n return new CubicCurve2dImpl(...Characteristic.apply(Characteristic.cubicBezier, ...channels))\n}\n\n/** @internal */\nexport const isCubicCurve2d = (c: unknown): c is CubicCurve2d =>\n typeof c === 'object' && c !== null && CubicCurve2dTypeId in c\n\n/** @internal */\nexport const solve = dual<\n (t: number) => (c: CubicCurve2d) => Vector2.Vector2,\n (c: CubicCurve2d, t: number) => Vector2.Vector2\n>(2, (c: CubicCurve2d, t: number) =>\n Vector2.make(CubicPolynomial.solve(c.x, t), CubicPolynomial.solve(c.y, t)),\n)\n\n// solveAtX: invert the x polynomial to find ts within the unit interval, then\n// evaluate y at each surviving t. Result order matches solveInverse order\n// (t-ascending).\n/** @internal */\nexport const solveAtX = dual(2, (c: CubicCurve2d, x: number) => {\n const ts = Solution.clip(CubicPolynomial.solveInverse(c.x, x), Interval.unit)\n return Solution.map(ts, (t) => CubicPolynomial.solve(c.y, t))\n})\n\n/** @internal */\nexport const solveAtY = dual(2, (c: CubicCurve2d, y: number) => {\n const ts = Solution.clip(CubicPolynomial.solveInverse(c.y, y), Interval.unit)\n return Solution.map(ts, (t) => CubicPolynomial.solve(c.x, t))\n})\n\n/** @internal */\nexport const derivative = (c: CubicCurve2d) =>\n QuadraticCurve2d.fromPolynomials(CubicPolynomial.derivative(c.x), CubicPolynomial.derivative(c.y))\n\n/** @internal */\nexport const length = dual(2, (c: CubicCurve2d, i: Interval.Interval) => {\n if (Interval.size(i) === 0) {\n return 0\n }\n\n if (c.x.c3 === 0 && c.y.c3 === 0) {\n return QuadraticCurve2d.length(\n QuadraticCurve2d.fromPolynomials(\n QuadraticPolynomial.make(c.x.c0, c.x.c1, c.x.c2),\n QuadraticPolynomial.make(c.y.c0, c.y.c1, c.y.c2),\n ),\n i,\n )\n }\n\n const d = derivative(c)\n\n const { scale, shift } = Interval.scaleShift(Interval.biunit, i)\n\n return (\n (GL32_W0 * Vector2.magnitude(QuadraticCurve2d.solve(d, shift + scale * -GL32_X0)) +\n GL32_W0 * Vector2.magnitude(QuadraticCurve2d.solve(d, shift + scale * GL32_X0)) +\n GL32_W1 * Vector2.magnitude(QuadraticCurve2d.solve(d, shift + scale * -GL32_X1)) +\n GL32_W1 * Vector2.magnitude(QuadraticCurve2d.solve(d, shift + scale * GL32_X1)) +\n GL32_W2 * Vector2.magnitude(QuadraticCurve2d.solve(d, shift + scale * -GL32_X2)) +\n GL32_W2 * Vector2.magnitude(QuadraticCurve2d.solve(d, shift + scale * GL32_X2)) +\n GL32_W3 * Vector2.magnitude(QuadraticCurve2d.solve(d, shift + scale * -GL32_X3)) +\n GL32_W3 * Vector2.magnitude(QuadraticCurve2d.solve(d, shift + scale * GL32_X3)) +\n GL32_W4 * Vector2.magnitude(QuadraticCurve2d.solve(d, shift + scale * -GL32_X4)) +\n GL32_W4 * Vector2.magnitude(QuadraticCurve2d.solve(d, shift + scale * GL32_X4)) +\n GL32_W5 * Vector2.magnitude(QuadraticCurve2d.solve(d, shift + scale * -GL32_X5)) +\n GL32_W5 * Vector2.magnitude(QuadraticCurve2d.solve(d, shift + scale * GL32_X5)) +\n GL32_W6 * Vector2.magnitude(QuadraticCurve2d.solve(d, shift + scale * -GL32_X6)) +\n GL32_W6 * Vector2.magnitude(QuadraticCurve2d.solve(d, shift + scale * GL32_X6)) +\n GL32_W7 * Vector2.magnitude(QuadraticCurve2d.solve(d, shift + scale * -GL32_X7)) +\n GL32_W7 * Vector2.magnitude(QuadraticCurve2d.solve(d, shift + scale * GL32_X7)) +\n GL32_W8 * Vector2.magnitude(QuadraticCurve2d.solve(d, shift + scale * -GL32_X8)) +\n GL32_W8 * Vector2.magnitude(QuadraticCurve2d.solve(d, shift + scale * GL32_X8)) +\n GL32_W9 * Vector2.magnitude(QuadraticCurve2d.solve(d, shift + scale * -GL32_X9)) +\n GL32_W9 * Vector2.magnitude(QuadraticCurve2d.solve(d, shift + scale * GL32_X9)) +\n GL32_W10 * Vector2.magnitude(QuadraticCurve2d.solve(d, shift + scale * -GL32_X10)) +\n GL32_W10 * Vector2.magnitude(QuadraticCurve2d.solve(d, shift + scale * GL32_X10)) +\n GL32_W11 * Vector2.magnitude(QuadraticCurve2d.solve(d, shift + scale * -GL32_X11)) +\n GL32_W11 * Vector2.magnitude(QuadraticCurve2d.solve(d, shift + scale * GL32_X11)) +\n GL32_W12 * Vector2.magnitude(QuadraticCurve2d.solve(d, shift + scale * -GL32_X12)) +\n GL32_W12 * Vector2.magnitude(QuadraticCurve2d.solve(d, shift + scale * GL32_X12)) +\n GL32_W13 * Vector2.magnitude(QuadraticCurve2d.solve(d, shift + scale * -GL32_X13)) +\n GL32_W13 * Vector2.magnitude(QuadraticCurve2d.solve(d, shift + scale * GL32_X13)) +\n GL32_W14 * Vector2.magnitude(QuadraticCurve2d.solve(d, shift + scale * -GL32_X14)) +\n GL32_W14 * Vector2.magnitude(QuadraticCurve2d.solve(d, shift + scale * GL32_X14)) +\n GL32_W15 * Vector2.magnitude(QuadraticCurve2d.solve(d, shift + scale * -GL32_X15)) +\n GL32_W15 * Vector2.magnitude(QuadraticCurve2d.solve(d, shift + scale * GL32_X15))) *\n scale\n )\n})\n\n/** @internal */\nexport const curvature = dual(2, (c: CubicCurve2d, t: number) => {\n const d = derivative(c)\n\n const v = QuadraticCurve2d.solve(d, t)\n const a = LinearCurve2d.solve(QuadraticCurve2d.derivative(d), t)\n\n const vMag = Vector2.magnitude(v)\n\n if (vMag === 0) {\n return 0\n }\n\n return Math.abs(Vector2.cross(v, a)) / vMag ** 3\n})\n\n/** @internal */\nexport const boundingBox = (\n c: CubicCurve2d,\n): Interval2d.Interval2d<Interval.Closed, Interval.Closed> =>\n Interval2d.make(CubicPolynomial.unitRange(c.x), CubicPolynomial.unitRange(c.y))\n\n// Combined trait refiners — fan out the polynomial-level check across both\n// axes, over the unit interval. For per-axis checks, users can call\n// `CubicPolynomial.isMonotonic(c.x, Interval.unit)` directly.\n/** @internal */\nexport const isMonotonic = <XT, YT>(\n c: CubicCurve2d<XT, YT>,\n): c is CubicCurve2d<XT & Monotonic, YT & Monotonic> =>\n CubicPolynomial.isMonotonic(c.x, Interval.unit) && CubicPolynomial.isMonotonic(c.y, Interval.unit)\n\n/** @internal */\nexport const isIncreasing = <XT, YT>(\n c: CubicCurve2d<XT, YT>,\n): c is CubicCurve2d<XT & Increasing, YT & Increasing> =>\n CubicPolynomial.isIncreasing(c.x, Interval.unit) &&\n CubicPolynomial.isIncreasing(c.y, Interval.unit)\n\n/** @internal */\nexport const isDecreasing = <XT, YT>(\n c: CubicCurve2d<XT, YT>,\n): c is CubicCurve2d<XT & Decreasing, YT & Decreasing> =>\n CubicPolynomial.isDecreasing(c.x, Interval.unit) &&\n CubicPolynomial.isDecreasing(c.y, Interval.unit)\n\nconst fail = (m: string): never => {\n throw new Error(m)\n}\n\n/** @internal */\nexport const asMonotonic = <XT, YT>(\n c: CubicCurve2d<XT, YT>,\n): CubicCurve2d<XT & Monotonic, YT & Monotonic> =>\n isMonotonic(c) ? c : fail('cubic curve is not monotonic in both axes')\n\n/** @internal */\nexport const asIncreasing = <XT, YT>(\n c: CubicCurve2d<XT, YT>,\n): CubicCurve2d<XT & Increasing, YT & Increasing> =>\n isIncreasing(c) ? c : fail('cubic curve is not increasing in both axes')\n\n/** @internal */\nexport const asDecreasing = <XT, YT>(\n c: CubicCurve2d<XT, YT>,\n): CubicCurve2d<XT & Decreasing, YT & Decreasing> =>\n isDecreasing(c) ? c : fail('cubic curve is not decreasing in both axes')\n","import type { Interval2d } from '../interval/interval2d.ts'\nimport type { TwoDimensional } from '../dimensions.ts'\nimport type { Closed, Interval } from '../interval/interval.ts'\nimport type { Pipeable } from '../utils.ts'\nimport type { CubicPolynomial } from '../polynomial/cubic.ts'\nimport type { Decreasing, Increasing, Monotonic } from '../polynomial/traits.ts'\nimport type * as Solution from '../solution/solution.ts'\nimport type { Vector2 } from '../vector/vector2.ts'\nimport type { CubicCurve2dTypeId } from './cubic2d.internal.ts'\nimport * as internal from './cubic2d.internal.ts'\n\nexport type { Monotonic, Increasing, Decreasing } from '../polynomial/traits.ts'\n\n/**\n * A cubic curve in 2D space.\n *\n * All fields are readonly and immutable, and all operations create new instances.\n *\n * The two type parameters carry the trait sets of the curve's per-axis\n * polynomials. Refiners check monotonicity over the unit interval `[0, 1]` —\n * the curve's natural parameter domain.\n *\n * @since 1.0.0\n */\nexport interface CubicCurve2d<out XTraits = unknown, out YTraits = unknown>\n extends Pipeable, TwoDimensional<CubicPolynomial<XTraits>, CubicPolynomial<YTraits>> {\n readonly [CubicCurve2dTypeId]: CubicCurve2dTypeId\n}\n\n/**\n * Creates a new `CubicCurve2d` instance from polynomial parameters.\n *\n * @param x - The x polynomial.\n * @param y - The y polynomial.\n * @returns A new `CubicCurve2d` instance.\n * @since 1.0.0\n */\nexport const fromPolynomials: (x: CubicPolynomial, y: CubicPolynomial) => CubicCurve2d =\n internal.fromPolynomials\n\n/**\n * Creates a new `CubicCurve2d` instance from monomial coefficient vectors.\n *\n * Each argument bundles the per-axis coefficient at the given power: `c0`\n * holds the x⁰ term, `c1` holds the x¹ term, and so on. The resulting curve\n * evaluates to `c0 + c1·t + c2·t² + c3·t³` per axis.\n *\n * @param c0 - The x⁰ coefficients (x and y).\n * @param c1 - The x¹ coefficients (x and y).\n * @param c2 - The x² coefficients (x and y).\n * @param c3 - The x³ coefficients (x and y).\n * @returns A new `CubicCurve2d` instance.\n * @since 2.0.0\n */\nexport const fromCoefficients: (\n c0: Vector2,\n c1: Vector2,\n c2: Vector2,\n c3: Vector2,\n) => CubicCurve2d = internal.fromCoefficients\n\n/**\n * Creates a new `CubicCurve2d` instance from cubic Bézier control points.\n *\n * The four arguments are the Bernstein-basis control points: `p0` and `p3` are\n * the curve's endpoints and `p1` and `p2` are the off-curve control handles.\n * The implementation converts to the curve's internal monomial form in closed\n * form.\n *\n * @param p0 - The first control point (curve start).\n * @param p1 - The second control point (start handle).\n * @param p2 - The third control point (end handle).\n * @param p3 - The fourth control point (curve end).\n * @returns A new `CubicCurve2d` instance whose curve matches the given Bézier.\n * @since 2.0.0\n */\nexport const fromBezierPoints: (\n p0: Vector2,\n p1: Vector2,\n p2: Vector2,\n p3: Vector2,\n) => CubicCurve2d = internal.fromBezierPoints\n\n/**\n * Checks if a value is a `CubicCurve2d`.\n *\n * @param c - The value to check.\n * @returns `true` if the value is a `CubicCurve2d`, `false` otherwise.\n * @since 1.0.0\n */\nexport const isCubicCurve2d: (c: unknown) => c is CubicCurve2d = internal.isCubicCurve2d\n\nexport const solve: {\n /**\n * Solves the cubic curve for a given parameter t.\n *\n * @param t - The parameter value.\n * @returns A function that takes a cubic curve and returns the point on the curve at parameter t.\n * @since 1.0.0\n */\n (t: number): (c: CubicCurve2d) => Vector2\n /**\n * Solves the cubic curve for a given parameter t.\n *\n * @param c - The cubic curve to solve.\n * @param t - The parameter value.\n * @returns The point on the curve at parameter t.\n * @since 1.0.0\n */\n (c: CubicCurve2d, t: number): Vector2\n} = internal.solve\n\nexport const length: {\n /**\n * Calculates (approximates) the length of a cubic curve.\n *\n * @param c - The cubic curve to calculate the length of.\n * @param i - The interval over which to calculate the length.\n * @returns The length of the cubic curve.\n * @since 1.0.0\n */\n (c: CubicCurve2d, i: Interval): number\n /**\n * Calculates (approximates) the length of a cubic curve.\n *\n * @param i - The interval over which to calculate the length.\n * @returns A function that takes a cubic curve and returns the length of the cubic curve.\n * @since 1.0.0\n */\n (i: Interval): (c: CubicCurve2d) => number\n} = internal.length\n\nexport const solveAtX: {\n /**\n * Evaluates the curve's y values at a given x. Because the x polynomial is\n * `Monotonic`, the inverse has at most one solution — at most one y value.\n *\n * @param c - The cubic curve.\n * @param x - The x coordinate.\n * @returns Zero or one y values, in t-ascending order.\n * @since 2.0.0\n */\n <XT extends Monotonic, YT>(c: CubicCurve2d<XT, YT>, x: number): Solution.AtMostOne<number>\n /**\n * Evaluates the curve's y values at a given x. The result is the y values\n * the curve passes through where x(t) = the given x — up to three solutions\n * for a cubic curve.\n *\n * @param c - The cubic curve.\n * @param x - The x coordinate.\n * @returns The y values at x, in t-ascending order.\n * @since 2.0.0\n */\n <XT, YT>(c: CubicCurve2d<XT, YT>, x: number): Solution.AtMostThree<number>\n /** @since 2.0.0 */\n (x: number): {\n <XT extends Monotonic, YT>(c: CubicCurve2d<XT, YT>): Solution.AtMostOne<number>\n <XT, YT>(c: CubicCurve2d<XT, YT>): Solution.AtMostThree<number>\n }\n} = internal.solveAtX as never\n\nexport const solveAtY: {\n /**\n * Evaluates the curve's x values at a given y. Because the y polynomial is\n * `Monotonic`, the inverse has at most one solution.\n *\n * @param c - The cubic curve.\n * @param y - The y coordinate.\n * @returns Zero or one x values, in t-ascending order.\n * @since 2.0.0\n */\n <XT, YT extends Monotonic>(c: CubicCurve2d<XT, YT>, y: number): Solution.AtMostOne<number>\n /**\n * Evaluates the curve's x values at a given y. The result is the x values\n * the curve passes through where y(t) = the given y — up to three solutions\n * for a cubic curve.\n *\n * @param c - The cubic curve.\n * @param y - The y coordinate.\n * @returns The x values at y, in t-ascending order.\n * @since 2.0.0\n */\n <XT, YT>(c: CubicCurve2d<XT, YT>, y: number): Solution.AtMostThree<number>\n /** @since 2.0.0 */\n (y: number): {\n <XT, YT extends Monotonic>(c: CubicCurve2d<XT, YT>): Solution.AtMostOne<number>\n <XT, YT>(c: CubicCurve2d<XT, YT>): Solution.AtMostThree<number>\n }\n} = internal.solveAtY as never\n\nexport const curvature: {\n /**\n * Calculates the curvature of a cubic curve at a given parameter.\n *\n * @param c - The cubic curve to calculate the curvature for.\n * @param t - The parameter value.\n * @returns The curvature of the cubic curve at parameter t.\n * @since 1.0.0\n */\n (c: CubicCurve2d, t: number): number\n /**\n * Calculates the curvature of a cubic curve at a given parameter.\n *\n * @param t - The parameter value.\n * @returns A function that takes a cubic curve and returns the curvature of the cubic curve at parameter t.\n * @since 1.0.0\n */\n (t: number): (c: CubicCurve2d) => number\n} = internal.curvature\n\n/**\n * Computes the axis-aligned bounding box of the curve over its parameter\n * domain `[0, 1]`. Accounts for up to two interior extrema per axis, so the\n * box is tight against the curve and not just the control polygon.\n *\n * @param c - The cubic curve.\n * @returns A closed `Box2d` enclosing the curve.\n * @since 2.0.0\n */\nexport const boundingBox: (c: CubicCurve2d) => Interval2d<Closed, Closed> = internal.boundingBox\n\n/**\n * Type-narrowing predicate: refines both axes' traits to include `Monotonic`\n * when both x and y polynomials are monotonic over the unit interval `[0, 1]`.\n *\n * For checking only one axis, call the polynomial-level refiner directly:\n * `CubicPolynomial.isMonotonic(curve.x, Interval.unit)`.\n *\n * @since 2.0.0\n */\nexport const isMonotonic: <XT, YT>(\n c: CubicCurve2d<XT, YT>,\n) => c is CubicCurve2d<XT & Monotonic, YT & Monotonic> = internal.isMonotonic\n\n/** @since 2.0.0 */\nexport const isIncreasing: <XT, YT>(\n c: CubicCurve2d<XT, YT>,\n) => c is CubicCurve2d<XT & Increasing, YT & Increasing> = internal.isIncreasing\n\n/** @since 2.0.0 */\nexport const isDecreasing: <XT, YT>(\n c: CubicCurve2d<XT, YT>,\n) => c is CubicCurve2d<XT & Decreasing, YT & Decreasing> = internal.isDecreasing\n\n/** @since 2.0.0 */\nexport const asMonotonic: <XT, YT>(\n c: CubicCurve2d<XT, YT>,\n) => CubicCurve2d<XT & Monotonic, YT & Monotonic> = internal.asMonotonic\n\n/** @since 2.0.0 */\nexport const asIncreasing: <XT, YT>(\n c: CubicCurve2d<XT, YT>,\n) => CubicCurve2d<XT & Increasing, YT & Increasing> = internal.asIncreasing\n\n/** @since 2.0.0 */\nexport const asDecreasing: <XT, YT>(\n c: CubicCurve2d<XT, YT>,\n) => CubicCurve2d<XT & Decreasing, YT & Decreasing> = internal.asDecreasing\n","import * as Characteristic from '../characteristic/characteristic.ts'\nimport * as Interval from '../interval/interval.ts'\nimport * as Interval2d from '../interval/interval2d.ts'\nimport { dual, Pipeable } from '../utils.ts'\nimport * as CubicPolynomial from '../polynomial/cubic.ts'\nimport * as Solution from '../solution/solution.ts'\nimport { invariant } from '../utils.ts'\nimport * as Vector2 from '../vector/vector2.ts'\nimport * as Vector4 from '../vector/vector4.ts'\nimport * as CubicCurve2d from './cubic2d.ts'\nimport type { RationalCubicCurve2d } from './rationalCubic2d.ts'\n\nexport const RationalCubicCurve2dTypeId: unique symbol = Symbol('curvy/curve/rationalCubic2d')\nexport type RationalCubicCurve2dTypeId = typeof RationalCubicCurve2dTypeId\n\n// Phantom property key carrying the per-axis trait tuple. Unlike `CubicCurve2d`\n// where traits flow through to the underlying polynomials, rational curve\n// traits are properties of the projected rational functions x(t)/w(t) and\n// y(t)/w(t) — not of any individual polynomial — so the brand lives on the\n// curve itself.\n/** @internal */\nexport const RationalCurveTraits: unique symbol = Symbol.for('curvy/curve/rationalCubic2d/traits')\n/** @internal */\nexport type RationalCurveTraits = typeof RationalCurveTraits\n\n/** @internal */\nexport class RationalCubicCurve2dImpl\n extends Pipeable\n implements RationalCubicCurve2d<unknown, unknown>\n{\n readonly [RationalCubicCurve2dTypeId]: RationalCubicCurve2dTypeId = RationalCubicCurve2dTypeId\n declare readonly [RationalCurveTraits]: [unknown, unknown]\n\n readonly x: CubicPolynomial.CubicPolynomial\n readonly y: CubicPolynomial.CubicPolynomial\n readonly w: CubicPolynomial.CubicPolynomial\n\n constructor(\n x: CubicPolynomial.CubicPolynomial,\n y: CubicPolynomial.CubicPolynomial,\n w: CubicPolynomial.CubicPolynomial,\n ) {\n super()\n this.x = x\n this.y = y\n this.w = w\n }\n}\n\n/** @internal */\nexport const isRationalCubicCurve2d = (c: unknown): c is RationalCubicCurve2d =>\n typeof c === 'object' && c !== null && RationalCubicCurve2dTypeId in c\n\n/** @internal */\nexport const fromPolynomials = (\n x: CubicPolynomial.CubicPolynomial,\n y: CubicPolynomial.CubicPolynomial,\n w: CubicPolynomial.CubicPolynomial,\n): RationalCubicCurve2d => new RationalCubicCurve2dImpl(x, y, w)\n\n// Applies the cubic Bézier characteristic matrix in homogeneous space —\n// each control point is lifted to `(w·x, w·y, w)` and the same matrix that\n// drives `CubicCurve2d.fromBezierPoints` runs on each of the three channels\n// independently. The shared `w` polynomial is the projective denominator;\n// at solve time, x(t)/w(t) and y(t)/w(t) project the curve back to the plane.\n//\n// This is Freya Holmér's \"matrix IS the spline\" framing extended to rational:\n// same matrix, three channels instead of two, one projection at the end.\n/** @internal */\nexport const fromBezierPoints = (\n p0: Vector2.Weighted,\n p1: Vector2.Weighted,\n p2: Vector2.Weighted,\n p3: Vector2.Weighted,\n): RationalCubicCurve2d =>\n new RationalCubicCurve2dImpl(\n ...Characteristic.apply(\n Characteristic.cubicBezier,\n // Lift each control point to homogeneous (w·x, w·y, w), then transpose\n // the four lifted CPs into three per-channel Vector4s for the matrix.\n ...Vector4.transpose([p0, p1, p2, p3], (p) => [p.x * p.weight, p.y * p.weight, p.weight]),\n ),\n )\n\n// Gregory-Delbourgo style monotone rational cubic Hermite easing.\n//\n// Construction: rational cubic with *linear* denominator embedded in the 2D\n// pipeline by pinning x(t) = t exactly. With endpoint weights α at t=0 and\n// β at t=1, the Hermite conditions y(0)=0, y(1)=1, y'(0)=m₀, y'(1)=m₁\n// produce a closed-form cubic numerator. Monotonicity of y(t) is then a\n// degree-3 polynomial sign question — verified rigorously with the existing\n// cubic root-finder.\n//\n// The 2D embedding stores three polynomials in cubic form:\n// X(t) = t · Q(t) (quadratic, c3 = 0) so x(t)/w(t) = t\n// Y(t) = cubic numerator\n// W(t) = Q(t) = α + (β-α)·t (linear, c2 = c3 = 0)\n//\n// The α = m₀+1, β = m₁+1 choice is a serviceable heuristic — it makes\n// smoothstep (m₀=m₁=0) and linear (m₀=m₁=1) fall out for free, gives a\n// useful operating range for moderate slopes, and throws cleanly on inputs\n// it can't handle. Finding the optimal α, β formula for a wider input range\n// is a v2 problem.\n/** @internal */\nexport const makeMonotonicEasing = (startSlope: number, endSlope: number): RationalCubicCurve2d => {\n invariant(\n Number.isFinite(startSlope) && startSlope >= 0,\n 'makeMonotonicEasing: startSlope must be finite and ≥ 0',\n )\n invariant(\n Number.isFinite(endSlope) && endSlope >= 0,\n 'makeMonotonicEasing: endSlope must be finite and ≥ 0',\n )\n\n const m0 = startSlope\n const m1 = endSlope\n const alpha = m0 + 1\n const beta = m1 + 1\n\n // Numerator P(t) cubic coefficients, derived from Hermite conditions\n // y(0)=0, y(1)=1, y'(0)=m₀·α/α = m₀, y'(1)=(m₁·β + (β-α))/β = m₁:\n // c0 = 0\n // c1 = m₀·α\n // c2 = β·(2 - m₁) + α·(1 - 2m₀)\n // c3 = β·(m₁ - 1) + α·(m₀ - 1)\n const pC0 = 0\n const pC1 = m0 * alpha\n const pC2 = beta * (2 - m1) + alpha * (1 - 2 * m0)\n const pC3 = beta * (m1 - 1) + alpha * (m0 - 1)\n\n // Denominator Q(t) = α + (β-α)·t — linear, stored as cubic with c2=c3=0.\n const qC0 = alpha\n const qC1 = beta - alpha\n\n // X(t) = t · Q(t) = α·t + (β-α)·t² — quadratic, stored as cubic with c3=0.\n const xC1 = alpha\n const xC2 = beta - alpha\n\n const xPoly = CubicPolynomial.make(0, xC1, xC2, 0)\n const yPoly = CubicPolynomial.make(pC0, pC1, pC2, pC3)\n const wPoly = CubicPolynomial.make(qC0, qC1, 0, 0)\n\n // Verify monotonicity of y(t) = P(t)/Q(t) on (0, 1).\n //\n // sign(y'(t)) = sign(P'·Q - P·Q') (since Q > 0 on [0,1])\n //\n // P' is degree 2, Q is degree 1, Q' is constant — so P'·Q - P·Q' is a\n // degree-3 polynomial. We compute its coefficients and clip the roots to\n // the strict interior (0, 1); any surviving root where the polynomial\n // changes sign means y'(t) crosses zero inside the interval and the curve\n // is not monotonic.\n //\n // q(t) = m₀·α² + 2·α·a·t + (3·α·b + a·(β-α))·t² + 2·b·(β-α)·t³\n // where a = β(2-m₁) + α(1-2m₀), b = β(m₁-1) + α(m₀-1) — i.e. c2 and c3.\n const monoQ = CubicPolynomial.make(\n m0 * alpha * alpha,\n 2 * alpha * pC2,\n 3 * alpha * pC3 + pC2 * (beta - alpha),\n 2 * pC3 * (beta - alpha),\n )\n\n const interiorRoots = monoQ.pipe(CubicPolynomial.roots, Solution.clip(Interval.unitOpen))\n for (const t of interiorRoots) {\n // Check sign on both sides of the root. If the polynomial changes sign\n // across this point, monotonicity is violated.\n const epsilon = 1e-6\n const lo = Math.max(0, t - epsilon)\n const hi = Math.min(1, t + epsilon)\n const signLo = Math.sign(CubicPolynomial.solve(monoQ, lo))\n const signHi = Math.sign(CubicPolynomial.solve(monoQ, hi))\n invariant(\n signLo * signHi >= 0,\n `makeMonotonicEasing: slopes (${m0}, ${m1}) produce a non-monotonic curve with the default Gregory-Delbourgo construction. Try smaller slopes or use a different easing form.`,\n )\n }\n\n return new RationalCubicCurve2dImpl(xPoly, yPoly, wPoly)\n}\n\n/** @internal */\nexport const solve = dual<\n (t: number) => (c: RationalCubicCurve2d) => Vector2.Vector2,\n (c: RationalCubicCurve2d, t: number) => Vector2.Vector2\n>(2, (c: RationalCubicCurve2d, t: number) => {\n const w = CubicPolynomial.solve(c.w, t)\n return Vector2.make(CubicPolynomial.solve(c.x, t) / w, CubicPolynomial.solve(c.y, t) / w)\n})\n\n// Inverse-solve x(t)/w(t) = X by finding roots of X(t) - X·w(t) = 0.\n// Both X(t) and w(t) are cubic in t, so their linear combination is also\n// cubic — solvable with the existing cubic root-finder. Solutions outside\n// the [0, 1] unit interval are discarded; for each surviving t, y(t)/w(t)\n// is evaluated. The brand-aware overload narrows to `AtMostOne` for curves\n// known to be x-monotonic.\n/** @internal */\nexport const solveAtX = dual(\n 2,\n (c: RationalCubicCurve2d, x: number): Solution.Solution<number> =>\n CubicPolynomial.make(\n c.x.c0 - x * c.w.c0,\n c.x.c1 - x * c.w.c1,\n c.x.c2 - x * c.w.c2,\n c.x.c3 - x * c.w.c3,\n ).pipe(\n CubicPolynomial.roots,\n Solution.clip(Interval.unit),\n Solution.map((t) => CubicPolynomial.solve(c.y, t) / CubicPolynomial.solve(c.w, t)),\n ),\n)\n\n/** @internal */\nexport const solveAtY = dual(\n 2,\n (c: RationalCubicCurve2d, y: number): Solution.Solution<number> =>\n CubicPolynomial.make(\n c.y.c0 - y * c.w.c0,\n c.y.c1 - y * c.w.c1,\n c.y.c2 - y * c.w.c2,\n c.y.c3 - y * c.w.c3,\n ).pipe(\n CubicPolynomial.roots,\n Solution.clip(Interval.unit),\n Solution.map((t) => CubicPolynomial.solve(c.x, t) / CubicPolynomial.solve(c.w, t)),\n ),\n)\n\n// Approximation cap. At depth 20 we'd emit up to 2²⁰ ≈ 1M segments for one\n// input curve — well past any sane target — so the cap is really just a guard\n// against pathological tolerances (e.g. tolerance approaching 0).\nconst MAX_APPROX_DEPTH = 20\n\n// Builds the polynomial-cubic candidate for one rational segment by:\n// 1. Inverting Bernstein → monomial on each of x, y, w to recover the four\n// homogeneous Bézier control points (Xᵢ, Yᵢ, Wᵢ).\n// 2. Projecting each CP back to 2D as (Xᵢ/Wᵢ, Yᵢ/Wᵢ).\n// 3. Lifting those 2D CPs back to a polynomial cubic via fromBezierPoints.\n// The result matches the rational at t=0 and t=1 exactly and matches endpoint\n// tangent directions, but interior shape diverges whenever the weights are\n// not all equal.\nconst buildCubicCandidate = (c: RationalCubicCurve2d): CubicCurve2d.CubicCurve2d => {\n const x0 = c.x.c0\n const x1 = c.x.c0 + c.x.c1 / 3\n const x2 = c.x.c0 + (2 * c.x.c1) / 3 + c.x.c2 / 3\n const x3 = c.x.c0 + c.x.c1 + c.x.c2 + c.x.c3\n\n const y0 = c.y.c0\n const y1 = c.y.c0 + c.y.c1 / 3\n const y2 = c.y.c0 + (2 * c.y.c1) / 3 + c.y.c2 / 3\n const y3 = c.y.c0 + c.y.c1 + c.y.c2 + c.y.c3\n\n const w0 = c.w.c0\n const w1 = c.w.c0 + c.w.c1 / 3\n const w2 = c.w.c0 + (2 * c.w.c1) / 3 + c.w.c2 / 3\n const w3 = c.w.c0 + c.w.c1 + c.w.c2 + c.w.c3\n\n return CubicCurve2d.fromBezierPoints(\n Vector2.make(x0 / w0, y0 / w0),\n Vector2.make(x1 / w1, y1 / w1),\n Vector2.make(x2 / w2, y2 / w2),\n Vector2.make(x3 / w3, y3 / w3),\n )\n}\n\n// Splits a rational cubic at parameter `t ∈ (0, 1)` by applying\n// `CubicPolynomial.subdivide` independently to each of x, y, w. Equivalent to\n// de Casteljau on the homogeneous control polygon but stays in monomial form\n// throughout, so no Bernstein round-trip is required.\n/** @internal */\nexport const subdivide = dual<\n (t: number) => (c: RationalCubicCurve2d) => [RationalCubicCurve2d, RationalCubicCurve2d],\n (c: RationalCubicCurve2d, t: number) => [RationalCubicCurve2d, RationalCubicCurve2d]\n>(2, (c: RationalCubicCurve2d, t: number) => {\n const [leftX, rightX] = CubicPolynomial.subdivide(c.x, t)\n const [leftY, rightY] = CubicPolynomial.subdivide(c.y, t)\n const [leftW, rightW] = CubicPolynomial.subdivide(c.w, t)\n\n return [\n new RationalCubicCurve2dImpl(leftX, leftY, leftW),\n new RationalCubicCurve2dImpl(rightX, rightY, rightW),\n ]\n})\n\n// Loose bounding box from the rational's projected Bézier control polygon.\n//\n// Rational Bézier curves with positive weights satisfy the projected\n// convex-hull property: the curve lies inside the convex hull of the four\n// projected 2D control points (Wᵢ⁻¹·Xᵢ, Wᵢ⁻¹·Yᵢ). Their AABB is a strict\n// superset of the hull, so it is a valid (and cheap) bound on the curve.\n//\n// Looser than a true tight box — for that we'd need the extrema of x(t)/w(t)\n// and y(t)/w(t), each a degree-5 root problem — but tight enough for\n// subdivision-based geometric queries, which compensate via depth.\n/** @internal */\nexport const boundingBox = (\n c: RationalCubicCurve2d,\n): Interval2d.Interval2d<Interval.Closed, Interval.Closed> => {\n // Bernstein control points recovered from monomial coefficients — same\n // inversion as `buildCubicCandidate`.\n const x0 = c.x.c0\n const x1 = c.x.c0 + c.x.c1 / 3\n const x2 = c.x.c0 + (2 * c.x.c1) / 3 + c.x.c2 / 3\n const x3 = c.x.c0 + c.x.c1 + c.x.c2 + c.x.c3\n\n const y0 = c.y.c0\n const y1 = c.y.c0 + c.y.c1 / 3\n const y2 = c.y.c0 + (2 * c.y.c1) / 3 + c.y.c2 / 3\n const y3 = c.y.c0 + c.y.c1 + c.y.c2 + c.y.c3\n\n const w0 = c.w.c0\n const w1 = c.w.c0 + c.w.c1 / 3\n const w2 = c.w.c0 + (2 * c.w.c1) / 3 + c.w.c2 / 3\n const w3 = c.w.c0 + c.w.c1 + c.w.c2 + c.w.c3\n\n return Interval2d.fromVectors(\n Vector2.make(x0 / w0, y0 / w0),\n Vector2.make(x1 / w1, y1 / w1),\n Vector2.make(x2 / w2, y2 / w2),\n Vector2.make(x3 / w3, y3 / w3),\n )\n}\n\n// Certified Hausdorff-within-tolerance check between a rational and a\n// candidate polynomial cubic.\n//\n// `approximateAsCubicCurves` uses this as the stopping criterion: when it\n// returns `true`, every point on the rational is provably within `tolerance`\n// of the candidate, and every point on the candidate is within `tolerance` of\n// the rational. When `false`, the rational is subdivided and the procedure\n// recurses.\n//\n// Implementation: for each direction (rational → candidate, candidate →\n// rational), run a depth-first subdivision on the source side. At each\n// piece, compute\n//\n// lower = dist(witness-on-piece, target)\n// upper = min(\n// lower + maxDist(witness, piece.box), // triangle inequality bound\n// maxDist(piece.box, target.box), // box-pair bound\n// )\n//\n// Both upper bounds are provable; their min is too. The triangle bound\n// shrinks proportionally to source box diameter, so it dominates when source\n// and target overlap (which they usually do here — the candidate matches the\n// rational at endpoints and tangents). Early-terminate on the first piece\n// whose `lower` exceeds `tolerance` (definitive miss) or accept whenever\n// every piece's `upper` ≤ tolerance.\n\nconst MAX_HAUSDORFF_DEPTH = 30\n\n// Coarse sample + bisection on the squared-distance derivative. Returns the\n// minimum squared distance from (qx, qy) to a parametric curve described by\n// `eval_`. Stationary points of (P(s) - q) · P'(s) are local extrema of\n// D²(s); 32 coarse samples reliably bracket the global min for cubic-degree\n// curves (which have at most ~5 critical points of squared distance).\nconst closestSquaredDistance = (\n eval_: (s: number) => { px: number; py: number; tx: number; ty: number },\n qx: number,\n qy: number,\n): number => {\n const coarseSamples = 32\n let sBest = 0\n let d2Best = Number.POSITIVE_INFINITY\n for (let i = 0; i <= coarseSamples; i++) {\n const s = i / coarseSamples\n const { px, py } = eval_(s)\n const dx = px - qx\n const dy = py - qy\n const d2 = dx * dx + dy * dy\n if (d2 < d2Best) {\n d2Best = d2\n sBest = s\n }\n }\n const step = 1 / coarseSamples\n let lo = Math.max(0, sBest - step)\n let hi = Math.min(1, sBest + step)\n const gradient = (s: number): number => {\n const { px, py, tx, ty } = eval_(s)\n return (px - qx) * tx + (py - qy) * ty\n }\n if (gradient(lo) > 0 || gradient(hi) < 0) {\n return d2Best\n }\n for (let i = 0; i < 40; i++) {\n const m = 0.5 * (lo + hi)\n if (gradient(m) > 0) {\n hi = m\n } else {\n lo = m\n }\n if (hi - lo < 1e-12) {\n break\n }\n }\n const s = 0.5 * (lo + hi)\n const { px, py } = eval_(s)\n const dx = px - qx\n const dy = py - qy\n const d2 = dx * dx + dy * dy\n return d2 < d2Best ? d2 : d2Best\n}\n\nconst polynomialEval = (c: CubicCurve2d.CubicCurve2d, s: number) => ({\n px: c.x.c0 + s * (c.x.c1 + s * (c.x.c2 + s * c.x.c3)),\n py: c.y.c0 + s * (c.y.c1 + s * (c.y.c2 + s * c.y.c3)),\n tx: c.x.c1 + s * (2 * c.x.c2 + s * 3 * c.x.c3),\n ty: c.y.c1 + s * (2 * c.y.c2 + s * 3 * c.y.c3),\n})\n\n// R(s) = (X(s)/W(s), Y(s)/W(s)) → R'(s) = ((X'W - XW')/W², (Y'W - YW')/W²)\nconst rationalEval = (c: RationalCubicCurve2d, s: number) => {\n const X = c.x.c0 + s * (c.x.c1 + s * (c.x.c2 + s * c.x.c3))\n const Y = c.y.c0 + s * (c.y.c1 + s * (c.y.c2 + s * c.y.c3))\n const W = c.w.c0 + s * (c.w.c1 + s * (c.w.c2 + s * c.w.c3))\n const Xp = c.x.c1 + s * (2 * c.x.c2 + s * 3 * c.x.c3)\n const Yp = c.y.c1 + s * (2 * c.y.c2 + s * 3 * c.y.c3)\n const Wp = c.w.c1 + s * (2 * c.w.c2 + s * 3 * c.w.c3)\n const w2 = W * W\n return {\n px: X / W,\n py: Y / W,\n tx: (Xp * W - X * Wp) / w2,\n ty: (Yp * W - Y * Wp) / w2,\n }\n}\n\nconst maxDistFromPointToBox = (px: number, py: number, box: Interval2d.Interval2d): number => {\n const xLo = Math.min(box.x.start, box.x.end)\n const xHi = Math.max(box.x.start, box.x.end)\n const yLo = Math.min(box.y.start, box.y.end)\n const yHi = Math.max(box.y.start, box.y.end)\n const dx = Math.max(px - xLo, xHi - px)\n const dy = Math.max(py - yLo, yHi - py)\n return Math.hypot(dx, dy)\n}\n\n// Subdivide a polynomial cubic curve at parameter t by subdividing each\n// per-axis polynomial independently — the polynomial split is exact and in\n// monomial form.\nconst subdividePolynomial = (\n c: CubicCurve2d.CubicCurve2d,\n t: number,\n): [CubicCurve2d.CubicCurve2d, CubicCurve2d.CubicCurve2d] => {\n const [leftX, rightX] = CubicPolynomial.subdivide(c.x, t)\n const [leftY, rightY] = CubicPolynomial.subdivide(c.y, t)\n return [CubicCurve2d.fromPolynomials(leftX, leftY), CubicCurve2d.fromPolynomials(rightX, rightY)]\n}\n\ninterface CertifiedPiece {\n box: Interval2d.Interval2d\n witnessX: number\n witnessY: number\n depth: number\n subdivide(): [CertifiedPiece, CertifiedPiece]\n}\n\nconst rationalPiece = (c: RationalCubicCurve2d, depth = 0): CertifiedPiece => {\n const wMid = CubicPolynomial.solve(c.w, 0.5)\n const witnessX = CubicPolynomial.solve(c.x, 0.5) / wMid\n const witnessY = CubicPolynomial.solve(c.y, 0.5) / wMid\n return {\n box: boundingBox(c),\n witnessX,\n witnessY,\n depth,\n subdivide: () => {\n const [left, right] = subdivide(c, 0.5)\n return [rationalPiece(left, depth + 1), rationalPiece(right, depth + 1)]\n },\n }\n}\n\nconst polynomialPiece = (c: CubicCurve2d.CubicCurve2d, depth = 0): CertifiedPiece => {\n const witnessX = CubicPolynomial.solve(c.x, 0.5)\n const witnessY = CubicPolynomial.solve(c.y, 0.5)\n return {\n box: CubicCurve2d.boundingBox(c),\n witnessX,\n witnessY,\n depth,\n subdivide: () => {\n const [left, right] = subdividePolynomial(c, 0.5)\n return [polynomialPiece(left, depth + 1), polynomialPiece(right, depth + 1)]\n },\n }\n}\n\nconst oneSidedWithinTolerance = (\n initialPiece: CertifiedPiece,\n targetBox: Interval2d.Interval2d,\n targetClosestSquared: (qx: number, qy: number) => number,\n tolerance: number,\n): boolean => {\n const tol2 = tolerance * tolerance\n const stack: Array<CertifiedPiece> = [initialPiece]\n while (stack.length > 0) {\n const piece = stack.pop() as CertifiedPiece\n const lower2 = targetClosestSquared(piece.witnessX, piece.witnessY)\n if (lower2 > tol2) {\n return false\n }\n const lower = Math.sqrt(lower2)\n const triangleUpper = lower + maxDistFromPointToBox(piece.witnessX, piece.witnessY, piece.box)\n const boxPairUpper = Interval2d.maxDistance(piece.box, targetBox)\n const upper = triangleUpper < boxPairUpper ? triangleUpper : boxPairUpper\n if (upper <= tolerance) {\n continue\n }\n if (piece.depth >= MAX_HAUSDORFF_DEPTH) {\n return false\n }\n const [left, right] = piece.subdivide()\n stack.push(left, right)\n }\n return true\n}\n\nconst hausdorffWithinTolerance = (\n rational: RationalCubicCurve2d,\n candidate: CubicCurve2d.CubicCurve2d,\n tolerance: number,\n): boolean => {\n // Algebraic fast path: when the denominator polynomial is constant — every\n // weighted Bézier control point shares the same weight, so the rational\n // reduces to a polynomial cubic — `buildCubicCandidate` is exact. The\n // Bernstein → monomial transform produces exact zero higher coefficients\n // for a uniform input (integer cancellation), and `CubicPolynomial.subdivide`\n // preserves constants, so this check holds at every recursion depth.\n //\n // Without this fast path the subdivision Hausdorff would take ~30 levels\n // to certify the coincident-curve case at sub-pixel tolerances, even\n // though the answer is exactly zero.\n if (rational.w.c1 === 0 && rational.w.c2 === 0 && rational.w.c3 === 0) {\n return true\n }\n\n const candidateBox = CubicCurve2d.boundingBox(candidate)\n if (\n !oneSidedWithinTolerance(\n rationalPiece(rational),\n candidateBox,\n (qx, qy) => closestSquaredDistance((s) => polynomialEval(candidate, s), qx, qy),\n tolerance,\n )\n ) {\n return false\n }\n const rationalBox = boundingBox(rational)\n return oneSidedWithinTolerance(\n polynomialPiece(candidate),\n rationalBox,\n (qx, qy) => closestSquaredDistance((s) => rationalEval(rational, s), qx, qy),\n tolerance,\n )\n}\n\n/** @internal */\nexport const approximateAsCubicCurves = dual<\n (tolerance: number) => (c: RationalCubicCurve2d) => ReadonlyArray<CubicCurve2d.CubicCurve2d>,\n (c: RationalCubicCurve2d, tolerance: number) => ReadonlyArray<CubicCurve2d.CubicCurve2d>\n>(2, (c: RationalCubicCurve2d, tolerance: number) => {\n invariant(\n Number.isFinite(tolerance) && tolerance > 0,\n 'approximateAsCubicCurves: tolerance must be finite and > 0',\n )\n\n const out: Array<CubicCurve2d.CubicCurve2d> = []\n const recurse = (curr: RationalCubicCurve2d, depth: number): void => {\n const candidate = buildCubicCandidate(curr)\n if (depth >= MAX_APPROX_DEPTH || hausdorffWithinTolerance(curr, candidate, tolerance)) {\n out.push(candidate)\n return\n }\n const [left, right] = subdivide(curr, 0.5)\n recurse(left, depth + 1)\n recurse(right, depth + 1)\n }\n recurse(c, 0)\n return out\n})\n","import type { Closed } from '../interval/interval.ts'\nimport type { Interval2d } from '../interval/interval2d.ts'\nimport type { Pipeable } from '../utils.ts'\nimport type { CubicPolynomial } from '../polynomial/cubic.ts'\nimport type { Increasing, Monotonic } from '../polynomial/traits.ts'\nimport type * as Solution from '../solution/solution.ts'\nimport type { Vector2, Weighted } from '../vector/vector2.ts'\nimport type { CubicCurve2d } from './cubic2d.ts'\nimport type { RationalCubicCurve2dTypeId, RationalCurveTraits } from './rationalCubic2d.internal.ts'\nimport * as internal from './rationalCubic2d.internal.ts'\n\nexport type { Decreasing, Increasing, Monotonic } from '../polynomial/traits.ts'\nexport { RationalCurveTraits } from './rationalCubic2d.internal.ts'\n\n/**\n * A rational cubic curve in 2D space.\n *\n * Represented as three cubic polynomials in the parameter `t`: per-axis\n * numerators `x`, `y`, and a shared denominator `w`. Evaluation is\n * `(x(t)/w(t), y(t)/w(t))` — the projection from homogeneous coordinates\n * back to the plane. With all weights equal at the source (e.g. produced\n * from a non-rational Bézier with unit weights), `w` is constant and the\n * curve coincides with a polynomial cubic.\n *\n * The two type parameters carry per-axis monotonicity trait brands attached\n * to the rational functions `x(t)/w(t)` and `y(t)/w(t)`. Unlike\n * `CubicCurve2d`, traits do not flow through to the underlying polynomials —\n * monotonicity of a ratio of cubics is not the same property as monotonicity\n * of either cubic alone, so the brand lives on the curve itself. Constructors\n * with construction-time monotonicity guarantees (e.g. {@link makeMonotonicEasing})\n * return curves with `Increasing` brands attached, narrowing downstream\n * operations like {@link solveAtX} to single-solution returns.\n *\n * All fields are readonly and immutable, and all operations create new instances.\n *\n * @since 2.0.0\n */\nexport interface RationalCubicCurve2d<\n out XTraits = unknown,\n out YTraits = unknown,\n> extends Pipeable {\n readonly [RationalCubicCurve2dTypeId]: RationalCubicCurve2dTypeId\n readonly [RationalCurveTraits]: [XTraits, YTraits]\n readonly x: CubicPolynomial\n readonly y: CubicPolynomial\n readonly w: CubicPolynomial\n}\n\n/**\n * Checks if a value is a `RationalCubicCurve2d`.\n *\n * @param c - The value to check.\n * @returns `true` if the value is a `RationalCubicCurve2d`, `false` otherwise.\n * @since 2.0.0\n */\nexport const isRationalCubicCurve2d: (c: unknown) => c is RationalCubicCurve2d =\n internal.isRationalCubicCurve2d\n\n/**\n * Creates a new `RationalCubicCurve2d` from per-axis numerator polynomials\n * and a shared denominator polynomial.\n *\n * @param x - The x numerator polynomial.\n * @param y - The y numerator polynomial.\n * @param w - The shared denominator polynomial (must be non-zero on `[0, 1]`).\n * @returns A new `RationalCubicCurve2d` instance.\n * @since 2.0.0\n */\nexport const fromPolynomials: (\n x: CubicPolynomial,\n y: CubicPolynomial,\n w: CubicPolynomial,\n) => RationalCubicCurve2d = internal.fromPolynomials\n\n/**\n * Creates a new `RationalCubicCurve2d` from four weighted cubic Bézier\n * control points. The four control points are lifted to homogeneous form\n * `(w·x, w·y, w)` and the cubic Bernstein basis is expanded into per-channel\n * monomial coefficients, yielding the curve's `x`, `y`, and `w` polynomials.\n *\n * @param p0 - The first weighted control point (curve start).\n * @param p1 - The second weighted control point (start handle).\n * @param p2 - The third weighted control point (end handle).\n * @param p3 - The fourth weighted control point (curve end).\n * @returns A new `RationalCubicCurve2d` instance.\n * @since 2.0.0\n */\nexport const fromBezierPoints: (\n p0: Weighted,\n p1: Weighted,\n p2: Weighted,\n p3: Weighted,\n) => RationalCubicCurve2d = internal.fromBezierPoints\n\n/**\n * Creates a guaranteed-monotonic rational cubic easing curve via Gregory-\n * Delbourgo style construction. The result interpolates `(0, 0)` and\n * `(1, 1)` with the given endpoint slopes, with `x(t) = t` pinned linearly\n * and a rational cubic numerator for `y(t)`. Monotonicity of `y(t)` is\n * verified rigorously at construction (degree-3 polynomial sign analysis);\n * the returned curve is branded `<Increasing, Increasing>` so that\n * {@link solveAtX} returns `Solution.AtMostOne<number>` without further\n * trait refinement.\n *\n * For input slope combinations that the default Gregory-Delbourgo\n * construction cannot accommodate (typically when one slope is large while\n * the other is small), construction throws. Useful operating range is\n * roughly `m₀, m₁ ∈ [0, 2]` with `m₀ + m₁ ≲ 3`; smoothstep (`0, 0`) and\n * linear (`1, 1`) fall out as special cases.\n *\n * @param startSlope - The easing function's slope at the start (`dy/dx` at `x = 0`); must be finite and non-negative.\n * @param endSlope - The easing function's slope at the end (`dy/dx` at `x = 1`); must be finite and non-negative.\n * @returns A monotone-by-construction rational cubic easing curve.\n * @throws When slopes are negative, non-finite, or produce a non-monotonic curve under the default construction.\n * @since 2.0.0\n */\nexport const makeMonotonicEasing: (\n startSlope: number,\n endSlope: number,\n) => RationalCubicCurve2d<Increasing, Increasing> = internal.makeMonotonicEasing as never\n\nexport const solve: {\n /**\n * Evaluates the rational cubic curve at parameter `t`. Returns\n * `(x(t)/w(t), y(t)/w(t))` — three Horner evaluations and two divisions.\n *\n * @param c - The curve to evaluate.\n * @param t - The parameter value.\n * @returns The point on the curve at parameter `t`.\n * @since 2.0.0\n */\n (c: RationalCubicCurve2d, t: number): Vector2\n /**\n * Evaluates the rational cubic curve at parameter `t`.\n *\n * @param t - The parameter value.\n * @returns A function that takes a curve and returns the point at `t`.\n * @since 2.0.0\n */\n (t: number): (c: RationalCubicCurve2d) => Vector2\n} = internal.solve\n\nexport const solveAtX: {\n /**\n * Evaluates the curve's y values at a given x. Because the curve's x axis\n * carries the `Monotonic` brand, the inverse has at most one solution.\n *\n * @param c - The rational cubic curve with monotonic x.\n * @param x - The x coordinate.\n * @returns Zero or one y values.\n * @since 2.0.0\n */\n <XT extends Monotonic, YT>(c: RationalCubicCurve2d<XT, YT>, x: number): Solution.AtMostOne<number>\n /**\n * Evaluates the curve's y values at a given x. Up to three solutions —\n * `(X(t) - x·W(t))` is a cubic polynomial in `t`.\n *\n * @param c - The rational cubic curve.\n * @param x - The x coordinate.\n * @returns The y values at x, in t-ascending order.\n * @since 2.0.0\n */\n <XT, YT>(c: RationalCubicCurve2d<XT, YT>, x: number): Solution.AtMostThree<number>\n /** @since 2.0.0 */\n (x: number): {\n <XT extends Monotonic, YT>(c: RationalCubicCurve2d<XT, YT>): Solution.AtMostOne<number>\n <XT, YT>(c: RationalCubicCurve2d<XT, YT>): Solution.AtMostThree<number>\n }\n} = internal.solveAtX as never\n\nexport const solveAtY: {\n /**\n * Evaluates the curve's x values at a given y. Because the curve's y axis\n * carries the `Monotonic` brand, the inverse has at most one solution.\n *\n * @param c - The rational cubic curve with monotonic y.\n * @param y - The y coordinate.\n * @returns Zero or one x values.\n * @since 2.0.0\n */\n <XT, YT extends Monotonic>(c: RationalCubicCurve2d<XT, YT>, y: number): Solution.AtMostOne<number>\n /**\n * Evaluates the curve's x values at a given y. Up to three solutions.\n *\n * @param c - The rational cubic curve.\n * @param y - The y coordinate.\n * @returns The x values at y, in t-ascending order.\n * @since 2.0.0\n */\n <XT, YT>(c: RationalCubicCurve2d<XT, YT>, y: number): Solution.AtMostThree<number>\n /** @since 2.0.0 */\n (y: number): {\n <XT, YT extends Monotonic>(c: RationalCubicCurve2d<XT, YT>): Solution.AtMostOne<number>\n <XT, YT>(c: RationalCubicCurve2d<XT, YT>): Solution.AtMostThree<number>\n }\n} = internal.solveAtY as never\n\nexport const subdivide: {\n /**\n * Subdivides a rational cubic curve at parameter `t ∈ (0, 1)` into two new\n * rational cubic curves. The first curve's evaluation on `[0, 1]` matches\n * the original's on `[0, t]`; the second matches the original's on `[t, 1]`.\n * Equivalent to de Casteljau subdivision on the homogeneous control polygon,\n * but performed directly on the per-axis monomial polynomials.\n *\n * @param c - The rational cubic curve to subdivide.\n * @param t - The split parameter; must be in the open interval `(0, 1)`.\n * @returns A `[left, right]` tuple of rational cubic curves.\n * @since 2.0.0\n */\n (c: RationalCubicCurve2d, t: number): [RationalCubicCurve2d, RationalCubicCurve2d]\n /**\n * Subdivides a rational cubic curve at parameter `t ∈ (0, 1)`.\n *\n * @param t - The split parameter; must be in the open interval `(0, 1)`.\n * @returns A function that takes a curve and returns its `[left, right]` halves.\n * @since 2.0.0\n */\n (t: number): (c: RationalCubicCurve2d) => [RationalCubicCurve2d, RationalCubicCurve2d]\n} = internal.subdivide\n\n/**\n * Computes a closed axis-aligned bounding box for a rational cubic curve from\n * its projected control polygon. Looser than the tight extrema-based box used\n * by `CubicCurve2d.boundingBox` — finding tight extrema of `x(t)/w(t)` and\n * `y(t)/w(t)` requires solving degree-5 polynomials — but always valid: a\n * positive-weight rational Bézier curve lies inside the convex hull of its\n * projected control points, so the AABB of those points contains the curve.\n *\n * Suitable for subdivision-based geometric queries, where bound looseness is\n * compensated by recursion depth.\n *\n * @param c - The rational cubic curve.\n * @returns A closed `Interval2d` enclosing the curve.\n * @since 2.0.0\n */\nexport const boundingBox: (c: RationalCubicCurve2d) => Interval2d<Closed, Closed> =\n internal.boundingBox\n\nexport const approximateAsCubicCurves: {\n /**\n * Approximates the rational cubic as a sequence of polynomial cubic curves\n * via recursive subdivision. At each level a candidate polynomial cubic is\n * built by projecting the segment's homogeneous Bézier control points to\n * 2D; if the symmetric Hausdorff distance between the rational segment and\n * its candidate exceeds `tolerance` (verified via a certified subdivision\n * bound, not a single-point sample), the segment is split at `t = 0.5` and\n * the procedure recurses on each half. Returns a non-empty array; for a\n * curve that is already polynomial (uniform weights) the result is a\n * single exact segment.\n *\n * The Hausdorff guarantee means: every point on the rational lies within\n * `tolerance` of some output segment, and every point on the output lies\n * within `tolerance` of the rational — a true two-sided bound on geometric\n * deviation, not just a parametric error at one sample.\n *\n * @param c - The rational cubic curve to approximate.\n * @param tolerance - Maximum allowed Hausdorff distance; must be positive.\n * @returns A sequence of polynomial cubic curves covering the input.\n * @since 2.0.0\n */\n (c: RationalCubicCurve2d, tolerance: number): ReadonlyArray<CubicCurve2d>\n /**\n * Approximates the rational cubic as a sequence of polynomial cubic curves.\n *\n * @param tolerance - Maximum allowed Hausdorff distance; must be positive.\n * @returns A function that takes a curve and returns its polynomial approximation.\n * @since 2.0.0\n */\n (tolerance: number): (c: RationalCubicCurve2d) => ReadonlyArray<CubicCurve2d>\n} = internal.approximateAsCubicCurves\n"],"mappings":";;;;;;;;;;;AASA,MAAa,sBAAqC,OAAO,uBAAuB;;AAIhF,IAAa,oBAAb,cAAuC,SAAoD;CACzF,CAAU,uBAA4C;CAEtD;CACA;CAEA,YAAY,IAAuC,IAAuC;EACxF,OAAO;EACP,KAAK,IAAI;EACT,KAAK,IAAI;;CAGX,KAAK,KAAK;EACR,OAAO,KAAK;;CAGd,KAAK,KAAK;EACR,OAAO,KAAK;;;;AAKhB,MAAaA,qBAGS,IAAI,OAAO,IAAI,kBAAkB,IAAI,GAAG;;AAG9D,MAAaC,sBACX,IACA,OACG,IAAI,kBAAkBC,OAAsB,GAAG,GAAG,GAAG,EAAE,EAAEA,OAAsB,GAAG,GAAG,GAAG,EAAE,CAAC;;AAKhG,MAAaC,mBACX,IACA,OAEA,IAAI,kBACFD,OAAsB,GAAG,GAAG,GAAG,IAAI,GAAG,EAAE,EACxCA,OAAsB,GAAG,GAAG,GAAG,IAAI,GAAG,EAAE,CACzC;;AAGH,MAAaE,qBAAmB,MAC9B,OAAO,MAAM,YAAY,MAAM,QAAQ,uBAAuB;;AAGhE,MAAaC,gBAAc,MAAqBC,KAAa,EAAE,EAAE,IAAI,EAAE,EAAE,GAAG;;AAG5E,MAAaC,UAAQ,KAGnB,IAAI,GA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Q;;;;;;;;;;;AAYF,MAAa,kBAIeC;;;;;;;;;;;;;;AAe5B,MAAa,mBAKeC;;;;;;;;;;;;;;;;;;;;;;;AAwB5B,MAAa,sBAGuCC;AAEpD,MAAa,QAmBTC;AAEJ,MAAa,WA0BTC;AAEJ,MAAa,WAyBTC;AAEJ,MAAa,YAsBTC;;;;;;;;;;;;;;;;AAiBJ,MAAa,cACXC;AAEF,MAAa,2BA+BTC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rationalCubic2d-MojACId0.mjs","names":["isLinearPath2d","make","fromArray","append","length","LinearCurve2d.length","Interval.unit","solve","LinearCurve2d.solve","toPathData","isContinuous","asContinuous","isIncreasingX","LinearPolynomial.isIncreasing","isDecreasingX","LinearPolynomial.isDecreasing","isMonotonicX","isIncreasingY","isDecreasingY","isMonotonicY","asIncreasingX","asDecreasingX","asMonotonicX","asIncreasingY","asDecreasingY","asMonotonicY","solveAtX","Solution.one","LinearCurve2d.solveAtX","Solution.isNone","Solution.none","solveAtY","LinearCurve2d.solveAtY","boundingBox","LinearCurve2d.boundingBox","Interval2d.union","make","internal.make","fromArray","internal.fromArray","internal.isLinearPath2d","append","internal.append","length","internal.length","solve","internal.solve","toPathData","internal.toPathData","isContinuous","internal.isContinuous","asContinuous","internal.asContinuous","isIncreasingX","internal.isIncreasingX","isDecreasingX","internal.isDecreasingX","isMonotonicX","internal.isMonotonicX","isIncreasingY","internal.isIncreasingY","isDecreasingY","internal.isDecreasingY","isMonotonicY","internal.isMonotonicY","asIncreasingX","internal.asIncreasingX","asDecreasingX","internal.asDecreasingX","asMonotonicX","internal.asMonotonicX","asIncreasingY","internal.asIncreasingY","asDecreasingY","internal.asDecreasingY","asMonotonicY","internal.asMonotonicY","solveAtX","internal.solveAtX","solveAtY","internal.solveAtY","boundingBox","internal.boundingBox","isCubicPath2d","make","fromArray","append","length","CubicCurve2d.length","Interval.unit","solve","CubicCurve2d.solve","derivative","cubicCurveInternal.derivative","Interval.make","Vector2.magnitude","QuadraticCurve2d.solve","toPathData","isContinuous","asContinuous","isIncreasingX","CubicPolynomial.isIncreasing","isDecreasingX","CubicPolynomial.isDecreasing","isMonotonicX","isIncreasingY","isDecreasingY","isMonotonicY","asIncreasingX","asDecreasingX","asMonotonicX","asIncreasingY","asDecreasingY","asMonotonicY","solveAtX","Solution.one","CubicCurve2d.solveAtX","Solution.isNone","Solution.none","solveAtY","CubicCurve2d.solveAtY","solveByDistance","boundingBox","CubicCurve2d.boundingBox","Interval2d.union","make","internal.make","fromArray","internal.fromArray","internal.isCubicPath2d","append","internal.append","internal.length","solve","internal.solve","internal.toPathData","internal.isContinuous","internal.asContinuous","internal.isIncreasingX","internal.isDecreasingX","internal.isMonotonicX","internal.isIncreasingY","internal.isDecreasingY","internal.isMonotonicY","internal.asIncreasingX","internal.asDecreasingX","internal.asMonotonicX","internal.asIncreasingY","internal.asDecreasingY","internal.asMonotonicY","internal.solveAtX","internal.solveAtY","internal.solveByDistance","internal.boundingBox","isRationalCubicPath2d","make","fromArray","append","solve","RationalCubicCurve2d.solve","approximateAsCubicPath","RationalCubicCurve2d.approximateAsCubicCurves","CubicPath2d.fromArray","internal.isRationalCubicPath2d","internal.make","internal.fromArray","internal.append","internal.solve","internal.approximateAsCubicPath"],"sources":["../../src/path/linear2d.internal.ts","../../src/path/linear2d.ts","../../src/path/cubic2d.internal.ts","../../src/path/cubic2d.ts","../../src/path/rationalCubic2d.internal.ts","../../src/path/rationalCubic2d.ts"],"sourcesContent":["import * as Interval2d from '../interval/interval2d.ts'\nimport * as LinearCurve2d from '../curve/linear2d.ts'\nimport * as Interval from '../interval/interval.ts'\nimport * as LinearPolynomial from '../polynomial/linear.ts'\nimport * as Solution from '../solution/solution.ts'\nimport { dual, Pipeable } from '../utils.ts'\nimport { invariant } from '../utils.ts'\nimport { EPSILON, epsEquals } from '../number.ts'\nimport type { Vector2 } from '../vector/vector2.ts'\nimport type { LinearPath2d } from './linear2d.ts'\nimport {\n PathTraits,\n type Continuous,\n type DecreasingX,\n type DecreasingY,\n type IncreasingX,\n type IncreasingY,\n type MonotonicX,\n type MonotonicY,\n} from './traits.ts'\n\nexport const LinearPath2dTypeId: unique symbol = Symbol('curvy/path/linear2d')\nexport type LinearPath2dTypeId = typeof LinearPath2dTypeId\n\n/** @internal */\nexport class LinearPath2dImpl extends Pipeable implements LinearPath2d<unknown> {\n readonly [LinearPath2dTypeId]: LinearPath2dTypeId = LinearPath2dTypeId\n declare readonly [PathTraits]: unknown\n\n readonly curves: ReadonlyArray<LinearCurve2d.LinearCurve2d>\n\n constructor(curves: ReadonlyArray<LinearCurve2d.LinearCurve2d>) {\n super()\n this.curves = curves\n }\n\n [Symbol.iterator](): Iterator<LinearCurve2d.LinearCurve2d> {\n return this.curves[Symbol.iterator]()\n }\n}\n\n/** @internal */\nexport const isLinearPath2d = (p: unknown): p is LinearPath2d =>\n typeof p === 'object' && p !== null && LinearPath2dTypeId in p\n\n/** @internal */\nexport const make = (...curves: ReadonlyArray<LinearCurve2d.LinearCurve2d>): LinearPath2d =>\n new LinearPath2dImpl(curves)\n\n/** @internal */\nexport const fromArray = (curves: ReadonlyArray<LinearCurve2d.LinearCurve2d>) =>\n new LinearPath2dImpl(curves)\n\n/** @internal */\nexport const append = dual<\n (c: LinearCurve2d.LinearCurve2d) => (p: LinearPath2d) => LinearPath2d,\n (p: LinearPath2d, c: LinearCurve2d.LinearCurve2d) => LinearPath2d\n>(2, (p: LinearPath2d, c: LinearCurve2d.LinearCurve2d) => fromArray([...p, c]))\n\n/** @internal */\nexport const length = (p: LinearPath2d) => {\n let total = 0\n for (const curve of p) {\n total += LinearCurve2d.length(curve, Interval.unit)\n }\n\n return total\n}\n\n/** @internal */\nexport const solve = dual<\n (u: number) => (p: LinearPath2d) => Vector2,\n (p: LinearPath2d, u: number) => Vector2\n>(2, (p: LinearPath2d, u: number) => {\n const curves = p instanceof LinearPath2dImpl ? p.curves : [...p]\n\n if (u === 1) {\n const last = curves.at(-1) as LinearCurve2d.LinearCurve2d\n return LinearCurve2d.solve(last, 1)\n }\n\n const t = u * curves.length\n const i = Math.floor(t)\n const curve = curves[i] as LinearCurve2d.LinearCurve2d\n return LinearCurve2d.solve(curve, t - i)\n})\n\n/** @internal */\nexport const toPathData = (p: LinearPath2d): string => {\n let result = ''\n let prevEndX = Number.NaN\n let prevEndY = Number.NaN\n\n for (const curve of p) {\n const startX = curve.x.c0\n const startY = curve.y.c0\n const endX = curve.x.c0 + curve.x.c1\n const endY = curve.y.c0 + curve.y.c1\n\n if (!epsEquals(startX, prevEndX) || !epsEquals(startY, prevEndY)) {\n result += ` M ${startX},${startY}`\n }\n result += ` L ${endX},${endY}`\n\n prevEndX = endX\n prevEndY = endY\n }\n\n return result.slice(1)\n}\n\n/** @internal */\nexport const isContinuous = <T>(p: LinearPath2d<T>): p is LinearPath2d<T & Continuous> => {\n let prevEndX = Number.NaN\n let prevEndY = Number.NaN\n let first = true\n\n for (const curve of p) {\n const startX = curve.x.c0\n const startY = curve.y.c0\n if (!first && (!epsEquals(startX, prevEndX) || !epsEquals(startY, prevEndY))) {\n return false\n }\n prevEndX = curve.x.c0 + curve.x.c1\n prevEndY = curve.y.c0 + curve.y.c1\n first = false\n }\n return true\n}\n\n/** @internal */\nexport const asContinuous = <T>(p: LinearPath2d<T>): LinearPath2d<T & Continuous> => {\n invariant(isContinuous(p), 'linear path is not continuous')\n return p\n}\n\n// Per-axis monotonicity refiners. A path is monotonic-on-an-axis when every\n// segment's per-axis polynomial is strictly monotonic in the same direction\n// AND adjacent segments' ranges on that axis don't overlap (modulo float\n// tolerance) — so the path's u → axis mapping is monotonic across joins.\n\n/** @internal */\nexport const isIncreasingX = <T>(p: LinearPath2d<T>): p is LinearPath2d<T & IncreasingX> => {\n let prevEnd = Number.NEGATIVE_INFINITY\n for (const c of p) {\n if (!LinearPolynomial.isIncreasing(c.x)) {\n return false\n }\n if (c.x.c0 < prevEnd - EPSILON) {\n return false\n }\n prevEnd = c.x.c0 + c.x.c1\n }\n return true\n}\n\n/** @internal */\nexport const isDecreasingX = <T>(p: LinearPath2d<T>): p is LinearPath2d<T & DecreasingX> => {\n let prevEnd = Number.POSITIVE_INFINITY\n for (const c of p) {\n if (!LinearPolynomial.isDecreasing(c.x)) {\n return false\n }\n if (c.x.c0 > prevEnd + EPSILON) {\n return false\n }\n prevEnd = c.x.c0 + c.x.c1\n }\n return true\n}\n\n/** @internal */\nexport const isMonotonicX = <T>(p: LinearPath2d<T>): p is LinearPath2d<T & MonotonicX> =>\n isIncreasingX(p) || isDecreasingX(p)\n\n/** @internal */\nexport const isIncreasingY = <T>(p: LinearPath2d<T>): p is LinearPath2d<T & IncreasingY> => {\n let prevEnd = Number.NEGATIVE_INFINITY\n for (const c of p) {\n if (!LinearPolynomial.isIncreasing(c.y)) {\n return false\n }\n if (c.y.c0 < prevEnd - EPSILON) {\n return false\n }\n prevEnd = c.y.c0 + c.y.c1\n }\n return true\n}\n\n/** @internal */\nexport const isDecreasingY = <T>(p: LinearPath2d<T>): p is LinearPath2d<T & DecreasingY> => {\n let prevEnd = Number.POSITIVE_INFINITY\n for (const c of p) {\n if (!LinearPolynomial.isDecreasing(c.y)) {\n return false\n }\n if (c.y.c0 > prevEnd + EPSILON) {\n return false\n }\n prevEnd = c.y.c0 + c.y.c1\n }\n return true\n}\n\n/** @internal */\nexport const isMonotonicY = <T>(p: LinearPath2d<T>): p is LinearPath2d<T & MonotonicY> =>\n isIncreasingY(p) || isDecreasingY(p)\n\n/** @internal */\nexport const asIncreasingX = <T>(p: LinearPath2d<T>): LinearPath2d<T & IncreasingX> => {\n invariant(isIncreasingX(p), 'linear path is not increasing in x')\n return p\n}\n\n/** @internal */\nexport const asDecreasingX = <T>(p: LinearPath2d<T>): LinearPath2d<T & DecreasingX> => {\n invariant(isDecreasingX(p), 'linear path is not decreasing in x')\n return p\n}\n\n/** @internal */\nexport const asMonotonicX = <T>(p: LinearPath2d<T>): LinearPath2d<T & MonotonicX> => {\n invariant(isMonotonicX(p), 'linear path is not monotonic in x')\n return p\n}\n\n/** @internal */\nexport const asIncreasingY = <T>(p: LinearPath2d<T>): LinearPath2d<T & IncreasingY> => {\n invariant(isIncreasingY(p), 'linear path is not increasing in y')\n return p\n}\n\n/** @internal */\nexport const asDecreasingY = <T>(p: LinearPath2d<T>): LinearPath2d<T & DecreasingY> => {\n invariant(isDecreasingY(p), 'linear path is not decreasing in y')\n return p\n}\n\n/** @internal */\nexport const asMonotonicY = <T>(p: LinearPath2d<T>): LinearPath2d<T & MonotonicY> => {\n invariant(isMonotonicY(p), 'linear path is not monotonic in y')\n return p\n}\n\n// solveAtX/solveAtY for `Monotonic{X,Y}` paths. Two defenses against float\n// drift at interior knots (where adjacent segments both bracket the query):\n// 1. Snap to t=0/t=1 endpoint y when the query is within EPSILON of a\n// segment's start or end.\n// 2. Fall through to the next bracketing segment on `none`. Linear paths\n// don't currently surface drift (degree-1 `c0 + c1 = x` is stable), but\n// the same shape applies for symmetry with quadratic / cubic.\n/** @internal */\nexport const solveAtX = dual(2, (p: LinearPath2d, x: number): Solution.AtMostOne<number> => {\n for (const c of p) {\n const sx = c.x.c0\n const ex = c.x.c0 + c.x.c1\n const lo = Math.min(sx, ex)\n const hi = Math.max(sx, ex)\n if (x >= lo - EPSILON && x <= hi + EPSILON) {\n if (epsEquals(x, sx)) {\n return Solution.one(c.y.c0)\n }\n if (epsEquals(x, ex)) {\n return Solution.one(c.y.c0 + c.y.c1)\n }\n const sol = LinearCurve2d.solveAtX(c, x)\n if (!Solution.isNone(sol)) {\n return sol\n }\n }\n }\n return Solution.none\n})\n\n/** @internal */\nexport const solveAtY = dual(2, (p: LinearPath2d, y: number): Solution.AtMostOne<number> => {\n for (const c of p) {\n const sy = c.y.c0\n const ey = c.y.c0 + c.y.c1\n const lo = Math.min(sy, ey)\n const hi = Math.max(sy, ey)\n if (y >= lo - EPSILON && y <= hi + EPSILON) {\n if (epsEquals(y, sy)) {\n return Solution.one(c.x.c0)\n }\n if (epsEquals(y, ey)) {\n return Solution.one(c.x.c0 + c.x.c1)\n }\n const sol = LinearCurve2d.solveAtY(c, y)\n if (!Solution.isNone(sol)) {\n return sol\n }\n }\n }\n return Solution.none\n})\n\n/** @internal */\nexport const boundingBox = (\n p: LinearPath2d,\n): Interval2d.Interval2d<Interval.Closed, Interval.Closed> => {\n const iter = p[Symbol.iterator]()\n const first = iter.next()\n // path invariant: at least one curve, so first.value is defined\n let acc = LinearCurve2d.boundingBox(first.value as LinearCurve2d.LinearCurve2d)\n for (let next = iter.next(); !next.done; next = iter.next()) {\n acc = Interval2d.union(acc, LinearCurve2d.boundingBox(next.value))\n }\n return acc\n}\n","import type { Interval2d } from '../interval/interval2d.ts'\nimport type { LinearCurve2d } from '../curve/linear2d.ts'\nimport type { Closed } from '../interval/interval.ts'\nimport type * as Solution from '../solution/solution.ts'\nimport type { Pipeable } from '../utils.ts'\nimport type { Vector2 } from '../vector/vector2.ts'\nimport type { LinearPath2dTypeId } from './linear2d.internal.ts'\nimport * as internal from './linear2d.internal.ts'\nimport type {\n Continuous,\n DecreasingX,\n DecreasingY,\n IncreasingX,\n IncreasingY,\n MonotonicX,\n MonotonicY,\n PathTraits,\n} from './traits.ts'\n\nexport type {\n Continuous,\n DecreasingX,\n DecreasingY,\n IncreasingX,\n IncreasingY,\n MonotonicX,\n MonotonicY,\n} from './traits.ts'\n\n/**\n * A linear path in 2D space.\n *\n * All fields are readonly and immutable, and all operations create new instances.\n *\n * The `Trait` type parameter accumulates trait brands as the path is refined\n * via `isContinuous` / `asContinuous`. A `Continuous` path's `toPathData`\n * skips the per-segment discontinuity check.\n *\n * @since 1.0.0\n */\nexport interface LinearPath2d<out Trait = unknown> extends Pipeable, Iterable<LinearCurve2d> {\n readonly [LinearPath2dTypeId]: LinearPath2dTypeId\n readonly [PathTraits]: Trait\n}\n\n/**\n * Creates a new `LinearPath2d` instance from a sequence of curves.\n *\n * @param curves - The curves to create the path from.\n * @returns A new `LinearPath2d` instance.\n * @since 2.0.0\n */\nexport const make: (...curves: ReadonlyArray<LinearCurve2d>) => LinearPath2d = internal.make\n\n/**\n * Creates a new `LinearPath2d` instance from an array of curves.\n *\n * @param curves - The curves to create the path from.\n * @returns A new `LinearPath2d` instance.\n * @since 2.0.0\n */\nexport const fromArray: (curves: ReadonlyArray<LinearCurve2d>) => LinearPath2d = internal.fromArray\n\n/**\n * Checks if a value is a `LinearPath2d`.\n *\n * @param p - The value to check.\n * @returns `true` if the value is a `LinearPath2d`, `false` otherwise.\n * @since 1.0.0\n */\nexport const isLinearPath2d: (p: unknown) => p is LinearPath2d = internal.isLinearPath2d\n\nexport const append: {\n /**\n * Appends a linear curve to a linear path.\n *\n * @param c - The linear curve to append.\n * @returns A function that takes a linear path and returns a new linear path.\n * @since 1.0.0\n */\n (c: LinearCurve2d): (p: LinearPath2d) => LinearPath2d\n /**\n * Appends a linear curve to a linear path.\n *\n * @param p - The linear path to append to.\n * @param c - The linear curve to append.\n * @returns A new `LinearPath2d` instance with the appended curve.\n * @since 1.0.0\n */\n (p: LinearPath2d, c: LinearCurve2d): LinearPath2d\n} = internal.append\n\n/**\n * Calculates the length of a linear path.\n *\n * @param p - The linear path to calculate the length of.\n * @returns The length of the linear path.\n * @since 1.0.0\n */\nexport const length: (p: LinearPath2d) => number = internal.length\n\nexport const solve: {\n /**\n * Solves a linear path for a given parameter.\n *\n * @param u - The parameter to solve for.\n * @returns A function that takes a linear path and returns the solved point.\n * @since 1.0.0\n */\n (u: number): (p: LinearPath2d) => Vector2\n /**\n * Solves a linear path for a given parameter.\n *\n * @param p - The linear path to solve.\n * @param u - The parameter to solve for.\n * @returns The solved point on the linear path.\n * @since 1.0.0\n */\n (p: LinearPath2d, u: number): Vector2\n} = internal.solve\n\n/**\n * Serializes a linear path as an SVG path data string (the value of a `<path>`\n * element's `d` attribute), using `M` and `L` commands. Discontinuities between\n * curves emit a fresh `M` command.\n *\n * @param p - The linear path to serialize.\n * @returns The SVG path data string.\n * @since 2.0.0\n */\nexport const toPathData: (p: LinearPath2d) => string = internal.toPathData\n\n/**\n * Type-narrowing predicate: refines `LinearPath2d<T>` to\n * `LinearPath2d<T & Continuous>` when adjacent curves connect at their join\n * points.\n *\n * @param p - The linear path to check.\n * @returns `true` when the path is continuous (G⁰).\n * @since 2.0.0\n */\nexport const isContinuous: <T>(p: LinearPath2d<T>) => p is LinearPath2d<T & Continuous> =\n internal.isContinuous\n\n/**\n * Asserts that the linear path is continuous, throwing on failure.\n *\n * @param p - The linear path to assert against.\n * @returns The same path, typed with the `Continuous` brand.\n * @throws When the path has a discontinuity between adjacent curves.\n * @since 2.0.0\n */\nexport const asContinuous: <T>(p: LinearPath2d<T>) => LinearPath2d<T & Continuous> =\n internal.asContinuous\n\n/**\n * Type-narrowing predicate: refines `LinearPath2d<T>` to\n * `LinearPath2d<T & IncreasingX>` when every segment's x-polynomial is\n * strictly increasing and adjacent segments' x-ranges don't overlap.\n *\n * @since 2.0.0\n */\nexport const isIncreasingX: <T>(p: LinearPath2d<T>) => p is LinearPath2d<T & IncreasingX> =\n internal.isIncreasingX\n\n/**\n * Type-narrowing predicate: refines `LinearPath2d<T>` to\n * `LinearPath2d<T & DecreasingX>` when every segment's x-polynomial is\n * strictly decreasing and adjacent segments' x-ranges don't overlap.\n *\n * @since 2.0.0\n */\nexport const isDecreasingX: <T>(p: LinearPath2d<T>) => p is LinearPath2d<T & DecreasingX> =\n internal.isDecreasingX\n\n/**\n * Type-narrowing predicate: refines `LinearPath2d<T>` to\n * `LinearPath2d<T & MonotonicX>` when the path is either increasing or\n * decreasing in x along its full parameter domain.\n *\n * @since 2.0.0\n */\nexport const isMonotonicX: <T>(p: LinearPath2d<T>) => p is LinearPath2d<T & MonotonicX> =\n internal.isMonotonicX\n\n/**\n * Type-narrowing predicate: refines `LinearPath2d<T>` to\n * `LinearPath2d<T & IncreasingY>`. The y-axis analog of {@link isIncreasingX}.\n *\n * @since 2.0.0\n */\nexport const isIncreasingY: <T>(p: LinearPath2d<T>) => p is LinearPath2d<T & IncreasingY> =\n internal.isIncreasingY\n\n/**\n * Type-narrowing predicate: refines `LinearPath2d<T>` to\n * `LinearPath2d<T & DecreasingY>`. The y-axis analog of {@link isDecreasingX}.\n *\n * @since 2.0.0\n */\nexport const isDecreasingY: <T>(p: LinearPath2d<T>) => p is LinearPath2d<T & DecreasingY> =\n internal.isDecreasingY\n\n/**\n * Type-narrowing predicate: refines `LinearPath2d<T>` to\n * `LinearPath2d<T & MonotonicY>`. The y-axis analog of {@link isMonotonicX}.\n *\n * @since 2.0.0\n */\nexport const isMonotonicY: <T>(p: LinearPath2d<T>) => p is LinearPath2d<T & MonotonicY> =\n internal.isMonotonicY\n\n/**\n * Asserts that the path is strictly increasing in x, throwing on failure.\n *\n * @since 2.0.0\n */\nexport const asIncreasingX: <T>(p: LinearPath2d<T>) => LinearPath2d<T & IncreasingX> =\n internal.asIncreasingX\n\n/**\n * Asserts that the path is strictly decreasing in x, throwing on failure.\n *\n * @since 2.0.0\n */\nexport const asDecreasingX: <T>(p: LinearPath2d<T>) => LinearPath2d<T & DecreasingX> =\n internal.asDecreasingX\n\n/**\n * Asserts that the path is monotonic in x, throwing on failure.\n *\n * @since 2.0.0\n */\nexport const asMonotonicX: <T>(p: LinearPath2d<T>) => LinearPath2d<T & MonotonicX> =\n internal.asMonotonicX\n\n/**\n * Asserts that the path is strictly increasing in y, throwing on failure.\n *\n * @since 2.0.0\n */\nexport const asIncreasingY: <T>(p: LinearPath2d<T>) => LinearPath2d<T & IncreasingY> =\n internal.asIncreasingY\n\n/**\n * Asserts that the path is strictly decreasing in y, throwing on failure.\n *\n * @since 2.0.0\n */\nexport const asDecreasingY: <T>(p: LinearPath2d<T>) => LinearPath2d<T & DecreasingY> =\n internal.asDecreasingY\n\n/**\n * Asserts that the path is monotonic in y, throwing on failure.\n *\n * @since 2.0.0\n */\nexport const asMonotonicY: <T>(p: LinearPath2d<T>) => LinearPath2d<T & MonotonicY> =\n internal.asMonotonicY\n\nexport const solveAtX: {\n /**\n * Evaluates the path's y value at a given x. Requires the path to carry the\n * `MonotonicX` brand — without it, an x query could match multiple\n * segments and the return cardinality would be unbounded.\n *\n * Returns `Solution.none` when x falls outside the path's x-range.\n *\n * @param p - A path branded `MonotonicX`.\n * @param x - The x coordinate.\n * @returns The y value at x, or `none` when x is outside the path's range.\n * @since 2.0.0\n */\n <T extends MonotonicX>(p: LinearPath2d<T>, x: number): Solution.AtMostOne<number>\n /** @since 2.0.0 */\n (x: number): <T extends MonotonicX>(p: LinearPath2d<T>) => Solution.AtMostOne<number>\n} = internal.solveAtX as never\n\nexport const solveAtY: {\n /**\n * Evaluates the path's x value at a given y. Requires the path to carry the\n * `MonotonicY` brand. Returns `Solution.none` when y is outside the path's\n * y-range.\n *\n * @param p - A path branded `MonotonicY`.\n * @param y - The y coordinate.\n * @returns The x value at y, or `none` when y is outside the path's range.\n * @since 2.0.0\n */\n <T extends MonotonicY>(p: LinearPath2d<T>, y: number): Solution.AtMostOne<number>\n /** @since 2.0.0 */\n (y: number): <T extends MonotonicY>(p: LinearPath2d<T>) => Solution.AtMostOne<number>\n} = internal.solveAtY as never\n\n/**\n * Computes the axis-aligned bounding box of the path — the smallest closed\n * `Box2d` enclosing every segment.\n *\n * @param p - The linear path.\n * @returns A closed `Box2d` enclosing the path.\n * @since 2.0.0\n */\nexport const boundingBox: (p: LinearPath2d) => Interval2d<Closed, Closed> = internal.boundingBox\n","import * as Interval2d from '../interval/interval2d.ts'\nimport * as CubicCurve2d from '../curve/cubic2d.ts'\nimport * as cubicCurveInternal from '../curve/cubic2d.internal.ts'\nimport * as QuadraticCurve2d from '../curve/quadratic2d.ts'\nimport * as Interval from '../interval/interval.ts'\nimport * as CubicPolynomial from '../polynomial/cubic.ts'\nimport * as Solution from '../solution/solution.ts'\nimport { dual, Pipeable } from '../utils.ts'\nimport { invariant } from '../utils.ts'\nimport { EPSILON, epsEquals } from '../number.ts'\nimport * as Vector2 from '../vector/vector2.ts'\nimport type { CubicPath2d } from './cubic2d.ts'\nimport {\n PathTraits,\n type Continuous,\n type DecreasingX,\n type DecreasingY,\n type IncreasingX,\n type IncreasingY,\n type MonotonicX,\n type MonotonicY,\n} from './traits.ts'\n\nexport const CubicPath2dTypeId: unique symbol = Symbol('curvy/path/cubic2d')\nexport type CubicPath2dTypeId = typeof CubicPath2dTypeId\n\n/** @internal */\nexport class CubicPath2dImpl extends Pipeable implements CubicPath2d<unknown> {\n readonly [CubicPath2dTypeId]: CubicPath2dTypeId = CubicPath2dTypeId\n declare readonly [PathTraits]: unknown\n\n readonly curves: ReadonlyArray<CubicCurve2d.CubicCurve2d>\n\n constructor(curves: ReadonlyArray<CubicCurve2d.CubicCurve2d>) {\n invariant(curves.length > 0, 'cubic path requires at least one curve')\n super()\n this.curves = curves\n }\n\n [Symbol.iterator](): Iterator<CubicCurve2d.CubicCurve2d> {\n return this.curves[Symbol.iterator]()\n }\n}\n\n/** @internal */\nexport const isCubicPath2d = (p: unknown): p is CubicPath2d =>\n typeof p === 'object' && p !== null && CubicPath2dTypeId in p\n\n/** @internal */\nexport const make = (...curves: ReadonlyArray<CubicCurve2d.CubicCurve2d>): CubicPath2d =>\n new CubicPath2dImpl(curves)\n\n/** @internal */\nexport const fromArray = (curves: ReadonlyArray<CubicCurve2d.CubicCurve2d>): CubicPath2d =>\n new CubicPath2dImpl(curves)\n\n/** @internal */\nexport const append = dual<\n (c: CubicCurve2d.CubicCurve2d) => (p: CubicPath2d) => CubicPath2d,\n (p: CubicPath2d, c: CubicCurve2d.CubicCurve2d) => CubicPath2d\n>(2, (p: CubicPath2d, c: CubicCurve2d.CubicCurve2d) => fromArray([...p, c]))\n\n/** @internal */\nexport const length = (p: CubicPath2d) => {\n let total = 0\n for (const curve of p) {\n total += CubicCurve2d.length(curve, Interval.unit)\n }\n\n return total\n}\n\n/** @internal */\nexport const solve = dual<\n (u: number) => (p: CubicPath2d) => Vector2.Vector2,\n (p: CubicPath2d, u: number) => Vector2.Vector2\n>(2, (p: CubicPath2d, u: number) => {\n const curves = p instanceof CubicPath2dImpl ? p.curves : [...p]\n\n if (u === 1) {\n const last = curves.at(-1) as CubicCurve2d.CubicCurve2d\n return CubicCurve2d.solve(last, 1)\n }\n\n const t = u * curves.length\n const i = Math.floor(t)\n const curve = curves[i] as CubicCurve2d.CubicCurve2d\n return CubicCurve2d.solve(curve, t - i)\n})\n\n// Cumulative segment lengths cache. lengths[k] = total length through segment k.\n// Cached by path identity since paths are immutable.\nconst cumulativeLengthCache = new WeakMap<CubicPath2d, ReadonlyArray<number>>()\n\nconst getCumulativeLengths = (p: CubicPath2d): ReadonlyArray<number> => {\n let cached = cumulativeLengthCache.get(p)\n if (cached === undefined) {\n const lengths: Array<number> = []\n let total = 0\n for (const curve of p) {\n total += CubicCurve2d.length(curve, Interval.unit)\n lengths.push(total)\n }\n cached = lengths\n cumulativeLengthCache.set(p, cached)\n }\n return cached\n}\n\n// Newton's method to find the local parameter t ∈ [0, 1] within `curve` such\n// that the arc length from 0 to t equals `target`. Each iteration costs one\n// GL32 quadrature plus one velocity eval; converges in 3–5 iterations for\n// well-behaved curves. Falls back to bisection on cusps where speed → 0.\nconst solveCurveByDistance = (\n curve: CubicCurve2d.CubicCurve2d,\n target: number,\n segmentLength: number,\n): number => {\n if (target <= 0) {\n return 0\n }\n if (target >= segmentLength) {\n return 1\n }\n\n const derivative = cubicCurveInternal.derivative(curve)\n\n let t = target / segmentLength\n let lo = 0\n let hi = 1\n\n for (let iter = 0; iter < 16; iter++) {\n const currentLength = CubicCurve2d.length(curve, Interval.make(0, t))\n const error = currentLength - target\n\n if (Math.abs(error) < 1e-10) {\n return t\n }\n\n if (error > 0) {\n hi = t\n } else {\n lo = t\n }\n\n const speed = Vector2.magnitude(QuadraticCurve2d.solve(derivative, t))\n if (speed === 0) {\n // cusp — bisect instead\n t = (lo + hi) / 2\n continue\n }\n\n const next = t - error / speed\n // bracket-clamp Newton step; if it leaves the bracket, fall back to bisection\n t = next > lo && next < hi ? next : (lo + hi) / 2\n }\n\n return t\n}\n\n// Cubic Bernstein basis: P(t) = (1-t)³·p0 + 3(1-t)²t·p1 + 3(1-t)t²·p2 + t³·p3\n// expanded gives c0 = p0, c1 = -3p0 + 3p1, c2 = 3p0 - 6p1 + 3p2, c3 = -p0 + 3p1 - 3p2 + p3,\n// so: p0 = c0, p1 = c0 + c1/3, p2 = c0 + 2c1/3 + c2/3, p3 = c0 + c1 + c2 + c3.\n/** @internal */\nexport const toPathData = (p: CubicPath2d): string => {\n let result = ''\n let prevEndX = Number.NaN\n let prevEndY = Number.NaN\n\n for (const curve of p) {\n const c0x = curve.x.c0\n const c0y = curve.y.c0\n const c1x = curve.x.c1\n const c1y = curve.y.c1\n const c2x = curve.x.c2\n const c2y = curve.y.c2\n const c3x = curve.x.c3\n const c3y = curve.y.c3\n\n const startX = c0x\n const startY = c0y\n const ctrl1X = c0x + c1x / 3\n const ctrl1Y = c0y + c1y / 3\n const ctrl2X = c0x + (2 * c1x) / 3 + c2x / 3\n const ctrl2Y = c0y + (2 * c1y) / 3 + c2y / 3\n const endX = c0x + c1x + c2x + c3x\n const endY = c0y + c1y + c2y + c3y\n\n if (!epsEquals(startX, prevEndX) || !epsEquals(startY, prevEndY)) {\n result += ` M ${startX},${startY}`\n }\n result += ` C ${ctrl1X},${ctrl1Y} ${ctrl2X},${ctrl2Y} ${endX},${endY}`\n\n prevEndX = endX\n prevEndY = endY\n }\n\n return result.slice(1)\n}\n\n/** @internal */\nexport const isContinuous = <T>(p: CubicPath2d<T>): p is CubicPath2d<T & Continuous> => {\n let prevEndX = Number.NaN\n let prevEndY = Number.NaN\n let first = true\n\n for (const curve of p) {\n const startX = curve.x.c0\n const startY = curve.y.c0\n if (!first && (!epsEquals(startX, prevEndX) || !epsEquals(startY, prevEndY))) {\n return false\n }\n prevEndX = curve.x.c0 + curve.x.c1 + curve.x.c2 + curve.x.c3\n prevEndY = curve.y.c0 + curve.y.c1 + curve.y.c2 + curve.y.c3\n first = false\n }\n return true\n}\n\n/** @internal */\nexport const asContinuous = <T>(p: CubicPath2d<T>): CubicPath2d<T & Continuous> => {\n invariant(isContinuous(p), 'cubic path is not continuous')\n return p\n}\n\n// Per-axis monotonicity for the path: every segment's axis polynomial must be\n// strictly monotonic over the unit interval AND adjacent segments' axis\n// ranges must not overlap (modulo EPSILON for float drift).\n/** @internal */\nexport const isIncreasingX = <T>(p: CubicPath2d<T>): p is CubicPath2d<T & IncreasingX> => {\n let prevEnd = Number.NEGATIVE_INFINITY\n for (const c of p) {\n if (!CubicPolynomial.isIncreasing(c.x, Interval.unit)) {\n return false\n }\n if (c.x.c0 < prevEnd - EPSILON) {\n return false\n }\n prevEnd = c.x.c0 + c.x.c1 + c.x.c2 + c.x.c3\n }\n return true\n}\n\n/** @internal */\nexport const isDecreasingX = <T>(p: CubicPath2d<T>): p is CubicPath2d<T & DecreasingX> => {\n let prevEnd = Number.POSITIVE_INFINITY\n for (const c of p) {\n if (!CubicPolynomial.isDecreasing(c.x, Interval.unit)) {\n return false\n }\n if (c.x.c0 > prevEnd + EPSILON) {\n return false\n }\n prevEnd = c.x.c0 + c.x.c1 + c.x.c2 + c.x.c3\n }\n return true\n}\n\n/** @internal */\nexport const isMonotonicX = <T>(p: CubicPath2d<T>): p is CubicPath2d<T & MonotonicX> =>\n isIncreasingX(p) || isDecreasingX(p)\n\n/** @internal */\nexport const isIncreasingY = <T>(p: CubicPath2d<T>): p is CubicPath2d<T & IncreasingY> => {\n let prevEnd = Number.NEGATIVE_INFINITY\n for (const c of p) {\n if (!CubicPolynomial.isIncreasing(c.y, Interval.unit)) {\n return false\n }\n if (c.y.c0 < prevEnd - EPSILON) {\n return false\n }\n prevEnd = c.y.c0 + c.y.c1 + c.y.c2 + c.y.c3\n }\n return true\n}\n\n/** @internal */\nexport const isDecreasingY = <T>(p: CubicPath2d<T>): p is CubicPath2d<T & DecreasingY> => {\n let prevEnd = Number.POSITIVE_INFINITY\n for (const c of p) {\n if (!CubicPolynomial.isDecreasing(c.y, Interval.unit)) {\n return false\n }\n if (c.y.c0 > prevEnd + EPSILON) {\n return false\n }\n prevEnd = c.y.c0 + c.y.c1 + c.y.c2 + c.y.c3\n }\n return true\n}\n\n/** @internal */\nexport const isMonotonicY = <T>(p: CubicPath2d<T>): p is CubicPath2d<T & MonotonicY> =>\n isIncreasingY(p) || isDecreasingY(p)\n\n/** @internal */\nexport const asIncreasingX = <T>(p: CubicPath2d<T>): CubicPath2d<T & IncreasingX> => {\n invariant(isIncreasingX(p), 'cubic path is not increasing in x')\n return p\n}\n\n/** @internal */\nexport const asDecreasingX = <T>(p: CubicPath2d<T>): CubicPath2d<T & DecreasingX> => {\n invariant(isDecreasingX(p), 'cubic path is not decreasing in x')\n return p\n}\n\n/** @internal */\nexport const asMonotonicX = <T>(p: CubicPath2d<T>): CubicPath2d<T & MonotonicX> => {\n invariant(isMonotonicX(p), 'cubic path is not monotonic in x')\n return p\n}\n\n/** @internal */\nexport const asIncreasingY = <T>(p: CubicPath2d<T>): CubicPath2d<T & IncreasingY> => {\n invariant(isIncreasingY(p), 'cubic path is not increasing in y')\n return p\n}\n\n/** @internal */\nexport const asDecreasingY = <T>(p: CubicPath2d<T>): CubicPath2d<T & DecreasingY> => {\n invariant(isDecreasingY(p), 'cubic path is not decreasing in y')\n return p\n}\n\n/** @internal */\nexport const asMonotonicY = <T>(p: CubicPath2d<T>): CubicPath2d<T & MonotonicY> => {\n invariant(isMonotonicY(p), 'cubic path is not monotonic in y')\n return p\n}\n\n// At an interior knot, two adjacent segments both bracket the query — one's\n// right endpoint and the next's left endpoint are (within float drift) the\n// same value. The per-curve cubic-root solver can return `none` for both\n// brackets when the true root sits just outside [0, 1] due to that drift. We\n// handle this two ways:\n// 1. If the query is within EPSILON of a segment's start or end, evaluate y\n// directly at t=0 or t=1 — skips polynomial inversion entirely.\n// 2. Otherwise, if a bracketing segment returns `none`, fall through to the\n// next bracketing segment. `MonotonicX` admits at most one real solution\n// across the path, so retrying after `none` is safe.\n/** @internal */\nexport const solveAtX = dual(2, (p: CubicPath2d, x: number): Solution.AtMostOne<number> => {\n for (const c of p) {\n const sx = c.x.c0\n const ex = c.x.c0 + c.x.c1 + c.x.c2 + c.x.c3\n const lo = Math.min(sx, ex)\n const hi = Math.max(sx, ex)\n if (x >= lo - EPSILON && x <= hi + EPSILON) {\n if (epsEquals(x, sx)) {\n return Solution.one(c.y.c0)\n }\n if (epsEquals(x, ex)) {\n return Solution.one(c.y.c0 + c.y.c1 + c.y.c2 + c.y.c3)\n }\n const sol = CubicCurve2d.solveAtX(c, x) as Solution.AtMostOne<number>\n if (!Solution.isNone(sol)) {\n return sol\n }\n }\n }\n return Solution.none\n})\n\n/** @internal */\nexport const solveAtY = dual(2, (p: CubicPath2d, y: number): Solution.AtMostOne<number> => {\n for (const c of p) {\n const sy = c.y.c0\n const ey = c.y.c0 + c.y.c1 + c.y.c2 + c.y.c3\n const lo = Math.min(sy, ey)\n const hi = Math.max(sy, ey)\n if (y >= lo - EPSILON && y <= hi + EPSILON) {\n if (epsEquals(y, sy)) {\n return Solution.one(c.x.c0)\n }\n if (epsEquals(y, ey)) {\n return Solution.one(c.x.c0 + c.x.c1 + c.x.c2 + c.x.c3)\n }\n const sol = CubicCurve2d.solveAtY(c, y) as Solution.AtMostOne<number>\n if (!Solution.isNone(sol)) {\n return sol\n }\n }\n }\n return Solution.none\n})\n\n/** @internal */\nexport const solveByDistance = dual<\n (s: number) => (p: CubicPath2d) => Vector2.Vector2,\n (p: CubicPath2d, s: number) => Vector2.Vector2\n>(2, (p: CubicPath2d, s: number) => {\n if (s <= 0) {\n return solve(p, 0)\n }\n if (s >= 1) {\n return solve(p, 1)\n }\n\n const lengths = getCumulativeLengths(p)\n const total = lengths[lengths.length - 1] as number\n const target = s * total\n\n // find segment k such that lengths[k-1] ≤ target ≤ lengths[k]\n let k = 0\n while (k < lengths.length - 1 && (lengths[k] as number) < target) {\n k++\n }\n\n const segmentStart = k === 0 ? 0 : (lengths[k - 1] as number)\n const segmentEnd = lengths[k] as number\n const segmentLength = segmentEnd - segmentStart\n const segmentTarget = target - segmentStart\n\n const curves = p instanceof CubicPath2dImpl ? p.curves : [...p]\n const curve = curves[k] as CubicCurve2d.CubicCurve2d\n const localT = solveCurveByDistance(curve, segmentTarget, segmentLength)\n\n return CubicCurve2d.solve(curve, localT)\n})\n\n/** @internal */\nexport const boundingBox = (\n p: CubicPath2d,\n): Interval2d.Interval2d<Interval.Closed, Interval.Closed> => {\n const iter = p[Symbol.iterator]()\n const first = iter.next()\n let acc = CubicCurve2d.boundingBox(first.value as CubicCurve2d.CubicCurve2d)\n for (let next = iter.next(); !next.done; next = iter.next()) {\n acc = Interval2d.union(acc, CubicCurve2d.boundingBox(next.value))\n }\n return acc\n}\n","import type { Interval2d } from '../interval/interval2d.ts'\nimport type { CubicCurve2d } from '../curve/cubic2d.ts'\nimport type { Closed } from '../interval/interval.ts'\nimport type * as Solution from '../solution/solution.ts'\nimport type { Pipeable } from '../utils.ts'\nimport type { Vector2 } from '../vector/vector2.ts'\nimport type { CubicPath2dTypeId } from './cubic2d.internal.ts'\nimport * as internal from './cubic2d.internal.ts'\nimport type {\n Continuous,\n DecreasingX,\n DecreasingY,\n IncreasingX,\n IncreasingY,\n MonotonicX,\n MonotonicY,\n PathTraits,\n} from './traits.ts'\n\nexport type {\n Continuous,\n DecreasingX,\n DecreasingY,\n IncreasingX,\n IncreasingY,\n MonotonicX,\n MonotonicY,\n} from './traits.ts'\n\n/**\n * A cubic path in 2D space.\n *\n * All fields are readonly and immutable, and all operations create new instances.\n *\n * The `Trait` type parameter accumulates trait brands as the path is refined\n * via `isContinuous` / `asContinuous`.\n *\n * @since 1.0.0\n */\nexport interface CubicPath2d<out Trait = unknown> extends Pipeable, Iterable<CubicCurve2d> {\n readonly [CubicPath2dTypeId]: CubicPath2dTypeId\n readonly [PathTraits]: Trait\n}\n\n/**\n * Creates a new `CubicPath2d` instance from a sequence of curves.\n *\n * @param curves - The curves to create the path from.\n * @returns A new `CubicPath2d` instance.\n * @since 2.0.0\n */\nexport const make: (...curves: ReadonlyArray<CubicCurve2d>) => CubicPath2d = internal.make\n\n/**\n * Creates a new `CubicPath2d` instance from an array of curves.\n *\n * @param curves - The curves to create the path from.\n * @returns A new `CubicPath2d` instance.\n * @since 2.0.0\n */\nexport const fromArray: (curves: ReadonlyArray<CubicCurve2d>) => CubicPath2d = internal.fromArray\n\n/**\n * Checks if a value is a `CubicPath2d`.\n *\n * @param p - The value to check.\n * @returns `true` if the value is a `CubicPath2d`, `false` otherwise.\n * @since 1.0.0\n */\nexport const isCubicPath2d: (p: unknown) => p is CubicPath2d = internal.isCubicPath2d\n\nexport const append: {\n /**\n * Appends a cubic curve to a cubic path.\n *\n * @param c - The cubic curve to append.\n * @returns A function that takes a cubic path and returns a new cubic path.\n * @since 1.0.0\n */\n (c: CubicCurve2d): (p: CubicPath2d) => CubicPath2d\n /**\n * Appends a cubic curve to a cubic path.\n *\n * @param p - The cubic path to append to.\n * @param c - The cubic curve to append.\n * @returns A new cubic path.\n * @since 1.0.0\n */\n (p: CubicPath2d, c: CubicCurve2d): CubicPath2d\n} = internal.append\n\n/**\n * Calculates the length of a cubic path.\n *\n * @param p - The cubic path to calculate the length of.\n * @returns The length of the cubic path.\n * @since 1.0.0\n */\nexport const length: (p: CubicPath2d) => number = internal.length\n\nexport const solve: {\n /**\n * Solves a cubic path for a given parameter.\n *\n * @param u - The parameter to solve for.\n * @returns A function that takes a cubic path and returns the solved vector.\n * @since 1.0.0\n */\n (u: number): (p: CubicPath2d) => Vector2\n /**\n * Solves a cubic path for a given parameter.\n *\n * @param p - The cubic path to solve.\n * @param u - The parameter to solve for.\n * @returns The solved vector.\n * @since 1.0.0\n */\n (p: CubicPath2d, u: number): Vector2\n} = internal.solve\n\n/**\n * Serializes a cubic path as an SVG path data string (the value of a `<path>`\n * element's `d` attribute), using `M` and `C` commands. Discontinuities between\n * curves emit a fresh `M` command.\n *\n * @param p - The cubic path to serialize.\n * @returns The SVG path data string.\n * @since 2.0.0\n */\nexport const toPathData: (p: CubicPath2d) => string = internal.toPathData\n\n/**\n * Type-narrowing predicate: refines `CubicPath2d<T>` to\n * `CubicPath2d<T & Continuous>` when adjacent curves connect.\n *\n * @since 2.0.0\n */\nexport const isContinuous: <T>(p: CubicPath2d<T>) => p is CubicPath2d<T & Continuous> =\n internal.isContinuous\n\n/**\n * Asserts that the cubic path is continuous, throwing on failure.\n *\n * @since 2.0.0\n */\nexport const asContinuous: <T>(p: CubicPath2d<T>) => CubicPath2d<T & Continuous> =\n internal.asContinuous\n\n/**\n * Type-narrowing predicate: refines `CubicPath2d<T>` to\n * `CubicPath2d<T & IncreasingX>` when every segment's x-polynomial is\n * strictly increasing on `[0, 1]` and adjacent segments' x-ranges don't\n * overlap.\n *\n * @since 2.0.0\n */\nexport const isIncreasingX: <T>(p: CubicPath2d<T>) => p is CubicPath2d<T & IncreasingX> =\n internal.isIncreasingX\n\n/**\n * Type-narrowing predicate: refines `CubicPath2d<T>` to\n * `CubicPath2d<T & DecreasingX>`.\n *\n * @since 2.0.0\n */\nexport const isDecreasingX: <T>(p: CubicPath2d<T>) => p is CubicPath2d<T & DecreasingX> =\n internal.isDecreasingX\n\n/**\n * Type-narrowing predicate: refines `CubicPath2d<T>` to\n * `CubicPath2d<T & MonotonicX>`.\n *\n * @since 2.0.0\n */\nexport const isMonotonicX: <T>(p: CubicPath2d<T>) => p is CubicPath2d<T & MonotonicX> =\n internal.isMonotonicX\n\n/**\n * Type-narrowing predicate: refines `CubicPath2d<T>` to\n * `CubicPath2d<T & IncreasingY>`.\n *\n * @since 2.0.0\n */\nexport const isIncreasingY: <T>(p: CubicPath2d<T>) => p is CubicPath2d<T & IncreasingY> =\n internal.isIncreasingY\n\n/**\n * Type-narrowing predicate: refines `CubicPath2d<T>` to\n * `CubicPath2d<T & DecreasingY>`.\n *\n * @since 2.0.0\n */\nexport const isDecreasingY: <T>(p: CubicPath2d<T>) => p is CubicPath2d<T & DecreasingY> =\n internal.isDecreasingY\n\n/**\n * Type-narrowing predicate: refines `CubicPath2d<T>` to\n * `CubicPath2d<T & MonotonicY>`.\n *\n * @since 2.0.0\n */\nexport const isMonotonicY: <T>(p: CubicPath2d<T>) => p is CubicPath2d<T & MonotonicY> =\n internal.isMonotonicY\n\n/**\n * Asserts that the path is strictly increasing in x, throwing on failure.\n *\n * @since 2.0.0\n */\nexport const asIncreasingX: <T>(p: CubicPath2d<T>) => CubicPath2d<T & IncreasingX> =\n internal.asIncreasingX\n\n/**\n * Asserts that the path is strictly decreasing in x, throwing on failure.\n *\n * @since 2.0.0\n */\nexport const asDecreasingX: <T>(p: CubicPath2d<T>) => CubicPath2d<T & DecreasingX> =\n internal.asDecreasingX\n\n/**\n * Asserts that the path is monotonic in x, throwing on failure.\n *\n * @since 2.0.0\n */\nexport const asMonotonicX: <T>(p: CubicPath2d<T>) => CubicPath2d<T & MonotonicX> =\n internal.asMonotonicX\n\n/**\n * Asserts that the path is strictly increasing in y, throwing on failure.\n *\n * @since 2.0.0\n */\nexport const asIncreasingY: <T>(p: CubicPath2d<T>) => CubicPath2d<T & IncreasingY> =\n internal.asIncreasingY\n\n/**\n * Asserts that the path is strictly decreasing in y, throwing on failure.\n *\n * @since 2.0.0\n */\nexport const asDecreasingY: <T>(p: CubicPath2d<T>) => CubicPath2d<T & DecreasingY> =\n internal.asDecreasingY\n\n/**\n * Asserts that the path is monotonic in y, throwing on failure.\n *\n * @since 2.0.0\n */\nexport const asMonotonicY: <T>(p: CubicPath2d<T>) => CubicPath2d<T & MonotonicY> =\n internal.asMonotonicY\n\nexport const solveAtX: {\n /**\n * Evaluates the path's y value at a given x. Requires the path to carry\n * the `MonotonicX` brand. Returns `Solution.none` when x is outside the\n * path's x-range.\n *\n * @param p - A path branded `MonotonicX`.\n * @param x - The x coordinate.\n * @returns The y value at x, or `none` when x is outside the path's range.\n * @since 2.0.0\n */\n <T extends MonotonicX>(p: CubicPath2d<T>, x: number): Solution.AtMostOne<number>\n /** @since 2.0.0 */\n (x: number): <T extends MonotonicX>(p: CubicPath2d<T>) => Solution.AtMostOne<number>\n} = internal.solveAtX as never\n\nexport const solveAtY: {\n /**\n * Evaluates the path's x value at a given y. Requires the path to carry\n * the `MonotonicY` brand. Returns `Solution.none` when y is outside the\n * path's y-range.\n *\n * @param p - A path branded `MonotonicY`.\n * @param y - The y coordinate.\n * @returns The x value at y, or `none` when y is outside the path's range.\n * @since 2.0.0\n */\n <T extends MonotonicY>(p: CubicPath2d<T>, y: number): Solution.AtMostOne<number>\n /** @since 2.0.0 */\n (y: number): <T extends MonotonicY>(p: CubicPath2d<T>) => Solution.AtMostOne<number>\n} = internal.solveAtY as never\n\nexport const solveByDistance: {\n /**\n * Solves a cubic path by normalized arc length. Unlike {@link solve}, which\n * is parameterized by curve `u`, this samples points at constant speed along\n * the path — `s = 0.5` returns the point exactly halfway along the curve by\n * arc length, regardless of how the underlying parameterization stretches.\n *\n * Cumulative segment lengths are cached by path identity so repeated calls\n * with the same path are fast.\n *\n * @param p - The cubic path to sample.\n * @param s - Normalized arc length in `[0, 1]`. Values outside the range are\n * clamped to path endpoints.\n * @returns The point on the path at the given normalized arc length.\n * @since 1.1.0\n */\n (p: CubicPath2d, s: number): Vector2\n /**\n * Solves a cubic path by normalized arc length.\n *\n * @param s - Normalized arc length in `[0, 1]`.\n * @returns A function that takes a cubic path and returns the point at that\n * arc length.\n * @since 1.1.0\n */\n (s: number): (p: CubicPath2d) => Vector2\n} = internal.solveByDistance\n\n/**\n * Computes the axis-aligned bounding box of the path — the smallest closed\n * `Box2d` enclosing every segment.\n *\n * @param p - The cubic path.\n * @returns A closed `Box2d` enclosing the path.\n * @since 2.0.0\n */\nexport const boundingBox: (p: CubicPath2d) => Interval2d<Closed, Closed> = internal.boundingBox\n","import type * as CubicCurve2d from '../curve/cubic2d.ts'\nimport * as RationalCubicCurve2d from '../curve/rationalCubic2d.ts'\nimport { dual, Pipeable } from '../utils.ts'\nimport { invariant } from '../utils.ts'\nimport type * as Vector2 from '../vector/vector2.ts'\nimport * as CubicPath2d from './cubic2d.ts'\nimport type { RationalCubicPath2d } from './rationalCubic2d.ts'\n\nexport const RationalCubicPath2dTypeId: unique symbol = Symbol('curvy/path/rationalCubic2d')\nexport type RationalCubicPath2dTypeId = typeof RationalCubicPath2dTypeId\n\n/** @internal */\nexport class RationalCubicPath2dImpl extends Pipeable implements RationalCubicPath2d {\n readonly [RationalCubicPath2dTypeId]: RationalCubicPath2dTypeId = RationalCubicPath2dTypeId\n\n readonly curves: ReadonlyArray<RationalCubicCurve2d.RationalCubicCurve2d>\n\n constructor(curves: ReadonlyArray<RationalCubicCurve2d.RationalCubicCurve2d>) {\n invariant(curves.length > 0, 'rational cubic path requires at least one curve')\n super()\n this.curves = curves\n }\n\n [Symbol.iterator](): Iterator<RationalCubicCurve2d.RationalCubicCurve2d> {\n return this.curves[Symbol.iterator]()\n }\n}\n\n/** @internal */\nexport const isRationalCubicPath2d = (p: unknown): p is RationalCubicPath2d =>\n typeof p === 'object' && p !== null && RationalCubicPath2dTypeId in p\n\n/** @internal */\nexport const make = (\n ...curves: ReadonlyArray<RationalCubicCurve2d.RationalCubicCurve2d>\n): RationalCubicPath2d => new RationalCubicPath2dImpl(curves)\n\n/** @internal */\nexport const fromArray = (\n curves: ReadonlyArray<RationalCubicCurve2d.RationalCubicCurve2d>,\n): RationalCubicPath2d => new RationalCubicPath2dImpl(curves)\n\n/** @internal */\nexport const append = dual<\n (c: RationalCubicCurve2d.RationalCubicCurve2d) => (p: RationalCubicPath2d) => RationalCubicPath2d,\n (p: RationalCubicPath2d, c: RationalCubicCurve2d.RationalCubicCurve2d) => RationalCubicPath2d\n>(2, (p, c) => fromArray([...p, c]))\n\n/** @internal */\nexport const solve = dual<\n (u: number) => (p: RationalCubicPath2d) => Vector2.Vector2,\n (p: RationalCubicPath2d, u: number) => Vector2.Vector2\n>(2, (p: RationalCubicPath2d, u: number) => {\n const curves = p instanceof RationalCubicPath2dImpl ? p.curves : [...p]\n\n if (u === 1) {\n const last = curves.at(-1) as RationalCubicCurve2d.RationalCubicCurve2d\n return RationalCubicCurve2d.solve(last, 1)\n }\n\n const t = u * curves.length\n const i = Math.floor(t)\n const curve = curves[i] as RationalCubicCurve2d.RationalCubicCurve2d\n return RationalCubicCurve2d.solve(curve, t - i)\n})\n\n// Path-level approximation: per-segment approximation is delegated to the\n// curve module; we just concat the results. Segment count grows from N\n// (input) to roughly N × k where k depends on weight magnitude and tolerance —\n// uniform-weight segments stay 1:1.\n/** @internal */\nexport const approximateAsCubicPath = dual<\n (tolerance: number) => (p: RationalCubicPath2d) => CubicPath2d.CubicPath2d,\n (p: RationalCubicPath2d, tolerance: number) => CubicPath2d.CubicPath2d\n>(2, (p: RationalCubicPath2d, tolerance: number) => {\n const curves: Array<CubicCurve2d.CubicCurve2d> = []\n for (const segment of p) {\n for (const approx of RationalCubicCurve2d.approximateAsCubicCurves(segment, tolerance)) {\n curves.push(approx)\n }\n }\n return CubicPath2d.fromArray(curves)\n})\n","import type { RationalCubicCurve2d } from '../curve/rationalCubic2d.ts'\nimport type { Pipeable } from '../utils.ts'\nimport type { Vector2 } from '../vector/vector2.ts'\nimport type { CubicPath2d } from './cubic2d.ts'\nimport type { RationalCubicPath2dTypeId } from './rationalCubic2d.internal.ts'\nimport * as internal from './rationalCubic2d.internal.ts'\n\n/**\n * A rational cubic path in 2D space.\n *\n * Holds a non-empty sequence of `RationalCubicCurve2d` segments; iteration\n * yields the segments in order. The path parameter `u ∈ [0, 1]` is mapped\n * uniformly across segments — `u = 0` is the start of the first segment,\n * `u = 1` is the end of the last segment, and intermediate values pick a\n * segment by index and a local parameter within it.\n *\n * Counterpart to `CubicPath2d` for curves whose evaluation includes the\n * homogeneous-to-plane projection.\n *\n * All fields are readonly and immutable, and all operations create new instances.\n *\n * @since 2.0.0\n */\nexport interface RationalCubicPath2d extends Pipeable, Iterable<RationalCubicCurve2d> {\n readonly [RationalCubicPath2dTypeId]: RationalCubicPath2dTypeId\n}\n\n/**\n * Checks if a value is a `RationalCubicPath2d`.\n *\n * @param p - The value to check.\n * @returns `true` if the value is a `RationalCubicPath2d`, `false` otherwise.\n * @since 2.0.0\n */\nexport const isRationalCubicPath2d: (p: unknown) => p is RationalCubicPath2d =\n internal.isRationalCubicPath2d\n\n/**\n * Creates a new `RationalCubicPath2d` from a sequence of curves.\n *\n * @param curves - The curves to create the path from.\n * @returns A new `RationalCubicPath2d` instance.\n * @since 2.0.0\n */\nexport const make: (...curves: ReadonlyArray<RationalCubicCurve2d>) => RationalCubicPath2d =\n internal.make\n\n/**\n * Creates a new `RationalCubicPath2d` from an array of curves.\n *\n * @param curves - The curves to create the path from.\n * @returns A new `RationalCubicPath2d` instance.\n * @since 2.0.0\n */\nexport const fromArray: (curves: ReadonlyArray<RationalCubicCurve2d>) => RationalCubicPath2d =\n internal.fromArray\n\nexport const append: {\n /**\n * Appends a curve to a `RationalCubicPath2d`.\n *\n * @param c - The curve to append.\n * @returns A function that takes a path and returns a new path with the appended curve.\n * @since 2.0.0\n */\n (c: RationalCubicCurve2d): (p: RationalCubicPath2d) => RationalCubicPath2d\n /**\n * Appends a curve to a `RationalCubicPath2d`.\n *\n * @param p - The path to append to.\n * @param c - The curve to append.\n * @returns A new path with the appended curve.\n * @since 2.0.0\n */\n (p: RationalCubicPath2d, c: RationalCubicCurve2d): RationalCubicPath2d\n} = internal.append\n\nexport const solve: {\n /**\n * Evaluates the rational cubic path at parameter `u ∈ [0, 1]`.\n *\n * Picks the segment containing `u` (uniform mapping across segments) and\n * delegates to `RationalCubicCurve2d.solve` on that segment with the local\n * parameter.\n *\n * @param p - The path to evaluate.\n * @param u - The path parameter in `[0, 1]`.\n * @returns The point on the path at parameter `u`.\n * @since 2.0.0\n */\n (p: RationalCubicPath2d, u: number): Vector2\n /**\n * Evaluates the rational cubic path at parameter `u ∈ [0, 1]`.\n *\n * @param u - The path parameter in `[0, 1]`.\n * @returns A function that takes a path and returns the point at `u`.\n * @since 2.0.0\n */\n (u: number): (p: RationalCubicPath2d) => Vector2\n} = internal.solve\n\nexport const approximateAsCubicPath: {\n /**\n * Approximates the rational cubic path as a `CubicPath2d` via per-segment\n * recursive subdivision. Each input segment is split until its midpoint\n * deviates from a polynomial-cubic candidate by at most `tolerance`; the\n * surviving candidates are concatenated into a new path.\n *\n * Lossy in general — only exact when every input segment has uniform\n * weights, in which case segment count is preserved. Tighter tolerance\n * produces more segments.\n *\n * @param p - The rational cubic path to approximate.\n * @param tolerance - Maximum allowed midpoint deviation per segment; must be positive.\n * @returns A new `CubicPath2d` approximating the input.\n * @since 2.0.0\n */\n (p: RationalCubicPath2d, tolerance: number): CubicPath2d\n /**\n * Approximates the rational cubic path as a `CubicPath2d`.\n *\n * @param tolerance - Maximum allowed midpoint deviation per segment; must be positive.\n * @returns A function that takes a rational path and returns its approximation.\n * @since 2.0.0\n */\n (tolerance: number): (p: RationalCubicPath2d) => CubicPath2d\n} = internal.approximateAsCubicPath\n"],"mappings":";;;;;;;;;;;AAqBA,MAAa,qBAAoC,OAAO,sBAAsB;;AAI9E,IAAa,mBAAb,cAAsC,SAA0C;CAC9E,CAAU,sBAA0C;CAGpD;CAEA,YAAY,QAAoD;EAC9D,OAAO;EACP,KAAK,SAAS;;CAGhB,CAAC,OAAO,YAAmD;EACzD,OAAO,KAAK,OAAO,OAAO,WAAW;;;;AAKzC,MAAaA,oBAAkB,MAC7B,OAAO,MAAM,YAAY,MAAM,QAAQ,sBAAsB;;AAG/D,MAAaC,UAAQ,GAAG,WACtB,IAAI,iBAAiB,OAAO;;AAG9B,MAAaC,eAAa,WACxB,IAAI,iBAAiB,OAAO;;AAG9B,MAAaC,WAAS,KAGpB,IAAI,GAAiB,MAAmCD,YAAU,CAAC,GAAG,GAAG,EAAE,CAAC,CAAC;;AAG/E,MAAaE,YAAU,MAAoB;CACzC,IAAI,QAAQ;CACZ,KAAK,MAAM,SAAS,GAClB,SAASC,SAAqB,OAAOC,KAAc;CAGrD,OAAO;;;AAIT,MAAaC,UAAQ,KAGnB,IAAI,GAAiB,MAAc;CACnC,MAAM,SAAS,aA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