-
Notifications
You must be signed in to change notification settings - Fork 1
/
roulette1_animate.m
69 lines (62 loc) · 1.46 KB
/
roulette1_animate.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
%
% roulette1_animate.m, (c) Matthew Roughan, 2013
%
% created: Tue Nov 26 2013
% author: Matthew Roughan
% email: [email protected]
%
% ROULETTE1_ANIMATE
% do some animations of roulettes
%
%
%
%
clear;
common;
plotdir = 'Animations/'
suffix = 'gif';
device = '-dgif';
%
% ellipse - undulary animation
%
% define and draw the ellipse
a = 2;
b = 1.5;
parameters = [0, b, a, b];
theta = 0:pi/100:2*pi;
points = ellipse(parameters, theta);
x = points(:,1);
y = points(:,2);
figure(1)
hold off
plot(x, y);
hold on
axis equal
% calculate the exact undulary
[x_undulary,y_undulary] = undulary(a, b, -10:0.1:10);
plot(x_undulary,y_undulary, 'm-');
plot(sqrt(a^2-b^2),b, 'bo', 'linewidth', 5)
% use roulette1 to calculate the roulette
M = [x, y];
f = @(t) ellipse(parameters, t);
F = @(t) ellipsed(parameters, t);
s = 2:2:14;
[u, Md] = roulette1(f, F, [sqrt(a^2-b^2),b], -pi/2, s);
% plot the focus at the points its been rolled to
plot(Md(:,1), Md(:,2), 'go', 'linewidth', 5)
% points_u = ellipse(parameters, u);
% x = points_u(:,1);
% y = points_u(:,2);
% plot(x,y, 'b+')
% draw the rolled ellipse
for i=1:length(s)
[u, Md] = roulette1(f, F, M, -pi/2, s(i));
plot(Md(:,1), Md(:,2), 'r', 'linewidth', 1)
end
% print out the plot
set(gca, 'xlim', [-5 15]);
set(gca, 'ylim', [0 5]);
set(gcf, 'PaperUnits', 'centimeters')
set(gcf, 'PaperPosition', [0 0 40 10])
filename = sprintf('%s/roulette_ellipse%s.%s', plotdir, version, suffix)
print(device, filename);