My problem is im using Cubic Spline but i get this error trying to graph a race circuit
raise ValueError("x
must be strictly increasing sequence.")
ValueError: x
must be strictly increasing sequence.
So one of my questions is. How i do it without using increasing sequence?
I expected to create my race circuit only using cubic spline but i see i cant do it with only 2 arrays of coordinates(x,y). Some proposals?
The cubic spline method requires the independent coordinates of the samples to be sorted. One option would be to parameterize x
and y
as a function of, say, t
, such that t
is strictly increasing. (Think of t
being time parameterizing an arbitrary smooth curve in 2 or 3D). Just make a new array t = sorted array of the size of x that covers the range [0, 1]
, and get two interpolants, one for t, x
and one for t, y
.
If you're up to the challenge, take a look at the cubic version of Bezier curves for more inspiration: https://en.wikipedia.org/wiki/B%C3%A9zier_curve