0

I have the a set of points and I pass a curve through them, using scipy CubeSpline, I really would like to know how can I add padding from outside, so that the curve is fitting the flow of the points but they are always inside it by some factor, as shown in this image, where what I have is the blue line and what I need to get is the red curve interpolated curve

def visualize_trajectory(points):
    points = np.array(points)
    distance = np.cumsum(np.sqrt(np.sum(np.diff(points, axis=0)**2, axis=1)))
    distance = np.insert(distance, 0, 0)/distance[-1]

    interpolations_methods = ['cubic']
    alpha = np.linspace(0, 1, 25)
    interpolator = CubicSpline(distance, points, axis=0)
    interpolated_points = {}
    for method in interpolations_methods:
        interpolator = CubicSpline(distance, points, axis=0)
        interpolated_points[method] = interpolator(alpha)

    plt.figure(figsize=(7, 7))
    plt.gca().invert_yaxis()
    for method_name, curve in interpolated_points.items():
        plt.plot(*curve.T, '-', label=method_name)

    plt.plot(*points.T, 'ok', label='original points')
    plt.axis('equal')
    plt.legend()
    plt.xlabel('x')
    plt.ylabel('y')
    # plt.show(block=False)
    plt.show()
    plt.close()

7
  • 1. You posted 3 questions within an hour. While there is no question limit, it doesn't make sense why you're asking more questions when you haven't addressed the comments on some of your previous questions (namely, your other questions are missing reproducible examples). 2. I edited the tags on your other questions, but please read the tags before using them--you've been using the python-3.x tag, which (if you read the description) should only be used for questions specifically pertaining to python 3. Commented Feb 14, 2024 at 22:02
  • I agree with you that I should have used python as a tag instead of python3, but I do not think saying "it does not make sense" for asking more questions is appropriate, I have different questions and they should be addressed in different threads, Who said that one needs to wait for a previous question to be answered so that I get the right to ask the next one? Sorry, but asking a question does not make me in a vulnerable position if you think so Commented Feb 15, 2024 at 9:01
  • You're missing my point. What "doesn't make sense" is that when you ask a question you should be ready to address comments. Posting more questions shows you're on the site but ignoring comments. Please read this post on how to ask a good question (note the "Help others reproduce the problem" and "Respond to feedback after posting"). As I said, there is no rule against asking multiple questions, but I could tell that the questions need improvement to be answerable--there's a reason you have 3 open (unanswered) questions and I'm trying to help. Commented Feb 15, 2024 at 14:47
  • So I stand by what I said. I was trying to help you, but you don't seem to want help. Commented Feb 15, 2024 at 14:49
  • Thank you, I understand your position, but I really did my best within my capabilities, I have posted the code I wrote and the image for the clarification to what I need, for other questions, you might be right, but I am doing my best Commented Feb 15, 2024 at 19:28

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.