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

22 次查看(过去 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