FITELLIPSE3D Fit an ellipse to a set of points.
FITTEDELLIPSE3D = fitEllipse3d(POINTS) returns the 3D ellipse fitted to
a set of 3D points.
Example
% Create 2D ellipse
n=randi([10,100]);
a=randi([30,50]); b=randi([5,25]);
[x, y] = ellipseToPolygon([0 0 a b 0 ], n);
% 3D and add some noise
points = [x, y, zeros(n,1)];
points=points+(-1+2*rand(n,3));
% Create a random transformation
center=-100+200*rand(1,3);
phi=randi([-180,180]); theta=randi([-180,180]); psi=randi([-180,180]);
TFM=eulerAnglesToRotation3d(phi, theta, psi, 'ZYZ'); TFM(1:3,4)=center';
points = transformPoint3d(points, TFM);
% Fit ellipse
[fE, fTFM] = fitEllipse3d(points, 'vis', true);
% Plot reconstructed ellipse
[fx, fy] = ellipseToPolygon([0 0 fE(4), fE(5) 0 ], n);
fpoints = transformPoint3d([fx, fy, zeros(n,1)], fTFM);
drawEllipse3d(fE,'k')
See also
drawEllipse3d, ellipseToPolygon
Source
Nested functions are part of the quadfit toolbox by Levente Hunyadi
https://mathworks.com/matlabcentral/fileexchange/45356
---------
Author: oqilipo
Created: 2017-08-11
Copyright 2017
Package: matgeom