image thumbnail

[xc,yc]=CircCalc(P1​,P2,R)

version 1.2.0.0 (2.35 KB) by Marco
This function calculates a circle by 2 points and a given radius

180 Downloads

Updated 21 Oct 2014

View License

[xc,yc]=CircCalc(P1,P2,R)
calculates a circle in P1,P2 and a given radius.
INPUT: P1 = [ x1 y1 ]
P2 = [ x2 y2 ]
R = value
RESULT: result is center point (yc,xc).

By: Marco Lehmann 21/oct /2014,
*****************************************

Example:
P1 = [1 1];
P2 = [3 6];
R = 10;

[xc,yc]=CircCalc(P1,P2,R)
figure
hold all
plot(P1(1),P1(2),'xg') % Point 1
plot(P2(1),P2(2),'xg') % Point 2
plot(xc(1),yc(1),'xr') % center point 1
plot(xc(2),yc(2),'xb') % center point 1
t=0:.01:2*pi;
plot(R*cos(t)+xc(1),R*sin(t)+yc(1),'r-') % calculated circle 1
plot(R*cos(t)+xc(2),R*sin(t)+yc(2),'b-') % calculated circle 2
hold off
axis equal

Cite As

Marco (2021). [xc,yc]=CircCalc(P1,P2,R) (https://www.mathworks.com/matlabcentral/fileexchange/48207-xc-yc-circcalc-p1-p2-r), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2007a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!