Home > matGeom > geom2d > isPointInCircle.m

isPointInCircle

PURPOSE ^

ISPOINTINCIRCLE Test if a point is located inside a given circle.

SYNOPSIS ^

function b = isPointInCircle(point, circle, varargin)

DESCRIPTION ^

ISPOINTINCIRCLE Test if a point is located inside a given circle.

   B = isPointInCircle(POINT, CIRCLE) 
   Returns true if point is located inside the circle, i.e. if distance to
   circle center is lower than the circle radius.

   B = isPointInCircle(POINT, CIRCLE, TOL) 
   Specifies the tolerance value

   Example:
   isPointInCircle([1 0], [0 0 1])
   isPointInCircle([0 0], [0 0 1])
   returns true, whereas
   isPointInCircle([1 1], [0 0 1])
   return false

   See also
     circles2d, isPointOnCircle, isPointInEllipse, isPointOnline

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function b = isPointInCircle(point, circle, varargin)
0002 %ISPOINTINCIRCLE Test if a point is located inside a given circle.
0003 %
0004 %   B = isPointInCircle(POINT, CIRCLE)
0005 %   Returns true if point is located inside the circle, i.e. if distance to
0006 %   circle center is lower than the circle radius.
0007 %
0008 %   B = isPointInCircle(POINT, CIRCLE, TOL)
0009 %   Specifies the tolerance value
0010 %
0011 %   Example:
0012 %   isPointInCircle([1 0], [0 0 1])
0013 %   isPointInCircle([0 0], [0 0 1])
0014 %   returns true, whereas
0015 %   isPointInCircle([1 1], [0 0 1])
0016 %   return false
0017 %
0018 %   See also
0019 %     circles2d, isPointOnCircle, isPointInEllipse, isPointOnline
0020 %
0021 
0022 % ------
0023 % Author: David Legland
0024 % E-mail: david.legland@inrae.fr
0025 % Created: 2004-04-07
0026 % Copyright 2004-2024 INRA - TPV URPOI - BIA IMASTE
0027 
0028 % extract computation tolerance
0029 tol = 1e-14;
0030 if ~isempty(varargin)
0031     tol = varargin{1};
0032 end
0033 
0034 d = sqrt(sum(power(point - circle(:,1:2), 2), 2));
0035 b = d-circle(:,3)<=tol;

Generated on Thu 21-Nov-2024 11:30:22 by m2html © 2003-2022