Spiral fitting in python

330 views Asked by At

I have a set of datapoints (459, x/y coordinates) which can be seen here.

I already fitted a spline to the dataset. However, I would also like to fit a spiral to the datapoints. I was able to draw a sprial manually, but I couldnt find a ready-to-use function to fit the spiral to the datapoints. Probabaly I need to calculate the distances between each point and the closest points on a set of spirals and minimize the distances to find the bestfitting spiral. But how can I do that?

Thanks you for your help:)

I already fitted a spline to the dataset. However, I would also like to fit a spiral to the datapoints. I was able to draw a sprial manually, but I couldnt find a ready-to-use function to fit the spiral to the datapoints. Probabaly I need to calculate the distances between each point and the closest points on a set of spirals and minimize the distances to find the bestfitting spiral. But how can I do that?

Thanks you for your help:)

2

There are 2 answers

0
user_na On

Iy it is an Euler Spiral, you can use Fresnel integrals

import matplotlib.pyplot as plt
import numpy as np
from scipy.special import fresnel
t = np.linspace(0, 2, 500)
plt.plot(*fresnel(t))

plot)

0
JJacquelin On

This is not a direct answer to the question. This is a comment but too long to be edited in the comments section.

They are much simpler equation models than spiral to fit your data. For example an arc of ellipse is very easy to fit because the fitting is a simple linear Least Mean Square regression.

Since I don't have your data I got an approximate data from your graph thanks to scanning the red pixels of the graph (5216 pixels)

Just for explanation there is no need for so many points. Only one pixel in a hundred were taken for the simplified calculus below.

enter image description here