classdef Circle < handle
% Operations on circles
properties
% A Circle object has a center and a radius.
% The center is a Point object.
center = Point();
r
end

methods
% Construct a Circle object...
function C = Circle(r,P)
% Creates a circle object with radius r and center P
C.r = r;
C.center = P;
end

% Translation...
function A = Translate(ThisCircle,delX,delY)
% A is the circle obtained by translating the center of ThisCircle by
% an amount delX in the x-coordinate and delY in the y-coordinate.
% A call of the form B.Translate(delX,delY) translates the center of Circle B by
% an amount delX in the x-coordinate and delY in the y-coordinate.
if nargout==1
C = ThisCircle.center.Translate(delX,delY);
A = Circle(ThisCircle.r,C);
else
ThisCircle.center.Translate(delX,delY);
end
end

% Distance...
function d = Dist(ThisCircle,P)
% The distance from ThisCircle to Point P
d = abs(P.Dist(ThisCircle.center) - ThisCircle.r);
end

% Display...
function Show(ThisCircle,c)
% Displays the circle ThisCircle.
% The color is specified by the character c.
% Assumes hold is on.
theta = linspace(0,2*pi);
xc = ThisCircle.center.x;
yc = ThisCircle.center.y;
r = ThisCircle.r;
plot(xc+r*cos(theta),yc+r*sin(theta),c)
end
end %methods
end %classdef