forked from higham/matlab-guide-3ed
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrosy.m
More file actions
26 lines (21 loc) · 668 Bytes
/
rosy.m
File metadata and controls
26 lines (21 loc) · 668 Bytes
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
function rosy(a, b)
%ROSY "Rose" figures.
% ROSY(a, b) plots the curve
% x = r*cos(a*theta), y = r*sin(a*theta), where
% r = sin(a*b*theta) and 0 <= theta <= 2*pi (360 values).
% Suggestions: ROSY(97, 5); ROSY(43, 4); ROSY(79, n9), n a digit.
% P. M. Maurer, A rose is a rose..., Amer. Math. Monthly, 94 (1987),
% pp. 631-645.
if nargin < 2, b = 1; end
if nargin < 1, a = 1; end
c = 0; d = 1; p = a*b;
[x, y] = spiro(a, a, c, d, p, .5);
plot(x,y)
axis square, axis off
% Local function.
function [x, y] = spiro(a, b, c, d, p, k)
h = k*2*pi/180;
t = (0:h:2*pi)';
r = c + d*sin(t*p);
x = r.*cos(a*t);
y = r.*sin(b*t);