ISPOINTONCIRCLE Test if a point is located on a given circle. B = isPointOnCircle(POINT, CIRCLE) return true if point is located on the circle, i.e. if the distance to the circle center equals the radius up to an epsilon value. B = isPointOnCircle(POINT, CIRCLE, TOL) Specifies the tolerance value. Example: isPointOnCircle([1 0], [0 0 1]) returns true, whereas isPointOnCircle([1 1], [0 0 1]) return false See also: circles2d, isPointInCircle --------- author : David Legland INRA - TPV URPOI - BIA IMASTE created the 07/04/2004.
0001 function b = isPointOnCircle(point, circle, varargin) 0002 %ISPOINTONCIRCLE Test if a point is located on a given circle. 0003 % 0004 % B = isPointOnCircle(POINT, CIRCLE) 0005 % return true if point is located on the circle, i.e. if the distance to 0006 % the circle center equals the radius up to an epsilon value. 0007 % 0008 % B = isPointOnCircle(POINT, CIRCLE, TOL) 0009 % Specifies the tolerance value. 0010 % 0011 % Example: 0012 % isPointOnCircle([1 0], [0 0 1]) 0013 % returns true, whereas 0014 % isPointOnCircle([1 1], [0 0 1]) 0015 % return false 0016 % 0017 % See also: 0018 % circles2d, isPointInCircle 0019 % 0020 % --------- 0021 % author : David Legland 0022 % INRA - TPV URPOI - BIA IMASTE 0023 % created the 07/04/2004. 0024 % 0025 0026 % HISTORY 0027 % 22/05/2009 rename to isPointOnCircle, add psb to specify tolerance 0028 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 = abs(d-circle(:,3))<tol; 0036