   Form ellipsoid around points
  Hello,I have a group of 3D points and their associated mean point. I want to form an ellipsoid around these points and the ellipsoid to have its centre at the mean point.At the moment I''m just calculating the points that are furthest away in the direction of the major and minor axis but there is a defect with this solution: some points will not be enclosed as the ellipsoid tapers off (i.e., slopes down to major axis).Does anybody know of a better solution? Thanks in advance.PS: I hope I have described this well enough
  The general equation for an ellipsoid centred on the origin isax^2 + by^2 + cz^2 + dxy + exz + fyz = 1So given six points you can solve the six simultaneous equations given by the points exactly for a, b, c, d, e and f to find an ellipsoid through them. Note that for general points you won''t always get an ellispoid, as this is more accurately the formula for conic surfaces, which also include various parabolic and hyperbolic surfaces.If you have six points the above method will either give you the answer or a non-ellipsoid conic, in which case there''s no single solution. For more than six points you can still use the above method, by calculating the ellipsoid for six of the points at a time. There are two ways to do this:Do it for all sets of six points until you generate an ellipsoid. Given n > 6 points there aren!/(6!(n-6!))sets of six points, so it could take some time to find the right one.Choose six points and find an ellipsoid through them. If there are points outside the ellipsoid swap one of them for one of the six points and try again. This should gradually swallow up points until there are none outside the ellipsoid, though it may depend on how you choose the point outside the ellipsoid, and how you choose which of the six points to swap it with. 