clear all; close all; clc; clf
clf
syms t
x(t) = 2*sin(t); y(t) = 2*cos(t)+ 6;
fplot(x,y, 'b', 'LineWidth',2)
axis([-15 15 -15 15])
hold on
grid on
x(t) = sin(t);
y(t) = cos(t);
fplot(x/5+.6,y/5+6.5, 'g', 'LineWidth',2)
fplot(x/5-.6,y/5+6.5, 'g', 'LineWidth',2)
fplot(x,y+5.5, [pi/2 3*pi/2], 'r', 'LineWidth',2)
fplot(sym(0),t,[1 4], 'b', 'LineWidth',2)
fplot(t,t-6,[-2 0], 'b', 'LineWidth',2)
fplot(-t,t-6,[-2 0], 'b', 'LineWidth',2)
fplot(sym(0),t,[-6 -3], 'b', 'LineWidth',2)
x(t) = t-1;
y1(t) = 8*t+8;
y2(t) = -8*t+8;
fplot(t,sym(8),[-2 2], 'b', 'LineWidth',2)
fplot(x,y1,[0 .5], 'b', 'LineWidth',2)
fplot(-x,y2,[-.5 0], 'b', 'LineWidth',2)
fplot(t,y1(.5),[-.5 1.5], 'b', 'LineWidth',2)
syms t
x(t) = 2*sin(t); y(t) = 2*cos(t) - 1;
x(t) = sin(t);
y(t) = cos(t);
hold off
r=linspace(2,3,60);
for i = 1:size(r,2)
hold on
circles(0,-1,r(i),'facecolor','blue')
h1=fplot(t,-t+r(i)-r(1),[-2 -1], 'b', 'LineWidth',2);
h2=fplot(t,t+r(i)-r(1),[1 2], 'b', 'LineWidth',2);
Zach(i,size(r,2)) = getframe;
if i < size(r,2)
delete(h1), delete(h2)
else
end
end
movie(Zach,1,60)
function [ h ] = circles(x,y,r,varargin)
assert(isnumeric(x),'Input x must be numeric.')
assert(isnumeric(y),'Input y must be numeric.')
assert(isnumeric(r),'Input r must be numeric.')
if ~isscalar(x) && ~isscalar(y)
assert(numel(x)==numel(y),'If neither x nor y is a scalar, their dimensions must match.')
end
if ~isscalar(x) && ~isscalar(r)
assert(numel(x)==numel(r),'If neither x nor r is a scalar, their dimensions must match.')
end
if ~isscalar(r) && ~isscalar(y)
assert(numel(r)==numel(y),'If neither y nor r is a scalar, their dimensions must match.')
end
tmp = strcmpi(varargin,'points')|strcmpi(varargin,'NOP')|strcmpi(varargin,'corners')|...
strncmpi(varargin,'vert',4);
if any(tmp)
NOP = varargin{find(tmp)+1};
tmp(find(tmp)+1)=1;
varargin = varargin(~tmp);
else
NOP = 1000;
end
tmp = strncmpi(varargin,'rot',3);
if any(tmp)
rotation = varargin{find(tmp)+1};
assert(isnumeric(rotation)==1,'Rotation must be numeric.')
rotation = rotation*pi/180;
tmp(find(tmp)+1)=1;
varargin = varargin(~tmp);
else
rotation = 0;
end
tmp = strcmpi(varargin,'color');
if any(tmp)
varargin{tmp} = 'facecolor';
end
x = x(:);
y = y(:);
r = r(:);
rotation = rotation(:);
numcircles = max([length(x) length(y) length(r) length(rotation)]);
if length(x)<numcircles
x(1:numcircles) = x;
end
if length(y)<numcircles
y(1:numcircles) = y;
end
if length(r)<numcircles
r(1:numcircles) = r;
end
if length(rotation)<numcircles
rotation(1:numcircles) = rotation;
end
t = 2*pi/NOP*(1:NOP);
holdState = ishold;
hold on;
h = NaN(size(x));
for n = 1:numcircles
h(n) = fill(x(n)+r(n).*cos(t+rotation(n)), y(n)+r(n).*sin(t+rotation(n)),'',varargin{:});
end
if ~holdState
hold off
end
if nargout==0
clear h
end
end