brepjs API Reference
    Preparing search index...

    Interface Curve2D

    Handle-wrapped 2D parametric curve backed by an kernel kernel 2D curve.

    Provides evaluation, splitting, projection, tangent queries, and distance computations on a single parametric curve.

    interface Curve2D {
        _boundingBox: BoundingBox2d | null;
        get boundingBox(): BoundingBox2d;
        get firstParameter(): number;
        get firstPoint(): Point2D;
        get geomType(): CurveType;
        get lastParameter(): number;
        get lastPoint(): Point2D;
        get repr(): string;
        get wrapped(): any;
        "[dispose]"(): void;
        clone(): Curve2D;
        delete(): void;
        distanceFrom(element: Point2D | Curve2D): number;
        isOnCurve(point: Point2D): boolean;
        parameter(point: Point2D, precision?: number): Result<number>;
        reverse(): void;
        serialize(): string;
        splitAt(points: number[] | Point2D[], precision?: number): Curve2D[];
        tangentAt(index: number | Point2D): Point2D;
        value(parameter: number): Point2D;
    }
    Index
    _boundingBox: BoundingBox2d | null
    • get boundingBox(): BoundingBox2d

      Compute (and cache) the 2D bounding box of this curve.

      Returns BoundingBox2d

      The returned box is owned by the curve and is disposed when the curve is deleted. Clone it if it must outlive the curve.

    • get firstParameter(): number

      Return the parameter value at the start of the curve (cached after first access).

      Returns number

    • get lastParameter(): number

      Return the parameter value at the end of the curve (cached after first access).

      Returns number

    • get repr(): string

      Return a human-readable representation, e.g. LINE (0,0) - (1,1).

      Returns string

    • Project a point onto the curve and return its parameter value.

      Parameters

      • point: Point2D
      • precision: number = 1e-9

      Returns Result<number>

      Ok(parameter) when the point is on the curve, or an error result otherwise.

    • Serialize this curve to a string that can be restored with deserializeCurve2D.

      Returns string

    • Split this curve at the given points or parameter values.

      Parameters

      • points: number[] | Point2D[]
      • precision: number = 1e-9

      Returns Curve2D[]

      An array of sub-curves whose union covers the original curve.

    • Compute the tangent vector at a parameter position or at the projection of a point.

      Parameters

      • index: number | Point2D

        A normalized parameter (0..1) or a Point2D to project onto the curve.

      Returns Point2D