- Fit a plane to your data.
- Project your (x,y,z) data on to the plane and write the results in a 2D coordinate system (xp,yp) within that plane.
- Fit an ellipse to the (xp,yp) data.
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
댓글 수: 0
채택된 답변
Matt J
2021년 6월 5일
편집: Matt J
2021년 6월 5일
Basically, the procedure would be to
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
2022년 6월 22일
You might be able to use this to calculate the orientation change:
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개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Fit Postprocessing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!