• Remix
  • Share
  • New Entry

  • michio

  • /
  • Spirograph Pattern: The Rose of Venus

on 19 Nov 2023
  • 13
  • 43
  • 0
  • 0
  • 974
drawframe(1);
Write your drawframe function below
function drawframe(f)
% see https://github.com/minoue-xx/The-Rose-of-Venus/tree/master
rhoE = 1.495;
rhoV = 1.082;
periodE = 365.2; % 364
periodV = 224.7; % 224
dthetaE = 2*pi/periodE;
dthetaV = 2*pi/periodV;
figure
[hE_point, hV_point] = drawOrbits(rhoE, rhoV);
% あとは各 drawnow のタイミングに併せて同じ処理を繰り返してキャプチャした画像を追加していきます。
iie = logspace(1,log10(365*8),43);
iie = [iie, repelem(iie(end),5)];
xEp = [];
yEp = [];
xVp = [];
yVp = [];
for ii=1:iie(f)
thetaE = dthetaE*ii;
[xE,yE] = pol2cart(thetaE,rhoE);
thetaV = dthetaV*ii;
[xV,yV] = pol2cart(thetaV,rhoV);
if ~mod(ii,4)
xEp = [xEp; xE];
xVp = [xVp; xV];
yEp = [yEp; yE];
yVp = [yVp; yV];
end
end
hE_point.XData = xE;
hE_point.YData = yE;
hV_point.XData = xV;
hV_point.YData = yV;
plot([xEp, xVp]',[yEp, yVp]', LineStyle="-", Color=[0.8 0.8 0.8]);
h_obj = get(gca,'Children');
set(gca,'Children',h_obj([end-3:end,1:end-4]));
end
function [hE_point, hV_point] = drawOrbits(rhoE, rhoV)
[xE,yE] = pol2cart(linspace(0,2*pi,100), rhoE);
[xV,yV] = pol2cart(linspace(0,2*pi,100), rhoV);
plot(xE,yE,xV,yV); % 軌道描画
hold on
colors = colororder;
hE_point = plot(rhoE,0,'o',MarkerFaceColor = colors(1,:));
hV_point = plot(rhoV,0,'o',MarkerFaceColor = colors(2,:));
axis off equal
end
Animation
Remix Tree