Learn R Programming

circular (version 0.3-7)

lsfit.circle: Fit a 2D circle to an (x,y) dataset

Description

Fit a 2D circle to an (x,y) dataset using LS.

Usage

lsfit.circle(x, y, init = NULL, units = c("radians", "degrees"), 
template = c("none", "geographics"),
modulo = c("asis", "2pi", "pi"), zero = 0, rotation = c("counter", "clock"), ...)
## S3 method for class 'lsfit.circle':
print(x, digits = max(3, getOption("digits") - 3), ...)

Arguments

x
either a matrix with two columns or a vector.
y
if x is a vector then y must be a vector with the same length.
init
initial values of the parameters. A vector of length 3 with the following components: radius of the circle, x-coordinate of the center, y-coordinate of the center. If NULL the vector is set to c(max(c(abs(x-mean(x)), abs(y-mean(y)
units
the units used in defining the angles between observations and the center of the circle. See circular.
template
the template used in defining the angles between observations and the center of the circle. See circular.
modulo
the modulo used in defining the angles between observations and the center of the circle. See circular.
zero
the zero used in defining the angles between observations and the center of the circle. See circular.
rotation
the rotation used in defining the angles between observations and the center of the circle. See circular.
...
further parameters passed to the optim function.
digits
the number of digits to be printed.

Value

  • An object of class lsfit.circle.
  • coefficientsa vector of length 3 with the estimated radius and coordinate of the center of the fitted circle.
  • xthe x-coordinate.
  • ythe y-coordinate.
  • x.centeredthe x-coordinate re-centered at the center of the circle.
  • y.centeredthe y-coordinate re-centered at the center of the circle.
  • anglesangles of the observations with respect to the center coordinate of class . radius{the distance between the observations and the center coordinate} convergence{value from the function optim.} optim{the output from the function optim.} call{match.call().}
  • Coope, I. (1993). Circle fitting by linear and non-linear least squares. Journal of Optimization Theory and Applications, 76, 381-388. [object Object],[object Object]

    data(coope) res <- lsfit.circle(x=x.coope, y=y.coope) res

    plot(res)

    par(mfcol=c(1,2)) plot(res$angles) hist(res$radius)

    plot(circular(0), type="n", xlim=c(-5.2, 5.2), ylim=c(-5.2, 5.2), xlab="The Radius of the circle is measured from the base line of the axes.") lines(x=res$angles, y=res$radius, join=TRUE, type="b") ff <- function(x) sqrt((res$coefficients[1]*cos(x))^2+(res$coefficients[1]*sin(x))^2) curve.circular(ff, add=TRUE, join=TRUE, nosort=FALSE, col=2)

    windrose(x=res$angles, y=res$radius)

    models

Details

lsfit.circle uses the optim function to minimize the sum of the squared residuals between the observations and the optimally fitting circle.