I am trying to fit 3D data points (>1000) with the implicit function of a cylinder (5 parameters : a,b,c,d,r) :
-r + sqrt((x-(x+a*(-b+y)+c*(-d+z))/(1+a^2+c^2))^2+(-b+y-(a*(x+a*(-b+y)+c*(-d+z)))/(1+a^2+c^2))^2+(-d+z-(c*(x+a*(-b+y)+c*(-d+z)))/(1+a^2+c^2))^2) == 0
I can't find a good way to implement that with Matlab (my knowledge is till very shallow in Matlab syntax). It would be much easier with a explicit function for sure. I have looked extensively on the net and I haven't found any specific answer.
I have also the parametric function of the cylinder using the same parameters if you know a way to fit the parametric equation directly?
x = v-(c*r*cos(u))/(sqrt(1+c^2))-(a*r*sin(u))/((1+c^2)*sqrt(1+(a^2)/(1+c^2)));
y = b+a*v+(r*sin(u))/(sqrt(1+(a^2)/(1+c^2)));
z = d+c*v+(r*cos(u))/(sqrt(1+c^2))-(a*c*r*sin(u))/((1+c^2)*sqrt(1+(a^2)/(1+c^2)));
Thanks a lot in advance.