Fit circle through 3 points

버전 1.0.0.0 (3.23 KB) 작성자: Danylo Malyuta
A fault-tolerant function for computing a circle's center and radius given three x-y points
다운로드 수: 2K
업데이트 날짜: 2016/6/14

라이선스 보기

Mathematical background is provided in http://www.regentsprep.org/regents/math/geometry/gcg6/RCir.htm
Input:
ABC is a [3 x 2n] array. Each two columns represent a set of three points which lie a circle. Example: [-1 2;2 5;1 1] represents the set of points (-1,2), (2,5) and (1,1) in Cartesian (x,y) coordinates.
Outputs:
R is a [1 x n] array of circle radii corresponding to each set of three points.
xcyc is an [2 x n] array of of the centers of the circles, where each column is [xc_i;yc_i] where i corresponds to the {A,B,C} set of points in the block [3 x 2i-1:2i] of ABC

Usage example: I want to compute the centers and radius for:
* A circle passing through points (-1,0), (0,1) and (1,0)
* A circle passing through points (-1 0), (0,0) and (0,1)
The code to do this is the following:
>> ABC=[[-1 0;0 1;1 0] [-1 0;0 0;0 1]]

ABC =

-1 0 -1 0
0 1 0 0
1 0 0 1

>> [R,xcyc] = fit_circle_through_3_points(ABC)

R =

1.0000 0.7071

xcyc =

0 -0.5000
0 0.5000

NOTE: the function is fully fault-tolerant, in other words it always outputs a result "that makes the most sense". See the heavily commented function code for details on how the fault-tolerance is achieved.

인용 양식

Danylo Malyuta (2024). Fit circle through 3 points (https://www.mathworks.com/matlabcentral/fileexchange/57668-fit-circle-through-3-points), MATLAB Central File Exchange. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R2016a
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Elementary Math에 대해 자세히 알아보기

Community Treasure Hunt

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

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

Changed title

Updated screenshot and file comments.
Corrected the description