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

2 次查看(过去 30 天)
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 中查找有关 MATLAB 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by