Boost logo

Boost Users :

From: Giorgino R (giorginor21_at_[hidden])
Date: 2019-09-30 08:51:11


Hi there,

You will need to normalise (0 - 1) your data set first.
To interpolate, you will need to pass normalised values, as well. Then you
can unscale the output in the range you want.

On Mon, Sep 30, 2019 at 1:51 AM hgrwilson via Boost-users <
boost-users_at_[hidden]> wrote:

> Hi all,
>
> I am trying to interpolate some data with a *catmull_rom* spline available
> in boost math (interpolation). However, the resulting spline collapses to a
> single point for all /s/, corresponding to the first control point,
> /points_intr[0]/.
>
> Below, the c++ code segment of the interpolation is depicted:
>
> std::vector<std::array&lt;double, 2>> points_intr(16);
>
> points_intr[0] = { 1.263270, 0.774614 };
> points_intr[1] = { 1.876, 2.480 };
> points_intr[2] = { 1.651110, 4.550 };
> points_intr[3] = { 1.426340, 5.688 };
> points_intr[4] = { 1.429, 7.054 };
> points_intr[5] = { 2.073220, 8.377020 };
> points_intr[6] = { 3.910, 9.140 };
> points_intr[7] = { 6.430, 9.537 };
> points_intr[8] = { 8.950, 9.859 };
> points_intr[9] = { 11.470, 10.317 };
> points_intr[10] = { 12.730, 10.6456 };
> points_intr[11] = { 13.990, 11.0741 };
> points_intr[12] = { 15.335, 11.6928 };
> points_intr[13] = { 16.680, 12.5661 };
> points_intr[14] = { 18.3538, 14.830 };
> points_intr[15] = { 18.700, 16.056 };
>
> boost::math::catmull_rom<std::array&lt;double, 2>>
> interpolator_cr(std::move(points_intr));
>
> auto max_s = interpolator_cr.max_parameter();
> std::array<double, 2> inter_points;
> for (int i = 0; i < 100; i++)
> {
> inter_points = interpolator_cr(max_s * (i / num_points));
> geometry_msgs::Point p;
> p.x = inter_points[0];
> p.y = inter_points[1];
> p.z = z;
> //p.z = inter_points[2];
> marker.points.push_back(p);
> DEBUG_INFO("spline %d: (x, y) %f, %f, current_s: %f",
> i, p.x, p.y, max_s * (i / 100.0));
> }
>
> I'm using boost 1.71.0
>
>
>
> --
> Sent from: http://boost.2283326.n4.nabble.com/Boost-Users-f2553780.html
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> https://lists.boost.org/mailman/listinfo.cgi/boost-users
>



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net