How can I fit an ellipse in 3D space to find it's center coordinates in (x,y,z)?

조회 수: 23 (최근 30일)
Input data and ellipse graph in attachments

채택된 답변

Matt J
Matt J 2021년 6월 5일
편집: Matt J 2021년 6월 5일
Basically, the procedure would be to
  1. Fit a plane to your data.
  2. Project your (x,y,z) data on to the plane and write the results in a 2D coordinate system (xp,yp) within that plane.
  3. Fit an ellipse to the (xp,yp) data.
You can do so using the tools in this File Exchange package,
load XYZ;
XYZ=[x,y,z].';
pfit=planarFit(XYZ);
%%% Project onto plane
B=null(pfit.normal).';
b0=(pfit.normal*pfit.distance).';
xpyp=B*(XYZ-b0); %2xN matrix of (xp,yp) coordinates
efit=ellipticalFit(xpyp);
center3D=B.'*efit.center(:)+b0; %3D center coordinates
xcenter=center3D(1),
ycenter=center3D(2),
zcenter=center3D(3),
This results in,
xcenter =
3.2233e+04
ycenter =
-188.3309
zcenter =
573.7545
  댓글 수: 6
Matt J
Matt J 2022년 10월 25일
편집: Matt J 2022년 10월 25일
I've added some methods to the planarFit class to help with the steps in my original answer. The code can now be shortened to,
load XYZ;
XYZ=[x,y,z].';
pfit=planarFit(XYZ);
xpyp=pfit.project2D(XYZ); %2xN matrix of (xp,yp) coordinates
efit=ellipticalFit(xpyp); %elliptical fit
center3D=pfit.unproject3D(efit.center(:)); %map center back to 3D

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Image Analyst
Image Analyst 2021년 6월 5일
I have a demo that you could probably adapt. It's attached.

카테고리

Help CenterFile Exchange에서 Fit Postprocessing에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by