I'm solving a path planning problem using optimization methods, for which the path required to be accurately estimated for calculating the cross-track error (error between two paths). To approximate the path I tried fitting a polynomial of 2 or 3 degrees but the approximation is not accurate, tried with spline but the x's in the path should always be non-decreasing (not sure whether this is mandatory, but faced an error in the spline library that I'm using) which is not the case as the input path might take a U-turn, are there any other methods to approximate path.
Thanks in advance. :)