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 --------- author : David Legland INRA - TPV URPOI - BIA IMASTE created the 07/04/2004.
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 0020 % 0021 % --------- 0022 % author : David Legland 0023 % INRA - TPV URPOI - BIA IMASTE 0024 % created the 07/04/2004. 0025 % 0026 0027 % HISTORY 0028 % 22/05/2009 rename to isPointInCircle, add psb to specify tolerance 0029 0030 % extract computation tolerance 0031 tol = 1e-14; 0032 if ~isempty(varargin) 0033 tol = varargin{1}; 0034 end 0035 0036 d = sqrt(sum(power(point - circle(:,1:2), 2), 2)); 0037 b = d-circle(:,3)<=tol; 0038