Hello,

You can use the function "circlefit" from "pracma". The example is adapted
from the help page to fit your data.

#-----------------------------------------------------------------------------------------------
require(pracma)

xp <- c(113, 143, 184, 229, 290, 342, 393, 456, 540, 618)
yp <- c(392, 389, 386, 383, 379, 380, 380, 380, 383, 388)

rslt <- circlefit(xp, yp)
x0 <- rslt[1]; y0 <- rslt[2]; r0 <- rslt[3]

plot(c(100, 650), c(370, 400), type="n")
grid()
abline(h=0, col="gray"); abline(v=0, col="gray")
points(xp, yp, col="darkred")

w  <- seq(0, 2*pi, len=1000)
xx <- r0 * cos(w) + x0
yy <- r0 * sin(w) + y0
lines(xx, yy, col="blue")
#-----------------------------------------------------------------------------------------------


Hope this helps,
Pascal




2013/9/19 Tom D. Harray <tomdharray@gmail.com>

> Hi there,
>
> I want to know the radius of curvature for a set of points, but cannot
> figure out how to perform the fit in R.
>
> I have a set of points P_i for which I want to calculate the radius of
> curvature. The coordinates (x_i|y_i) of the points in a data.frame:
>
> p <- data.frame(
>     x = c(113, 143, 184, 229, 290, 342, 393, 456, 540, 618),
>     y = c(392, 389, 386, 383, 379, 380, 380, 380, 383, 388)
>     )
>
> For the radius of curvature I now have to find the circle the which
> describes best my points. This circle has an origin at r_x and r_y,
> and the radius r. The equation I started with is:
>
>    r^2 = (r_x - x_i)^2 + (r_y + y_i)^2
>
> r^2, r_x, and r_y are constant. Expanding the quadratic terms and
> subtracting r^2 leads to
>
>    0 = x_i^2 + (-2*r_x)*x_i  +  y_i^2 + (-2*r_y)*y_i  + r_x^2 + r_y^2 - r^2
>
> The last three terms add up to zero due to r^2 = r_x^2 + r_y^2:
>
>    0 = x_i^2 + (-2*r_x)*x_i  +  y_i^2 + (-2*r_y)*y_i
>
> Here I got stuck. I -- as a non-mathematician -- would describe it as
> quadratic equation in two dimensions, but I didn't succeed searching
> for these terms in the help, mailing list, and web.
>
> My question is: How to estimate the r_x, and r_y from the set of
> points p using R?
>
>
> Thanks and regards,
>
> Dirk
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Pascal Oettli
Project Scientist
JAMSTEC
Yokohama, Japan

	[[alternative HTML version deleted]]

