Fitting cone/cylinder of known dimensions to 3D surface data
37 次查看(过去 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!