如何从离散样本计算曲率半径? [英] How do I calculate radius of curvature from discrete samples?
问题描述
我从平面曲线中获得了一系列 (x,y) 样本,这些样本取自实际测量值,因此可能有点嘈杂且时间间隔不均匀.
x = -2.51509 -2.38485 -1.88485 -1.38485 -0.88485 -0.38485 0.11515 0.61515 1.11515 1.61515 ...y = -48.902 -48.917 -48.955 -48.981 -49.001 -49.014 -49.015 -49.010 -49.001 -48.974 ...
如果我绘制整个系列,它看起来像一个漂亮的椭圆形,但如果我仔细观察,这条线看起来有点摇摆不定,这可能是噪音.
我将如何提取基础椭圆曲率半径的估计值?
任何编程语言都可以!
Roger Stafford 在这里给出了一些 MATLAB 代码:
http://www.mathworks.com/matlabcentral/newsreader/view_thread/152405
为了实现这个功能,我有点冗长:
#给定一个负载点,用x,y坐标,我们可以估计半径# 通过使用最小二乘法将圆拟合到它们的曲率.函数 [r,a,b]=radiusofcurv(x,y)# 将点转换为质心坐标mx = 平均值(x);我的 = 平均值(y);X = x - mx;Y = y - 我的;dx2 = 平均值(X.^2);dy2 = 平均值(Y.^2);# 建立线性方程求导并求解RHS=(X.^2-dx2+Y.^2-dy2)/2;M=[X,Y];t = M\RHS;# t 是圆的中心 [a0;b0]a0 = t(1);b0 = t(2);# 从中我们可以得到半径r = sqrt(dx2+dy2+a0^2+b0^2);# 返回给定坐标系a = a0 + mx;b = b0 + 我的;端功能
它似乎对我的目的很有效,尽管它给出了非常奇怪的答案,例如共线点.但是,如果它们来自一个不错的曲线并增加了一点噪音,那么工作就大功告成了.
它应该很容易适应其他语言,但请注意,\ 是 MATLAB/Octave 的使用伪逆求解"函数,因此您需要一个可以计算伪逆的线性代数库来复制它.>
I've got a series of (x,y) samples from a plane curve, taken from real measurements, so presumably a bit noisy and not evenly spaced in time.
x = -2.51509 -2.38485 -1.88485 -1.38485 -0.88485 -0.38485 0.11515 0.61515 1.11515 1.61515 ...
y = -48.902 -48.917 -48.955 -48.981 -49.001 -49.014 -49.015 -49.010 -49.001 -48.974 ...
If I plot the whole series, it looks like a nice oval, but if I look closely, the line looks a bit wiggly, which is presumably the noise.
How would I go about extracting an estimate of the radius of curvature of the underlying oval?
Any programming language would be fine!
Roger Stafford gave some MATLAB code here:
http://www.mathworks.com/matlabcentral/newsreader/view_thread/152405
Which I verbosed a bit to make this function:
# given a load of points, with x,y coordinates, we can estimate the radius
# of curvature by fitting a circle to them using least squares.
function [r,a,b]=radiusofcurv(x,y)
# translate the points to the centre of mass coordinates
mx = mean(x);
my = mean(y);
X = x - mx; Y = y - my;
dx2 = mean(X.^2);
dy2 = mean(Y.^2);
# Set up linear equation for derivative and solve
RHS=(X.^2-dx2+Y.^2-dy2)/2;
M=[X,Y];
t = M\RHS;
# t is the centre of the circle [a0;b0]
a0 = t(1); b0 = t(2);
# from which we can get the radius
r = sqrt(dx2+dy2+a0^2+b0^2);
# return to given coordinate system
a = a0 + mx;
b = b0 + my;
endfunction
It seems to work quite well for my purposes, although it gives very strange answers for e.g. collinear points. But if they're from a nice curve with a bit of noise added, job pretty much done.
It should adapt pretty easily to other languages, but note that \ is MATLAB/Octave's 'solve using pseudo-inverse' function, so you'll need a linear algebra library that can calculate the pseudo inverse to replicate it.
这篇关于如何从离散样本计算曲率半径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!