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

2 visualizaciones (últimos 30 días)
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.

Respuesta aceptada

David Hill
David Hill el 9 de Dic. de 2021
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]);

Más respuestas (1)

Image Analyst
Image Analyst el 9 de Dic. de 2021
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)

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by