fitcircle: Fit a Circle to Three Points in the Plane

버전 1.0.0 (429 KB) 작성자: Rob Comer
The fitcircle function fits a circle to exactly three points in the plane, returning the center coordinates and radius.
다운로드 수: 1
업데이트 날짜: 2025/9/17

라이선스 보기

fitcircle is a simple MATLAB function (six executable lines) that fits a circle to (exactly) three points in the plane, (x1, y1), (x2, y2), and (x3, y3), and returns the center (xc, yc) and radius (r) of the circle:
[xc, yc, r] = fitcircle(x1, y1, x2, y2, x3, y3)
Use of mldivide (the \ operator) means that no input validation is needed, other than checking that the inputs are real, finite, and double (using Function Argument Validation).
In the event of collinear or nearly collinear points (including the cases of identical or nearly-identical points), the 2x2 matrix,
A = [x2 - x1, y2 - y1
x3 - x1, y3 - y1],
which is central to the computations, will be singular or nearly singular and a warning will be issued:
"Matrix is singular to working precision"
or
"Matrix is close to singular ...",
In this case, the radius output will equal Inf or NaN, so a call to isfinite will indicate programmatically whether or not A was too ill-conditioned for a solution to be computed. (In most cases like this, the center coordinate outputs will also be nonfinite (Inf, -Inf, or NaN).)
Related Submissions
To fit more than three points (the overdetermined problem), or to fit circles to multiple sets of three points in a single function call, consider:
Circle fit by Izhak Bucher — "Fit a circle to a set of measured x,y points."
Circle Fit (Pratt method) by Nikolai Chernov — "Fits a circle to a set of data points on a plane; returns the circle center (a,b) and radius R"
circfit by Andrew Horchler — "Matlab function for least squares fitting of two-dimensional data to a circle."
Fit circle through 3 points by Danylo Malyuta — "A fault-tolerant function for computing a circle's center and radius given three x-y points"

인용 양식

Rob Comer (2025). fitcircle: Fit a Circle to Three Points in the Plane (https://kr.mathworks.com/matlabcentral/fileexchange/182051-fitcircle-fit-a-circle-to-three-points-in-the-plane), MATLAB Central File Exchange. 검색 날짜: .

MATLAB 릴리스 호환 정보
개발 환경: R2024b
R2019b 이상 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
태그 태그 추가

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
버전 게시됨 릴리스 정보
1.0.0