{ "cells": [ { "cell_type": "markdown", "id": "2ea5ba74-e2d4-4dda-a1a7-c0342d5d3a95", "metadata": {}, "source": [ "" ] }, { "cell_type": "markdown", "id": "b187b3b9-c362-4110-9d11-bb8fa02e0193", "metadata": {}, "source": [ "![alt text](solar.png \"Title\")" ] }, { "cell_type": "markdown", "id": "fe8034d3-1f0b-43db-a606-1c36bfec9aea", "metadata": {}, "source": [ "Group Name: Solar Opposites\n", "- Aniska Zephrina\n", "- Ronald Mwita\n", "- Donald Zvada\n", "- Peter Adepoju\n", "- Isaiah Aremu" ] }, { "cell_type": "markdown", "id": "03e17233-17b0-48bf-9825-6f0d46800263", "metadata": {}, "source": [ "____________________________________________________________________________________________________________________________________________________________________________________________" ] }, { "cell_type": "markdown", "id": "7a199948-25f8-4107-a287-11d682ec64f2", "metadata": {}, "source": [ "## **Facts and Notes**" ] }, { "cell_type": "markdown", "id": "b2a36f7d-6acb-4893-991a-5cbe32193268", "metadata": {}, "source": [ "________________________________________________________________________________________________________________\n", "\n", "## $\\color{red}{Project \\, idea: \\, Animating \\, the \\, planets \\,orbiting \\, around \\, the \\, Sun}$\n", "________________________________________________________________________________________________________________\n", "\n", "- **About the Planets**: The solar system has eight planets: Mercury, Venus, Earth, Mars, Jupiter, Saturn, Uranus, and Neptune. " ] }, { "cell_type": "markdown", "id": "b27c2988-caea-4293-9336-efa097818461", "metadata": {}, "source": [ "## Work breakdown\n", "___________________\n", "- We wanted to make a working prototype of the solar system orbiting around the sun\n", " -We made use of the following\n", "* Path of each planet is an Ellipse $\\dfrac{x^2}{a^2} + \\dfrac{y^2}{b^2} = 1$ where $a$ and $b$ are\n", " - 'a' represents the semi-major axis (half of the length of the major axis)\n", " - 'b' represents the semi-minor axis (half of the length of the minor axis)\n", "## Animating the Planets obirts\n", "________________________________\n", " - We made use of the Polar Coordinates\n", " - $x = a * cos(\\theta)$\n", " - $y = b * sin(\\theta)$\n", " - These cordinates were used to plot points around the Ellipse hence **Animation of The Planets Movement**\n", "\n" ] }, { "cell_type": "markdown", "id": "c336b086-4dd8-4d41-9455-ca2a16577c00", "metadata": {}, "source": [ "### Comparison of Planetary Characteristics in Our Solar System\n", "\n", "\n", "| Planets | Sizes (in Km) | Size in comparison to the Earth | Distance from the Sun (in million Km) | Revolution of each planet around the Sun |\n", "|----------|----------|----------|----------|----------|\n", "| Mercury | 2,440 km | 1/3 of the Earth | $$57 $$ | $$ 87.97 \\space \\space days $$ |\n", "| Venus | 6,052 km | slightly smaller than Earth | $$108$$ | $$224.70 \\space \\space days $$ |\n", "| Earth | 6,371 km | | $$149$$ | $$365.26 \\space \\space days $$ |\n", "| Mars | 3,390 km | about half the size of Earth | $$228 $$ | $$ 686.98 \\space \\space days $$ |\n", "| Jupiter | 69,911 km | 11x Earth’s size | $$780$$ | $$11.86 \\space \\space years $$ |\n", "| Saturn | 58,232 km | 9x larger than Earth | $$1437$$ | $$ 29.46 \\space \\space years $$ |\n", "| Uranus | 25,362 km | 4x Earth’s size | $$2871$$ | $$ 84.01 \\space \\space years $$ |\n", "| Neptune | 24,622 km | slightly smaller than Uranus | $$4530$$ | $$ 164.79 \\space \\space years $$ |\n", "\n", "\n", "\n", "\n", " **NASA**" ] }, { "cell_type": "code", "execution_count": null, "id": "4626d4a4-7033-4260-a902-2bac7d9d833b", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "id": "784c01ee-a3b1-4c40-875c-917292520f9e", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "id": "8fba912a-fb22-4f37-bfe0-ded4dbeb2873", "metadata": {}, "source": [ "# **Animating the Solar System Orbiting around the Earth Prototype**" ] }, { "cell_type": "markdown", "id": "75fcedd9-07ec-42bf-ae3d-b17c2e69f183", "metadata": {}, "source": [ "________________________________________________________________________________________________________________\n", "________________________________________________________________________________________________________________" ] }, { "cell_type": "code", "execution_count": 21, "id": "6e508922-0336-4eea-add5-5b3aa2857668", "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "Animation with 80 frames" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# Planet data (#name, radius1, radius2, color, size, speed)\n", "planets = [\n", "#####################################################################################################\n", " ('mercury', 0.5, 1, 'grey', 50, 16), \n", " ('venus', 1, 1.5, 'darkgoldenrod', 150, -14), # Negative speed for reverse direction\n", " ('earth', 1.5, 2, 'blue', 150, 12), \n", " ('mars', 2, 2.5, 'red', 80, 10), \n", " ('Jupiter', 3, 3.5, 'palegoldenrod', 650, 8), # List of tuples containing [(#name, radius1, radius2, color, size, speed)]\n", " ('Saturn', 4, 4.5, 'brown', 550, 6), \n", " ('Uranus', 5, 5.5, 'cyan', 250, 4),\n", " ('Neptune', 6, 6.5, 'midnightblue', 200, 2)\n", "#######################################################################################################\n", "]\n", "\n", "frames = 80 # The number of frames that will determine the speed of our animations\n", "system_solar = [] #This is where will will store each of our planets plots\n", "\n", "\n", "for i in range(frames):\n", " frame = point((0, 0), size=800, color='yellow') + text('sun', (0, 0.3), color='green') # Plotting the sun\n", "\n", "######################################################################################################################################################\n", " for name, r1, r2, color, size, speed in planets:\n", " angle = speed * pi * i / frames\n", " x = r2 * cos(angle) # In this chunk of code we are iterating through each of the planets and plot them\n", " y = r1 * sin(angle)\n", " frame += point((x, y), size=size, color=color) + ellipse((0, 0), r2, r1, color= \"#deddda\") + text(name, (x, y + 0.2 + size / 5000), color='black') \n", "########################################################################################################################################################\n", " system_solar.append(frame)\n", "## Here we are animating the solar System \n", "animation = animate(system_solar, xmin=-7, xmax=7, ymin=-7, ymax=7, axes=False, figsize=[12,12],frame=True, title = \"Solar System\" )\n", "animation.show()" ] }, { "cell_type": "code", "execution_count": null, "id": "d73fd2cd-f44a-4c9b-b003-ca348865f46e", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "id": "4dcbd856-1cc3-4fc4-a4d8-54c71373241a", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "id": "0cfce5d7-7f0b-4afc-9d29-c18fb5e9113b", "metadata": {}, "source": [ "# **INTERACT using Number of Frames**" ] }, { "cell_type": "code", "execution_count": 17, "id": "f0f39f52-5c14-4a34-9f35-22701889b4bf", "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "715e46aa71064294b70c7b461ea48e0a", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Interactive function with 1 widget\n", " frames: SelectionSlider(description='frames', options=(1, 25, 49, 73, 97), value=1)" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# title = pretty_print(html(\"

Solar System

\"))\n", "\n", "# Planet data (name, radius1, radius2, color, size, speed)\n", "planets = [\n", " ('mercury', 0.5, 1, 'grey', 50, 16), \n", " ('venus', 1, 1.5, 'darkgoldenrod', 150, -14), # Negative speed for reverse direction\n", " ('earth', 1.5, 2, 'blue', 150, 12), \n", " ('mars', 2, 2.5, 'red', 80, 10)\n", " \n", "]\n", "\n", "\n", "system_solar = []\n", "# @interact\n", "# def _(frames=slider(range(1,101,24))): ### To use this for the interact [part]\n", " # title = pretty_print(html(\"

Solar System

\"))\n", "@interact\n", "def _(frames=slider(range(1,101,24))):\n", " # title = pretty_print(html(\"

Solar System

\"))\n", " for i in range(frames):\n", " frame = point((0, 0), size=800, color='yellow') + text('sun', (0, 0.3), color='green') # Sun\n", " for name, r1, r2, color, size, speed in planets:\n", " angle = speed * pi * i / frames\n", " x = r2 * cos(angle)\n", " y = r1 * sin(angle)\n", " frame += point((x, y), size=size, color=color) + ellipse((0, 0), r2, r1, color= \"#deddda\") + text(name, (x, y + 0.2 + size / 5000), color='black') \n", " system_solar.append(frame)\n", " \n", " animation = animate(system_solar, xmin=-2.7, xmax=2.7, ymin=-2.7, ymax=2.7, axes=False, figsize=[8,8],frame=True, title = \"Solar System\" )\n", " animation.show()" ] }, { "cell_type": "code", "execution_count": null, "id": "52d07e8d-575c-435a-bb2f-9d275a5fa402", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "SageMath 10.4", "language": "sage", "name": "sagemath" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.2" } }, "nbformat": 4, "nbformat_minor": 5 }