Home > matGeom > geom2d > circumCircle.m

circumCircle

PURPOSE ^

CIRCUMCIRCLE Circumscribed circle of three points.

SYNOPSIS ^

function varargout = circumCircle(varargin)

DESCRIPTION ^

CIRCUMCIRCLE Circumscribed circle of three points.

   CIRC = circumCircle(TRI)
   CIRC = circumCircle(P1, P2, P3)
   Compute circumcircle of a triangle given by 3 points.

   Example
     T = [10 20; 70 20; 30 70];
     C = circumCircle(T);
     figure; drawPolygon(T, 'linewidth', 2);
     hold on; drawCircle(C);
     axis equal; axis([0 100 0 100]);

   See also
     circles2d, enclosingCircle, circumCenter

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function varargout = circumCircle(varargin)
0002 %CIRCUMCIRCLE Circumscribed circle of three points.
0003 %
0004 %   CIRC = circumCircle(TRI)
0005 %   CIRC = circumCircle(P1, P2, P3)
0006 %   Compute circumcircle of a triangle given by 3 points.
0007 %
0008 %   Example
0009 %     T = [10 20; 70 20; 30 70];
0010 %     C = circumCircle(T);
0011 %     figure; drawPolygon(T, 'linewidth', 2);
0012 %     hold on; drawCircle(C);
0013 %     axis equal; axis([0 100 0 100]);
0014 %
0015 %   See also
0016 %     circles2d, enclosingCircle, circumCenter
0017 %
0018 
0019 % ------
0020 % Author: David Legland
0021 % e-mail: david.legland@inra.fr
0022 % Created: 2011-12-01,    using Matlab 7.9.0.529 (R2009b)
0023 % Copyright 2011 INRA - Cepia Software Platform.
0024 
0025 % extract the three points
0026 [a, b, c] = parseThreePoints(varargin{:});
0027 
0028 % circle center
0029 center = circumCenter(a, b, c);
0030 
0031 % radius
0032 r = distancePoints(center, a);
0033 
0034 % format output
0035 varargout = {[center r]};

Generated on Wed 16-Feb-2022 15:10:47 by m2html © 2003-2019