From: (Roger Stafford)
Newsgroups: comp.soft-sys.matlab
Subject: Re: curvature and radius of curvature of a plane curve
Message-ID: <>
References: <ef5d840.-1@webcrossing.raydaftYaTP> <>
Organization: -
Lines: 29
Date: Mon, 16 Jul 2007 08:33:42 GMT
X-Trace: 1184574822 (Mon, 16 Jul 2007 01:33:42 PDT)
NNTP-Posting-Date: Mon, 16 Jul 2007 01:33:42 PDT
Xref: comp.soft-sys.matlab:419270

In article
<>, (Roger Stafford) wrote:

> In article <ef5d840.-1@webcrossing.raydaftYaTP>, bird
> <> wrote:
> > I want to calculate the local curvature (or radius of curvature) for
> > a few point on outline on a picture, but how the hell am i suppose to
> > do that ?
  You may find the following method more satisfactory than the previous
one I sent.  Its results are independent of any displacement of the axes'
origin.  Again x and y are your coordinate column vectors.

 mx = mean(x); my = mean(y)
 X = x - mx; Y = y - my; % Get differences from means
 dx2 = mean(X.^2); dy2 = mean(Y.^2); % Get variances
 t = [X,Y]\(X.^2-dx2+Y.^2-dy2)/2; % Solve least mean squares problem
 a0 = t(1); b0 = t(2); % t is the 2 x 1 solution array [a0;b0]
 r = sqrt(dx2+dy2+a0^2+b0^2); % Calculate the radius
 a = a0 + mx; b = b0 + my; % Locate the circle's center
 curv = 1/r; % Get the curvature

  The circle defined by center (a,b) and radius r will yield the least
mean square value for the expression (x-a)^2 + (y-b)^2 - r^2 among all
possible parameters, a, b, and r, over the points in vectors x and y.  The
circle's curvature will be 1/r.

Roger Stafford