A NURBS curve implementation that can be used by other curve classes

Constructors

  • Creates a NURBS curve from degree, knots, control points, and optional weights.

    When weights is omitted, all control points receive a weight of 1.0 (non-rational B-spline).

    Parameters

    • degree: number

      Polynomial degree p of the basis functions

    • knots: number[]

      Non-decreasing knot vector of length n + p + 1

    • controlPoints: AcGeVector3dLike[]

      Control points in curve order

    • Optionalweights: number[]

      Optional rational weights aligned with control points

    Returns AcGeNurbsCurve

Methods

  • Evaluates position and parametric derivatives at parameter u.

    Returns the rational NURBS point together with first- and second-order parametric derivatives computed analytically from the basis functions.

    Parameters

    • u: number

      Curve parameter in the valid knot span

    Returns AcGeNurbsEvaluation

    Position point, first derivative deriv1, and second derivative deriv2

  • Samples a 2D path with analytic tangents for planar offset.

    Builds an initial uniform parameter list scaled by curve length and offset distance, then refines intervals where |offsetDist| * |curvature| exceeds 0.85 (potential cusp region). Each final sample includes a unit tangent derived from the analytic first derivative.

    Parameters

    • offsetDist: number

      Signed offset distance used to choose sample density

    • maxSamples: number = 512

      Upper bound on the number of returned samples (default 512)

    Returns { points: AcGePoint2d[]; tangents: AcGePoint2d[] }

    XY samples and matching unit tangents in parameter order

  • Get the valid parameter range for this curve

    Returns { end: number; start: number }

  • Get points along the curve

    Parameters

    • divisions: number

      Number of divisions to create

    Returns number[][]

    Array of points along the curve

  • Check if the curve is closed by comparing start and end points

    Parameters

    • tolerance: number = 1e-6

    Returns boolean

  • Calculates a point on the curve at parameter u.

    Delegates to evaluate and returns only the position component.

    Parameters

    • u: number

      Curve parameter in the valid knot span

    Returns number[]

    Evaluated point as [x, y, z]

  • Signed curvature in the XY plane at parameter u.

    Uses the standard planar formula (x'y'' - y'x'') / (x'^2 + y'^2)^(3/2) applied to the parametric derivatives from evaluate.

    Parameters

    • u: number

      Curve parameter in the valid knot span

    Returns number

    Signed curvature; positive indicates counterclockwise bending