I have a large set of 3D data points to which I want to fit to an ellipsoid.
My maths is pretty poor, so I\'m having trouble implementing the least squares method withou
Here is very simple method to find foci's, based on random search. No linear algebra used. So if you are fine with non-perfect solution:
3DPoints - Array of some Amount of points
vecCenter - average of 3DPoints
AngleCosine - cos of angle between two vectors
RandomOrder(3DPoints)
vecFocus := (0, 0, 0)
for i := 0 to Amount:
vecRadius := 3DPoints[i] - vecCenter
// Change vecRadius direction to parallel
if AngleCosine(vecFocus, vecRadius) < 0 then
vecRadius *= -1
vecFocus += (vecRadius - vecFocus) / Amount
Result can be improved by passing array 2nd time in backward direction Foci's placed at vecCenter +/- vecFocus