Skip to content

Add dimension-templated constrained curve wrapper - #61

Open
illionj wants to merge 1 commit into
perazz:mainfrom
illionj:mr/constrained-curve-template-only
Open

Add dimension-templated constrained curve wrapper#61
illionj wants to merge 1 commit into
perazz:mainfrom
illionj:mr/constrained-curve-template-only

Conversation

@illionj

@illionj illionj commented Jul 10, 2026

Copy link
Copy Markdown

First of all, thank you for this library. It has been very helpful in my work.

I ran into a small issue in my own use case: I mostly work with 2D curves, and
the current std::vector<fpPoint> representation means that each point is itself
a dynamically sized vector. In my path-smoothing code, this adds some extra
overhead and makes the call sites slightly less direct.

This PR adds fpConstrainedCurveTemplate<N>, an alternative fixed-dimension
wrapper around fitpack_constrained_curve_c.

The main change is that each point is represented as:

std::array<FP_REAL, N>

instead of a dynamically sized std::vector.

This is useful for common fixed-dimension cases such as 2D and 3D curves, while
keeping the existing API unchanged.

Example:

using Curve2D = fpConstrainedCurveTemplate<2>;
using Point2D = Curve2D::Point;
using Points2D = Curve2D::Points;

Points2D pts = {
    {0.0, 0.0},
    {1.0, 1.0},
    {2.0, 0.0},
};

Curve2D curve;
curve.new_fit(pts, 1e-4, 5);

Point2D p = curve.eval(0.5);
Point2D dp = curve.ddu(0.5, 1);

Changes

  • Adds include/fpConstrainedCurveTemplate.hpp
  • Exposes it from include/fitpack.hpp
  • Uses std::array<FP_REAL, N> for points
  • Keeps the existing fpConstrainedCurve API unchanged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant