Circe center coordinates and radius from coordinades ( A, B, C )

조회 수: 5 (최근 30일)
pauli relanderi
pauli relanderi 2021년 12월 9일
답변: David Hill 2021년 12월 9일
my problem is that i need to find circles center and radius from coordinates. (A,B,C)
So from this :
preferibly not with solve, but with "manual" calculations.
If manual is impossible, solve works too.
Hoping someone can help.
Thank you in advance. This is an amazing community.

채택된 답변

David Hill
David Hill 2021년 12월 9일
syms h k r x1 x2 x3 y1 y2 y3
eqn1=(x1-h)^2+(y1-k)^2==r^2;
eqn2=(x2-h)^2+(y2-k)^2==r^2;
eqn3=(x3-h)^2+(y3-k)^2==r^2;
[H,K,R]=solve([eqn1,eqn2,eqn3],[h,k,r]);

추가 답변 (1개)

Image Analyst
Image Analyst 2021년 12월 9일
See the FAQ:
function [xCenter, yCenter, radius, a] = circlefit(x, y)
% circlefit(): Fits a circle through a set of points in the x - y plane.
% USAGE :
% [xCenter, yCenter, radius, a] = circlefit(X, Y)
% The output is the center point (xCenter, yCenter) and the radius of the fitted circle.
% "a" is an optional output vector describing the coefficients in the circle's equation:
% x ^ 2 + y ^ 2 + a(1) * x + a(2) * y + a(3) = 0
% by Bucher Izhak 25 - Oct - 1991
numPoints = numel(x);
xx = x .* x;
yy = y .* y;
xy = x .* y;
A = [sum(x), sum(y), numPoints;
sum(xy), sum(yy), sum(y);
sum(xx), sum(xy), sum(x)];
B = [-sum(xx + yy) ;
-sum(xx .* y + yy .* y);
-sum(xx .* x + xy .* y)];
a = A \ B;
xCenter = -.5 * a(1);
yCenter = -.5 * a(2);
radius = sqrt((a(1) ^ 2 + a(2) ^ 2) / 4 - a(3));
To call
x = [1,4,5];
y = [1,4,2];
[xCenter, yCenter, radius, a] = circlefit(x, y)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by