assuming the first variable is the time axis, does cubic spline to fit all points along the spline. adaptively add points until the margin is less than a tolerance.
input is written with vector<Eigen::VectorXd>
but you can definitely change to whatever you want.