FITCIRCLE3D Fit a 3D circle to a set of points.
[FITTEDCIRCLE, CIRCLENORMAL] = fitCircle3d(PTS)
Example
% points on a 2d circle with noise
nop = randi([5 50],1,1);
radius = randi([5 25],1,1);
points2d = circleToPolygon([0 0 radius], nop);
points2d(1,:) = [];
points2d = points2d + rand(size(points2d));
points2d(:,3)=rand(length(nop),1);
% apply random rotation and translation
[theta, phi] = randomAngle3d;
theta = rad2deg(theta);
phi = rad2deg(phi);
tfm = eulerAnglesToRotation3d(phi, theta, 0);
trans = randi([-250 250],3,1);
tfm(1:3,4)=trans;
points3d = awgn(transformPoint3d(points2d, tfm),1);
% fit 3d circle
[fittedCircle, circleNormal] = fitCircle3d(points3d);
% plot 3d points and 3d circle
figure('Color','w'); hold on; axis equal tight; view(3);
xlabel('X');ylabel('Y');zlabel('Z');
drawPoint3d(points3d)
drawCircle3d(fittedCircle, 'k')
drawVector3d(fittedCircle(1:3), circleNormal*fittedCircle(4))
See also
circle3dOrigin, circle3dPosition, circle3dPoint, intersectPlaneSphere
drawCircle3d, drawCircleArc3d, drawEllipse3d
------
Authors: oqilipo, David Legland
created: 2017-05-09
Package: matgeom