import type { Interval2d } from '../interval/interval2d.ts'; import type { TwoDimensional } from '../dimensions.ts'; import type { Closed, Interval } from '../interval/interval.ts'; import type { Pipeable } from '../utils.ts'; import type { CubicPolynomial } from '../polynomial/cubic.ts'; import type { Decreasing, Increasing, Monotonic } from '../polynomial/traits.ts'; import type * as Solution from '../solution/solution.ts'; import type { Vector2 } from '../vector/vector2.ts'; import type { CubicCurve2dTypeId } from './cubic2d.internal.ts'; export type { Monotonic, Increasing, Decreasing } from '../polynomial/traits.ts'; /** * A cubic curve in 2D space. * * All fields are readonly and immutable, and all operations create new instances. * * The two type parameters carry the trait sets of the curve's per-axis * polynomials. Refiners check monotonicity over the unit interval `[0, 1]` — * the curve's natural parameter domain. * * @since 1.0.0 */ export interface CubicCurve2d extends Pipeable, TwoDimensional, CubicPolynomial> { readonly [CubicCurve2dTypeId]: CubicCurve2dTypeId; } /** * Creates a new `CubicCurve2d` instance from polynomial parameters. * * @param x - The x polynomial. * @param y - The y polynomial. * @returns A new `CubicCurve2d` instance. * @since 1.0.0 */ export declare const fromPolynomials: (x: CubicPolynomial, y: CubicPolynomial) => CubicCurve2d; /** * Creates a new `CubicCurve2d` instance from monomial coefficient vectors. * * Each argument bundles the per-axis coefficient at the given power: `c0` * holds the x⁰ term, `c1` holds the x¹ term, and so on. The resulting curve * evaluates to `c0 + c1·t + c2·t² + c3·t³` per axis. * * @param c0 - The x⁰ coefficients (x and y). * @param c1 - The x¹ coefficients (x and y). * @param c2 - The x² coefficients (x and y). * @param c3 - The x³ coefficients (x and y). * @returns A new `CubicCurve2d` instance. * @since 2.0.0 */ export declare const fromCoefficients: (c0: Vector2, c1: Vector2, c2: Vector2, c3: Vector2) => CubicCurve2d; /** * Creates a new `CubicCurve2d` instance from cubic Bézier control points. * * The four arguments are the Bernstein-basis control points: `p0` and `p3` are * the curve's endpoints and `p1` and `p2` are the off-curve control handles. * The implementation converts to the curve's internal monomial form in closed * form. * * @param p0 - The first control point (curve start). * @param p1 - The second control point (start handle). * @param p2 - The third control point (end handle). * @param p3 - The fourth control point (curve end). * @returns A new `CubicCurve2d` instance whose curve matches the given Bézier. * @since 2.0.0 */ export declare const fromBezierPoints: (p0: Vector2, p1: Vector2, p2: Vector2, p3: Vector2) => CubicCurve2d; /** * Checks if a value is a `CubicCurve2d`. * * @param c - The value to check. * @returns `true` if the value is a `CubicCurve2d`, `false` otherwise. * @since 1.0.0 */ export declare const isCubicCurve2d: (c: unknown) => c is CubicCurve2d; export declare const solve: { /** * Solves the cubic curve for a given parameter t. * * @param t - The parameter value. * @returns A function that takes a cubic curve and returns the point on the curve at parameter t. * @since 1.0.0 */ (t: number): (c: CubicCurve2d) => Vector2; /** * Solves the cubic curve for a given parameter t. * * @param c - The cubic curve to solve. * @param t - The parameter value. * @returns The point on the curve at parameter t. * @since 1.0.0 */ (c: CubicCurve2d, t: number): Vector2; }; export declare const length: { /** * Calculates (approximates) the length of a cubic curve. * * @param c - The cubic curve to calculate the length of. * @param i - The interval over which to calculate the length. * @returns The length of the cubic curve. * @since 1.0.0 */ (c: CubicCurve2d, i: Interval): number; /** * Calculates (approximates) the length of a cubic curve. * * @param i - The interval over which to calculate the length. * @returns A function that takes a cubic curve and returns the length of the cubic curve. * @since 1.0.0 */ (i: Interval): (c: CubicCurve2d) => number; }; export declare const solveAtX: { /** * Evaluates the curve's y values at a given x. Because the x polynomial is * `Monotonic`, the inverse has at most one solution — at most one y value. * * @param c - The cubic curve. * @param x - The x coordinate. * @returns Zero or one y values, in t-ascending order. * @since 2.0.0 */ (c: CubicCurve2d, x: number): Solution.AtMostOne; /** * Evaluates the curve's y values at a given x. The result is the y values * the curve passes through where x(t) = the given x — up to three solutions * for a cubic curve. * * @param c - The cubic curve. * @param x - The x coordinate. * @returns The y values at x, in t-ascending order. * @since 2.0.0 */ (c: CubicCurve2d, x: number): Solution.AtMostThree; /** @since 2.0.0 */ (x: number): { (c: CubicCurve2d): Solution.AtMostOne; (c: CubicCurve2d): Solution.AtMostThree; }; }; export declare const solveAtY: { /** * Evaluates the curve's x values at a given y. Because the y polynomial is * `Monotonic`, the inverse has at most one solution. * * @param c - The cubic curve. * @param y - The y coordinate. * @returns Zero or one x values, in t-ascending order. * @since 2.0.0 */ (c: CubicCurve2d, y: number): Solution.AtMostOne; /** * Evaluates the curve's x values at a given y. The result is the x values * the curve passes through where y(t) = the given y — up to three solutions * for a cubic curve. * * @param c - The cubic curve. * @param y - The y coordinate. * @returns The x values at y, in t-ascending order. * @since 2.0.0 */ (c: CubicCurve2d, y: number): Solution.AtMostThree; /** @since 2.0.0 */ (y: number): { (c: CubicCurve2d): Solution.AtMostOne; (c: CubicCurve2d): Solution.AtMostThree; }; }; export declare const curvature: { /** * Calculates the curvature of a cubic curve at a given parameter. * * @param c - The cubic curve to calculate the curvature for. * @param t - The parameter value. * @returns The curvature of the cubic curve at parameter t. * @since 1.0.0 */ (c: CubicCurve2d, t: number): number; /** * Calculates the curvature of a cubic curve at a given parameter. * * @param t - The parameter value. * @returns A function that takes a cubic curve and returns the curvature of the cubic curve at parameter t. * @since 1.0.0 */ (t: number): (c: CubicCurve2d) => number; }; /** * Computes the axis-aligned bounding box of the curve over its parameter * domain `[0, 1]`. Accounts for up to two interior extrema per axis, so the * box is tight against the curve and not just the control polygon. * * @param c - The cubic curve. * @returns A closed `Box2d` enclosing the curve. * @since 2.0.0 */ export declare const boundingBox: (c: CubicCurve2d) => Interval2d; /** * Type-narrowing predicate: refines both axes' traits to include `Monotonic` * when both x and y polynomials are monotonic over the unit interval `[0, 1]`. * * For checking only one axis, call the polynomial-level refiner directly: * `CubicPolynomial.isMonotonic(curve.x, Interval.unit)`. * * @since 2.0.0 */ export declare const isMonotonic: (c: CubicCurve2d) => c is CubicCurve2d; /** @since 2.0.0 */ export declare const isIncreasing: (c: CubicCurve2d) => c is CubicCurve2d; /** @since 2.0.0 */ export declare const isDecreasing: (c: CubicCurve2d) => c is CubicCurve2d; /** @since 2.0.0 */ export declare const asMonotonic: (c: CubicCurve2d) => CubicCurve2d; /** @since 2.0.0 */ export declare const asIncreasing: (c: CubicCurve2d) => CubicCurve2d; /** @since 2.0.0 */ export declare const asDecreasing: (c: CubicCurve2d) => CubicCurve2d;