File : Details

# ellipfit, circfit

Fitting a circle or an ellipse on 2D given points
Details
Version
1.0
A more recent valid version with binaries for Scilab exists: 2.0
Author
Samuel Gougeon
Maintainer
Samuel Gougeon
Categories
Supported Scilab Version
5.4
Creation Date
October 17, 2011
Description
```            -->ellipfit
function [Xc,Yc,a,b] = ellipfit(Xp,Yp,Po)
Looks for the best circle or ellipse fitting some given 2D data points

ellipfit         : Displays this help
ellipfit circle  : Runs a randomized circle-fitting demo.
ellipfit ellipse : Runs a randomized ellipse-fitting demo.
Some difficult cases may fail (without fine initial params)

[xc, yc, r]    = ellipfit(Xp,Yp [,Po]) :
[xc, yc, a, b] = ellipfit(Xp,Yp [,Po]) :
Xp: Row or column of abscissae of points
Yp: Row or column or ordinates of points (same length than Xp)
xc, yc: Coordinates of the center of the best fitting circle | ellipse
r: Radius of the best fitting circle
a: Horizontal radius of the best fitting ellipse
b: Vertical radius of the best fitting ellipse
Po: Optionnal vector of initial parameters (best guess).
It may have from 1 to 4 elements, in this order:
[xc0 yc0 r0] or [xc0 yc0 a0] or [xc0 yc0 a0 b0]
```
Files (1)
[5.78 kB]
Miscellaneous file
```ellipfit() macro and its utilities. Randomized demos are included (see the
description hereabove)
```
News (0)
Comment from Phil Sv -- December 8, 2013, 02:29:38 PM
`Hi. Is there a more detailed documentation of this function (or the name of this method)?`
Answer from Samuel Gougeon -- December 8, 2013, 05:50:25 PM
```Hello Philip,
ellipfit() is based on datafit(). So you may refer to datafit().
rawCircle() is a utility used to initiate circle raw parameters (first guess),
if they are not provided. It is based on simple geometrical considerations.
Any other detail is in the code..
Hope this help
Samuel
```
Answer from Phil Sv -- December 10, 2013, 11:27:19 AM
```This answer has been deleted.
```
Comment from Phil Sv -- December 10, 2013, 11:28:26 AM
```Thanks for the reply.
The way I understand the role of datafit() in the code is that you used it to find the
radius and center of the circle somehow inferred by each input point, and the final output
of ellipfit() is the mean of all those radii and centers...? (I might be very, very wrong,
sorry..)
What I really wanted to ask was that if ellipfit() produces an algebraic
fit ("minimizes the vertical (y-axis) displacement of a point from the curve (e.g.,
ordinary least squares)" -from wikipedia) or a geometric fit (minimize the orthogonal

distance to the curve (e.g., total least squares))?```