Fitting cone/cylinder of known dimensions to 3D surface data
조회 수: 34 (최근 30일)
이전 댓글 표시
I'm looking to fit a cone/cylinder of known dimensions to 3D surface data.
As a test, I created a cone using the parametric equations and downsample it to get some 3D surface data (see photo).
I need to fit to this data a cone whose dimensions are fixed but its orientation and origin are variable (so total 6 unknowns). These 6 parameters need to be determined (in the least square sense) based on the available data.
What would be the best approach to perform this?
I am using the following but so far have not had good luck with it.
- A function that uses fsolve to get the cone surface from an implicit form of the cone equation given the 6 parameters.
- lsqcurvefit that calls the above function and compares with the 3D data to optimize the 6 parameters.
Thanks!
댓글 수: 5
J. Alex Lee
2021년 6월 11일
I don't think your response on the reasoning for using fsolve makes sense. When you say x, y, z coordinates are related implicitly, i think "minimize the function F(xData,yData,zData), where the surface of the cone is defined as 0=F(x,y,z)". Unless your data points were exactly on the surface, fsolve would fail. Alternatively, if your data points were exactly on the surface a bad/naive minimizer may fail.
채택된 답변
Matt J
2021년 6월 12일
편집: Matt J
2021년 6월 13일
I've recently added a cone-fitting routine to this FIle Exchange package,
I still consider it a beta-version for now, but it's performed well so far in a number of tests. Here is an example of usage,
vertex=[1,2,3].'; %ground truth vertex coordinates
cone_angle=20; %ground truth axis-to-surface angle
yaw=20; pitch=-45; %ground truth yaw/pitch orientation (degrees)
theta=[0:40:200];
h=linspace(5,10,31);
sig=0.01; %noise sigma
xyz = rightcircularconeFit.xyzsim(vertex,cone_angle,[yaw,pitch],...
theta,h,sig); %noisy surface samples
fobj=rightcircularconeFit(xyz), %perform the fit
%Visualize the fit
fobj.plot()
xlabel X; ylabel Y; zlabel Z;
axis vis3d
The results of the fit are,
fobj =
rightcircularconeFit with properties:
vertex: [1.0001 1.9994 2.9979]
cone_angle: 19.9902
height: 10.0113
yaw: 20.0104
pitch: -45.0145
댓글 수: 12
추가 답변 (2개)
Matt J
2021년 6월 14일
If you know where the given surface samples would be located on an unrotated/untranslated version of the cone/cylinder, then the rotation and translation can be calculated using absor (Download).
댓글 수: 0
Matt J
2021년 6월 11일
편집: Matt J
2021년 6월 11일
I am providing a guess that is not too far from the original values.
If so, it sounds like there is an error in your calculation of the objective function and/or of the Jacobian, if you are providing it. One thing you should check is whether if you initialize the iterations with the exact original values, if lsqnonlin recognizes it as a solution, terminating in zero iterations with residuals=0.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Get Started with Curve Fitting Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!