🌻 ریاضیات یا نقاشی طبیعت؟
تا حالا دقت کردید چرا چیدمان دانههای گل آفتابگردان یا انحنای صدف حلزون انقدر چشمنواز و بینقصه؟
رازش در یک عدد جادوییه: نسبت طلایی (Golden Ratio)! ✨
امروز در بخش #فان متلبپلاس، کدی نوشتیم که مارپیچ طلایی و الگوی رشد آفتابگردان رو به زیباییِ هرچهتمامتر رسم میکنه. وقتی این کد رو اجرا میکنید، انگار دارید مستقیماً به «سورسکدِ طبیعت» نگاه میکنید؛ دقیقاً همون الگویی که در خلقت برای چیدمان بهینه و خلق زیبایی بینهایت استفاده میشه.
☕️ کد زیر رو در متلب کپی کنید و از این رقص هندسی و رنگارنگ لذت ببرید. تقدیم به نگاههای زیبای شما 📐
% ==========================================
% The Golden Spiral
% Provided by: MatlabPlus
% Website: https://Matlabplus.com
% ==========================================
clear; clc; close all;
% Set up the canvas
fig = figure('Color', 'k', 'Name', 'Nature Source Code', 'NumberTitle', 'off');
% fig.Position = [300, 150, 700, 700];
axes('Color', 'k', 'XColor', 'none', 'YColor', 'none');
hold on; axis equal;
xlim([-65 65]); ylim([-65 65]);
% Golden ratio and golden angle calculations
n_points = 2000;
phi = (1 + sqrt(5)) / 2;
golden_angle = 2 * pi * (2 - phi);
% Define a beautiful colormap
colors = turbo(n_points);
% Draw the spiral dynamically
scaling_factor = 1.05;
for n = 1:n_points
% Calculate polar coordinates
r = scaling_factor * sqrt(n);
theta = n * golden_angle;
% Convert to Cartesian coordinates
x = r * cos(theta);
y = r * sin(theta);
% Adjust marker size gradually
marker_size = 15 + (n / n_points) * 60;
% Plot current point
scatter(x, y, marker_size, colors(n,:), 'filled', ...
'MarkerEdgeColor', 'w', 'LineWidth', 0.2);
% Create animation effect
if mod(n, 20) == 0
drawnow;
end
end
% Add a glowing title
title('The Golden Ratio in Nature', 'Color', 'w', ...
'FontSize', 18, 'FontWeight', 'bold', 'FontName', 'Arial');
🎥 پیشنهاد: حتماً این کد رو ران کنید، انیمیشنِ رسم شدنش فوقالعاده آرامشبخشه!
#فان #متلب_فان #نسبت_طلایی #فیبوناچی #طبیعت #برنامه_نویسی #متلب
♾️ متلبپلاس
📢 @matlabplus_com20 jul, 12:30
