- /
- 
        Solar Symphony
        on 7 Oct 2024
        
        
 
    - 15
- 313
- 0
- 2
- 1553
 Cite your audio source here (if applicable): 
https://soundcloud.com/nasa/chorus-radio-waves-within-earths-atmosphere?in=nasa/sets/solar-system-beyond-sounds&si=c4fbe17dee9a4bbda687194ab3c04e91&utm_source=clipboard&utm_medium=text&utm_campaign=social_sharing
drawframe(1);
 Write your drawframe function below
function drawframe(f)
    N = 600;
    [X0, Y0] = meshgrid(linspace(-12, 12, N)); 
    t = 2 * pi * f / 96;  % Time variable for orbit and rotation
    % Create Sun with glow
    sun_radius = 0.8; 
    sun_core = sqrt(X0.^2 + Y0.^2) <= sun_radius;  
    sun_glow_radius = 1.5;  
    sun_glow = (sqrt(X0.^2 + Y0.^2) > sun_radius) & (sqrt(X0.^2 + Y0.^2) <= sun_glow_radius);
    img = zeros(N, N, 3);
    sun_color = [1, 0.9, 0];  % Sun color (bright yellow)
    for i = 1:3
        img(:,:,i) = img(:,:,i) + sun_core * sun_color(i);
        img(:,:,i) = img(:,:,i) + sun_glow * sun_color(i) * 0.5;  % Sun glow
    end
    % Planet parameters (position, size, color)
    planets = {
        [0, 0], 0.5, [0, 0.4, 1];   % Earth
        [4, 0], 0.3, [1, 0.2, 0];   % Mars
        [5.5, 0], 0.6, [0.8, 0.5, 0.3]; % Jupiter
        [7, 0], 0.4, [0.6, 0.4, 0.9];   % Saturn
        [8.5, 0], 0.3, [0.5, 0.2, 0];   % Uranus
        [10, 0], 0.3, [0.6, 0.4, 0.3];  % Neptune
        [6.5, 1.5], 0.4, [0.9, 0.8, 0.2]; % Venus
        [4, -1.5], 0.2, [1, 1, 0]; % Mercury
        [9, 3], 0.4, [0.7, 0.7, 0.9]; % Pluto
    };
    % Speeds for orbital rotation and planet axis rotation
    orbit_speeds = [1, 0.5, 0.4, 0.3, 0.6, 0.4, 0.5, 0.7, 0.9]; 
    axis_speeds = [1, 0.8, 0.6, 0.7, 0.4, 0.3, 1, 1, 0.9];
    for j = 1:length(planets)
        % Orbit rotation
        orbit_radius = sqrt(planets{j, 1}(1)^2 + planets{j, 1}(2)^2);
        planet_x = orbit_radius * cos(t * orbit_speeds(j));
        planet_y = orbit_radius * sin(t * orbit_speeds(j));
        % Planet's self-rotation (spin)
        planet_theta = t * axis_speeds(j);
        X_rot = cos(planet_theta) * (X0 - planet_x) - sin(planet_theta) * (Y0 - planet_y);
        Y_rot = sin(planet_theta) * (X0 - planet_x) + cos(planet_theta) * (Y0 - planet_y);
        % Create planet's circular shape
        planet = sqrt(X_rot.^2 + Y_rot.^2) <= planets{j, 2};
        % Add planet's color
        for i = 1:3
            img(:,:,i) = img(:,:,i) + planet * planets{j, 3}(i);
        end
        % Saturn's ring
        if j == 4
            ring_mask = sqrt(X_rot.^2 + Y_rot.^2) <= (planets{j, 2} + 0.3) & sqrt(X_rot.^2 + Y_rot.^2) > planets{j, 2};
            img(:,:,1) = img(:,:,1) + ring_mask * 0.8;  % Ring color (whitish)
        end
    end
    % Starry background with brighter stars
    stars = rand(N, N) < 0.004;  % Increased density for more stars
    for i = 1:3
        img(:,:,i) = img(:,:,i) + stars * 1.0;  % Brighter stars
    end
    % Display the image
    imshow(img, 'InitialMagnification', 'fit');
    axis off;  % Hide axes for clean appearance
end


 

