Surface data cloud fitting to even asphere model

12 ビュー (過去 30 日間)
Cl ES
Cl ES 2022 年 9 月 7 日
コメント済み: Torsten 2022 年 9 月 8 日
I've got a set of (r,z) data which represent a surface section. I would like to fit such data to the Even asphere expression:
Where is the surface sagita, r is the radial coordinate, R is the radius of curvatre at the vertex, κ is the conic constant and are the coefficients describing the deviation of the surface from a pure conic section. Can anyone help to address the problem?
I have calculated the value of R by first fitting the data to a sphere with the code attached below, but I can't find a way to fit the data to the term once R has been calculated. Thank you, your help is very much appreciated!
-----------------------------------------------------------------
Function to fit circle to data set:
function Par = CircleFitting(XY)
centroid = mean(XY); % the centroid of the data set
X = XY(:,1) - centroid(1); % centering data
Y = XY(:,2) - centroid(2); % centering data
Z = X.*X + Y.*Y;
Zmean = mean(Z);
Z0 = (Z-Zmean)/(2*sqrt(Zmean));
ZXY = [Z0 X Y];
[U,S,V]=svd(ZXY,0);
A = V(:,3);
A(1) = A(1)/(2*sqrt(Zmean));
A = [A ; -Zmean*A(1)];
Par = [-(A(2:3))'/A(1)/2+centroid , sqrt(A(2)*A(2)+A(3)*A(3)-4*A(1)*A(4))/abs(A(1))/2];
end

採用された回答

Torsten
Torsten 2022 年 9 月 7 日
% your data
x = ...;
y = ...;
z = ...;
p0 = [...]; % initial guess for R and kappa
p = lsqnonlin(@(p)fun(p,x,y,z),p0)
function res = fun(p,x,y,z)
rho = 1/p(1);
kappa = p(2);
r = sqrt(x.^2+y.^2);
res = z - r.^2*rho./(1+sqrt(1-(1+kappa)*(r*rho).^2));
end
  9 件のコメント
Cl ES
Cl ES 2022 年 9 月 8 日
Hi Trosten,
thank you for your help. I've got a question, though. Why are you squaring the denominator ?
Torsten
Torsten 2022 年 9 月 8 日
So many brackets ... I corrected the code.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with Curve Fitting Toolbox についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by