Plot elipses with a foci based on equations to plot flowers

2 Ansichten (letzte 30 Tage)
I am trying to practice with matlab with various equations out there. Does anyone know how to plot this picture (see image below) based on these equations? I have coded the equations (see below picture), but have no idea how to plot it.
I have coded the equations A(k), B(k), C(k), D(k), E(k) but I do not know where to go from here.
Any help would be appreciated.
close all; clc; clear;
sin48 =@(k) sin((48*pi*k)./1000000);
cos48 =@(k) cos((48*pi*k)./1000000);
sin8 =@(k) sin((8*pi*k)./1000000);
cos8 =@(k) cos((8*pi*k)./1000000);
sin24 =@(k) sin((24*pi*k)./1000000);
cos24 =@(k) cos((24*pi*k)./1000000);
sin72 =@(k) sin((72*pi*k)./1000000);
cos72 =@(k) cos((72*pi*k)./1000000);
cos648=@(k) cos((648*pi*k)./1000000);
cos64 =@(k) cos((64*pi*k)./1000000);
Ek = 0.1 + 0.25*sin48(x).^2 + 0.2*cos18(x).^18 *...
(1 + (1/3)*cos24(x).^8 + 0.1*cos24(x)^20) + (1/6)*sin8(x).^16 +...
(8/20)*sin8(x).*(1 - 0.4*cos72(x).^4) + 0.0625*sin(x).^18.*...
sin24(x).^20.*sin72(x).^30 - (0.1*sin24(x).^6 + (1/6)*sin24(x).^30)...
(1-sin8(x));
Dk = (pi/2) + (1686*pi*x/1000000);
Ck = 0.003 + 0.097*cos648(x).^40;
Bk = -cos64(x).*Ek - 0.1*cos64(x);
Ak = 1.2*sin64(x)*Ek;
  2 Kommentare
Sam Chak
Sam Chak am 6 Okt. 2022
Hmm... Didn't you have few examples posted on the last few days?
Can you put the scatter() and colormap(jet) functions in the code?
Ahmed Mohamed Mansoor
Ahmed Mohamed Mansoor am 6 Okt. 2022
Yes. However, there are a few issues. These are ellipses with equations involving imaginary numbers.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Davide Masiello
Davide Masiello am 6 Okt. 2022
The code below does the job drawing the figure, but not the coloring.
I can't run it online (takes too long).
clear,clc
figure(1)
hold on
for k = 1:1000000
plotEllipse(k)
end
function plotEllipse(k)
e = 98/100;
sin48 = sin((48*pi*k)/1000000);
sin8 = sin((8*pi*k)/1000000);
cos8 = cos((8*pi*k)./1000000);
sin24 = sin((24*pi*k)/1000000);
cos24 = cos((24*pi*k)/1000000);
sin72 = sin((72*pi*k)/1000000);
cos72 = cos((72*pi*k)/1000000);
cos648 = cos((648*pi*k)/1000000);
sin64 = sin((64*pi*k)/1000000);
cos64 = cos((64*pi*k)/1000000);
Ek = 0.1 + 0.25*sin48^2 + 0.2*cos8^18 *...
(1 + (1/3)*cos24^8 + 0.1*cos24^20) + (1/6)*sin8^16 +...
(8/20)*sin8*(1 - 0.4*cos72^4) + 0.0625*sin8^18.*...
sin24^20*sin72^30 - (0.1*sin24^6 + (1/6)*sin24^30)*...
(1-sin8);
Dk = (pi/2) + (1686*pi*k/1000000);
Ck = 0.003 + 0.097*cos648^40;
Bk = -cos64*Ek - 0.1*cos64;
Ak = 1.2*sin64*Ek;
F1 = Ak + 1i*Bk + Ck*exp(1i*Dk) ; % Focus 1
F2 = Ak + 1i*Bk - Ck*exp(1i*Dk) ; % Focus 2
centre = mean([F1,F2]); % ellipse centre
angle = atan(abs(imag(F1)-imag(F2))/abs(real(F1)-real(F2))); % angle between ellipse horizontal axis and x-axis
c = sqrt((real(F1)-real(F2))^2+(imag(F1)-imag(F2))^2)/2; % distance from centre to foci
a = c/e; % ellipse horizontal axis
b = a^2-c^2; % ellipse vertical axis
t = linspace(0,2*pi,100); % parametric coordinate
x0 = a*cos(t); % x-coordinates of ellipse if centered with reference axis and horizontal
y0 = b*sin(t); % y-coordinates of ellipse if centered with reference axis and horizontal
x = x0*cos(angle)-y0*sin(angle)+real(centre); % Absolute x-coordinates (rotation+translation)
y = y0*cos(angle)+x0*sin(angle)+imag(centre); % Absolute y-coordinates (rotation+translation)
plot(x,y)
end
  8 Kommentare
Davide Masiello
Davide Masiello am 10 Okt. 2022
Bearbeitet: Davide Masiello am 10 Okt. 2022
@Ahmed Mohamed Mansoor Happy to help, please post the plot if you ever manage to produce it. Also, since you are interested in this cool plots, I suggest you check this out.
Ahmed Mohamed Mansoor
Ahmed Mohamed Mansoor am 10 Okt. 2022
@Davide Masiello The coincidence!!!! I was literally looking at them right now and was just mesmerised at the different plots. There's just so much to learn!!
and yes i'll try to get the plot when possible.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Produkte


Version

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by