title: Fitting an ellipsoid given 2D contours
body: <p>I have coordinates corresponding to a set of 2D contours, each corresponding to different heights. These contours do not draw out a perfect ellipsoid in 3D, and instead what I would like to do is to find the best fitting ellipsoid. I do not have any knowledge on the origin of this ellipsoid.</p>
  <p>My first thought was to incorporate some type of least squares algorithm, where I find the ellipsoid parameters that minimize the distance between points. I imagine this would be quite expensive and not too far from a brute force approach. I am convinced there is a more elegant and efficient way of doing this. If there is an existing library that handles this (preferably in Python) that would be even better.</p>
  <p>I have already seen a related question (<a href="https://stackoverflow.com/questions/7272252/fitting-an-ellipsoid-to-3d-data-points">Fitting an ellipsoid to 3D data points</a>), but figured I would ask again as it has been over a decade since that post.</p>