5

With the code below, I use scipy.interpolate.splprep routine to interpolate a set of points using B-splines. Evidently, this curve in the figure on the left is quite "sharp" near the 6th point: it's curvature is too large (see right figure).

enter image description here

I want the curvature to be limited to <10. I can improve this by increasing the smoothness factor s, e.g. setting it to s=8 gives:

enter image description here

Which satisfies my curvature bound. However, I currently have to find this smoothness factor s through trial and error (also, higher s does not necessarily imply a lower curvature). Is there anyway I can explicitely bound the curvature? I know it is theoretically possible based on this question.

Code (Python fiddle)

Thomas Wagenaar
  • 6,489
  • 5
  • 30
  • 73

3 Answers3

1

This is only a suggestion, but one thing that is possible as an alternative to deliberate smoothing is introduction of additional (fake) data points through which the curve should pass.

The condition to insert such points is to detect if there is a sharp reversal in direction between any two consecutive (real) points. This could be done by comparing the angle between directions of vectors containing any two consecutive nodes and if this angle is lower than certain threshold, the point is considered a 'reversal' point.

Once such reversal points are identified you can introduce P (fake) points, where the integer P depends on how smooth you would like these transitions to be. E.g. if you don't mind a U-shape, then you could introduce just one fake point per each reversal point that is slightly offset in the direction orthogonal to the reversal direction.

SultanOrazbayev
  • 14,900
  • 3
  • 16
  • 46
  • 1
    Thank you, this is actually similar to the approach i'm currently working on. Placing points so that each angle is under a threshold, and then using a spline with a fixed shape between each pair of points. If I succeed I will post it as an answer :) – Thomas Wagenaar Jan 14 '22 at 09:30
1

One known method is to interpolate points using Dubins paths. It provides the shortest curve between any two curves, while satisfying a minimum curvature. One implementation is described in this paper, called Markov-Dubins interpolation.

enter image description here

However, I do not recommend this approach because the curves are not smooth (there are discontinuities in the acceleration due to fixed levels of curvature).

Thomas Wagenaar
  • 6,489
  • 5
  • 30
  • 73
0

Not at the moment, at least not in scipy. Sadly.

ev-br
  • 24,968
  • 9
  • 65
  • 78