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

8 ビュー (過去 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 Center および File ExchangeMATLAB についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by