I have data that I would like to fit with an ellipsoid and I am currently fitting it via the following Matlab commands:
xs = pts(:,1);
ys = pts(:,2);
zs = pts(:,3);
A0 = [xs.^2 ys.^2 zs.^2 xs.*ys ys.*zs xs.*zs xs ys zs ones(size(xs))];
B0 = [ones(size(xs))];
A = A0'*A0;
B = A0'*B0;
X = A\B;
but I am going to rewrite this into C++
later. For now, I have X
which are the parameters for the general form of an ellipsoid in 3 space. How do I now turn these parameters into a 3x3
matrix to calculate $$ (x-C)^T \cdot A \cdot (x-C) $$ so that I can efficiently calculate if a point $x$ is inside the ellipsoid centered at $C$? Furthermore, $C$ is not any part of the original calculation of these parameters, so do I need to move xs
, ys
, and zs
to the original before performing the LS fit?