I'd like to find the best fit coefficients "a" and "c" for a toroidal surface, to a list of {x,y,z} points which are approximately on the surface of the torus. I believe I need LinearModelFit
for this, the function for the torus: z^2 == a^2 - (c - (x^2 + y^2)^(1/2))^2
and the data:
data={{x1,y1,z1},{x2,y2,z2},{x3,y3,z3},{x4,y4,z4},{x5,y5,z5}}; (* these would be passed as actual xyz values not variables. My fit function is more complicated than below so the actual values I have are not appropriate *)
In which case the command should look something like this but I'm clearly not expressing the torus function as a model correctly for LinearModelFit. Also I will need to include some constraints, but once I have the syntax and functional form for the model correct I should be able to manage the constraints and starting values:
LinearModelFit[data, z^2 == a^2 - (c - (x^2 + y^2)^(1/2))^2,{a,c,,x,y,z}]
This answer How to fit a surface to 3D data in Mathematica? is helpful but I couldn't see how to express the model for a torus in an equivalent form.
Torus = ResourceFunction["Torus"];
resources.wolframcloud.com/FunctionRepository/resources/Torus $\endgroup$