{"id":22452501,"url":"https://github.com/thomasafink/visualization_of_the_solar_system_on_an_interstellar_scale","last_synced_at":"2025-10-09T22:47:12.471Z","repository":{"id":223546079,"uuid":"760685670","full_name":"ThomasAFink/visualization_of_the_solar_system_on_an_interstellar_scale","owner":"ThomasAFink","description":"Visualize the Solar System: A Python script that plots the orbits of the major planets, with a special focus on Pluto and the Kuiper Belt. Utilizing NumPy for calculations and Matplotlib for visualization, this script provides an educational tool to explore the dynamics of our solar system, highlighting Pluto's unique orbit and the vast Kuiper Belt","archived":false,"fork":false,"pushed_at":"2024-11-24T20:39:53.000Z","size":183489,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-08-02T00:45:32.115Z","etag":null,"topics":["alpha-centauri","astro","astronomy","astrophysics","greeks","hildas","installer","kuiper-belt","nasa","oort-cloud","orbit","oumuamua","pluto","proxima-centauri","python","scale","solar","solar-system","system","trojans"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ThomasAFink.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-02-20T18:44:44.000Z","updated_at":"2025-06-30T12:49:30.000Z","dependencies_parsed_at":"2024-02-20T20:31:38.366Z","dependency_job_id":"78b3b73c-1663-45b6-a451-af136c0d7d4d","html_url":"https://github.com/ThomasAFink/visualization_of_the_solar_system_on_an_interstellar_scale","commit_stats":null,"previous_names":["thomasafink/visualization_of_plutos_orbit_and_the_kuiper_belt"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ThomasAFink/visualization_of_the_solar_system_on_an_interstellar_scale","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThomasAFink%2Fvisualization_of_the_solar_system_on_an_interstellar_scale","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThomasAFink%2Fvisualization_of_the_solar_system_on_an_interstellar_scale/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThomasAFink%2Fvisualization_of_the_solar_system_on_an_interstellar_scale/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThomasAFink%2Fvisualization_of_the_solar_system_on_an_interstellar_scale/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ThomasAFink","download_url":"https://codeload.github.com/ThomasAFink/visualization_of_the_solar_system_on_an_interstellar_scale/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThomasAFink%2Fvisualization_of_the_solar_system_on_an_interstellar_scale/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279002115,"owners_count":26083307,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["alpha-centauri","astro","astronomy","astrophysics","greeks","hildas","installer","kuiper-belt","nasa","oort-cloud","orbit","oumuamua","pluto","proxima-centauri","python","scale","solar","solar-system","system","trojans"],"created_at":"2024-12-06T06:11:30.531Z","updated_at":"2025-10-09T22:47:12.465Z","avatar_url":"https://github.com/ThomasAFink.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Visualization of The Solar System on an Interstellar Scale\n\nThis Python script provides a detailed visualization of the orbital paths of the major planets in our solar system, with a special focus on Pluto and its relationship with the Kuiper Belt. Utilizing `numpy` for mathematical calculations and `matplotlib` for plotting, the script generates a comprehensive diagram showing the orbits of the planets, Pluto's elliptical orbit, and the scattered distribution of the Kuiper Belt.\n\nCheckout https://github.com/ThomasAFink/orbital-mechanics where I'm trying to vibe code something even better.\n\n| Inner Solar System With Jupiter | Solar System With Kuiper Belt |\n|---------------|-----------------------------|\n| ![Inner Solar System With Jupiter](https://github.com/ThomasAFink/visualization_of_plutos_orbit_and_the_kuiper_belt/blob/main/output/2d/1_inner_solar_system_with_jupiter.jpg?raw=true) | ![Solar System With Kuiper Belt](https://github.com/ThomasAFink/visualization_of_plutos_orbit_and_the_kuiper_belt/blob/main/output/2d/2_solar_system_with_kuiper_belt.jpg?raw=true) |\n\n| Solar System With Oort Cloud | Solar System with Alpha Centauri |\n|-----------------------------|-----------------------------|\n| ![Solar System With Oort Cloud](https://github.com/ThomasAFink/visualization_of_plutos_orbit_and_the_kuiper_belt/blob/main/output/2d/3_solar_system_with_oort_cloud.jpg?raw=true) | ![Solar System with Alpha Centauri](https://github.com/ThomasAFink/visualization_of_plutos_orbit_and_the_kuiper_belt/blob/main/output/2d/4_solar_system_with_alpha_centauri.jpg?raw=true) |\n\n| Interstellar Neighbors Within 10 Light Years | Interstellar Neighbors Within 25 Light Years |\n|-----------------------------|-----------------------------|\n| ![Interstellar Neighbors Within 10 Light Years](https://github.com/ThomasAFink/visualization_of_plutos_orbit_and_the_kuiper_belt/blob/main/output/2d/5_solar_system_with_nearest_stars_10.jpg?raw=true) | ![Interstellar Neighbors Within 25 Light Years](https://github.com/ThomasAFink/visualization_of_plutos_orbit_and_the_kuiper_belt/blob/main/output/2d/6_solar_system_with_nearest_stars_25.jpg?raw=true) |\n\n\n## Getting Started\n\nTo run this script, you need Python installed on your system along with the `numpy` and `matplotlib` libraries. These dependencies can be installed using pip:\n\n```bash\npip3 install numpy\npip3 install pandas\npip3 install matplotlib\npip3 install mpl_toolkits\n```\n\n\n## Code Explanation\n**Importing Libraries**\n\n```python\nimport re\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport pandas as pd\n```\n\n**Constants Definition**\n\nThese constants define various parameters for the orbits of the major planets, Pluto, and the various asteroid belts. The semi-major axes of the planet orbits and specific parameters related to Pluto's orbit and the Kuiper Belt are set here.\n\n```python\nORBIT_POINTS = 1000\nPLANET_ORBITS = [0.39, 0.72, 1.0, 1.52, 5.2, 9.5, 19.2, 30]\nPLUTO_PERIHELION = 29.7\nPLUTO_APHELION = 49.5\nPLUTO_ECCENTRICITY = 0.25\nPLUTO_SEMI_MAJOR_AXIS = (PLUTO_PERIHELION + PLUTO_APHELION) / 2\nKUIPER_BELT_INNER = 30\nKUIPER_BELT_OUTER = 50\nASTEROID_BELT_INNER = 2.2\nASTEROID_BELT_OUTER = 3.2\nJUPITER_SEMI_MAJOR_AXIS = 5.2\nJUPITER_INCLINATION = 1.3\nJUPITER_ECCENTRICITY = 0.0489\nTROJANS_GREEKS_ANGLE = np.deg2rad(60)\nTROJANS_GREEKS_SPREAD = np.pi / 3\nTROJANS_GREEKS_WIDTH = 0.5\nHILDAS_INNER = ASTEROID_BELT_OUTER+0.25\nHILDAS_OUTER = JUPITER_SEMI_MAJOR_AXIS-0.25\nOORT_CLOUD_INNER = 2000\nOORT_CLOUD_OUTER = 100000\n\nif limit[3] == 'inner_solar_system':\n    ASTEROID_BELT_POINTS = 20000\n    TROJANS_GREEKS_POINTS = 4000\n    HILDAS_POINTS = 4000\n    KUIPER_BELT_POINTS = 10000\n    OORT_CLOUD_POINTS = 50000\n\nelif limit[3] == 'inner_solar_system_with_jupiter':\n    ASTEROID_BELT_POINTS = 10000\n    TROJANS_GREEKS_POINTS = 2000\n    HILDAS_POINTS = 2000\n    KUIPER_BELT_POINTS = 10000\n    OORT_CLOUD_POINTS = 50000\n\nelif limit[3] == 'solar_system_with_kuiper_belt':\n    ASTEROID_BELT_POINTS = 100\n    TROJANS_GREEKS_POINTS = 10\n    HILDAS_POINTS = 100\n    KUIPER_BELT_POINTS = 10000\n    OORT_CLOUD_POINTS = 50000\n\nelif limit[3] == 'solar_system_with_oort_cloud':\n    ASTEROID_BELT_POINTS = 20\n    TROJANS_GREEKS_POINTS = 10\n    HILDAS_POINTS = 10\n    KUIPER_BELT_POINTS = 100\n    OORT_CLOUD_POINTS = 50000\n\nelif limit[3] == 'solar_system_with_alpha_centauri':\n    ASTEROID_BELT_POINTS = 10\n    TROJANS_GREEKS_POINTS = 5\n    HILDAS_POINTS = 5\n    KUIPER_BELT_POINTS = 50\n    OORT_CLOUD_POINTS = 5000  \n\nelif  limit[3] == 'solar_system_with_nearest_stars_10':\n    ASTEROID_BELT_POINTS = 2\n    TROJANS_GREEKS_POINTS = 2\n    HILDAS_POINTS = 2\n    KUIPER_BELT_POINTS = 20\n    OORT_CLOUD_POINTS = 2000\n\nelif  limit[3] == 'solar_system_with_nearest_stars_25':\n    ASTEROID_BELT_POINTS = 1\n    TROJANS_GREEKS_POINTS = 1\n    HILDAS_POINTS = 1\n    KUIPER_BELT_POINTS = 10\n    OORT_CLOUD_POINTS = 1000\n```\n\n**Function to Calculate Ellipse**\n\nThis function calculates the x and y coordinates for points on an ellipse, used to plot Pluto's orbit. It takes the eccentricity and semi-major axis of the ellipse, along with an array of angle values (theta), to compute the coordinates.\n\nEquation 1: Calculates the semi-minor axis (b) of the ellipse based on its semi-major axis (a) and eccentricity (ε). The eccentricity measures the deviation of the ellipse from a perfect circle, with 0 representing a circle. The semi-minor axis is derived using the relationship between the eccentricity and the semi-major axis.\n- ![Equation 1](https://latex.codecogs.com/png.latex?b%20%3D%20a%20%5Csqrt%7B1%20-%20%5Cepsilon%5E2%7D)\n\nEquation 2: Computes the radial distance (r) from the center of the ellipse to a point on its edge, given an angle (theta) from the major axis. This formula adjusts for the ellipse's eccentricity, which influences the radial distance across the ellipse.\n- ![Equation 2](https://latex.codecogs.com/png.latex?r%20%3D%20%5Cfrac%7Ba%281%20-%20%5Cepsilon%5E2%29%7D%7B1%20%2B%20%5Cepsilon%20%5Ccos%28%5Ctheta%29%7D)\n\nEquation 3: Determines the x-coordinate of a point on the ellipse, based on the radial distance (r) and the angle (theta), showing how this distance is projected onto the x-axis.\n- ![Equation 3](https://latex.codecogs.com/png.latex?x%20%3D%20r%20%5Ccos%28%5Ctheta%29)\n\nEquation 4: Calculates the y-coordinate of a point on the ellipse, using the radial distance (r) and the angle (theta), which illustrates the projection of this distance onto the y-axis.\n- ![Equation 4](https://latex.codecogs.com/png.latex?y%20%3D%20r%20%5Csin%28%5Ctheta%29)\n\n\n```python\ndef calculate_ellipse(eccentricity, semi_major_axis, theta):\n    \"\"\"\n    Calculate the x, y coordinates of an ellipse based on eccentricity and semi-major axis.\n    \"\"\"\n    b = semi_major_axis * np.sqrt(1 - eccentricity**2)  # Semi-minor axis\n    r = (semi_major_axis * (1 - eccentricity**2)) / (1 + eccentricity * np.cos(theta))\n    x = r * np.cos(theta)\n    y = r * np.sin(theta)\n    return x, y\n```\n\n**Generating Orbits and Kuiper Belt**\n\nGenerates the coordinates for Pluto's orbit and randomly distributed points within the Kuiper Belt. For Pluto, it calculates an elliptical orbit. For the Kuiper Belt, it generates points within specified radial distances to simulate its scattered disk.\n\n```python\ntheta = np.linspace(0, 2 * np.pi, ORBIT_POINTS)\nx, y = calculate_ellipse(PLUTO_ECCENTRICITY, PLUTO_SEMI_MAJOR_AXIS, theta)\n\nkuiper_belt_r = np.random.uniform(KUIPER_BELT_INNER, KUIPER_BELT_OUTER, KUIPER_BELT_POINTS)\nkuiper_belt_theta = np.random.uniform(0, 2 * np.pi, KUIPER_BELT_POINTS)\nkuiper_belt_x = kuiper_belt_r * np.cos(kuiper_belt_theta)\nkuiper_belt_y = kuiper_belt_r * np.sin(kuiper_belt_theta)\n```\n\n\n**Plotting**\n\n```python\nfig, ax = plt.subplots(figsize=(39, 39))\n```\n\nPlots the Sun at the center of the solar system.\n```python\n# Plot the Sun at the center\nsun = plt.Circle((0, 0), 0.05, color='yellow', fill=True)\nax.add_artist(sun)\n```\n\nLoops through the PLANET_ORBITS array to plot circular orbits for each of the major planets.\n```python\n# Plot the orbits of the major planets\nfor orbit in PLANET_ORBITS:\n    circle = plt.Circle((0, 0), orbit, color='black', fill=False)\n    ax.add_artist(circle)\n```\n\nPlots Pluto's elliptical orbit and scatters points for the Kuiper Belt.\n```python\n# Plot the elliptical orbit of Pluto\nax.plot(x, y, color='blue')\n\n# Mark the perihelion and aphelion of Pluto's orbit\nax.plot(PLUTO_PERIHELION, 0, 'bo')  # Perihelion\nax.plot(-PLUTO_APHELION, 0, 'bo')  # Aphelion\n\n# Scatter the adjusted points for the Kuiper Belt\nax.scatter(kuiper_belt_x, kuiper_belt_y, color='gray', s=5)\n```\n\nAdds annotations for key features such as Pluto's perihelion and aphelion, and labels the Kuiper Belt. It also adjusts the plot's appearance for better visualization.\n```python\n# Annotations and labels with increased font size\nfont_size = 48\nax.annotate('Kuiper Belt', xy=(KUIPER_BELT_OUTER, 0), xytext=(KUIPER_BELT_OUTER+5, 10),\n            arrowprops=dict(facecolor='black', shrink=0.05), fontsize=font_size)\nax.annotate(\"Pluto's aphelion (49.5 AU)\", xy=(-PLUTO_APHELION, 0), xytext=(-PLUTO_APHELION-25, 10),\n            arrowprops=dict(facecolor='black', shrink=0.05), fontsize=font_size)\nax.annotate(\"Pluto's perihelion (29.7 AU)\", xy=(PLUTO_PERIHELION, 0), xytext=(PLUTO_PERIHELION+10, -10),\n            arrowprops=dict(facecolor='black', shrink=0.05), fontsize=font_size)\n```\n\nSaves the generated plot as a high-resolution image for use in presentations, educational materials, or personal study.\n```python\nax.set_xlim([-70, 70])\nax.set_ylim([-70, 70])\nax.set_aspect('equal', 'box')\nax.axis('off')\nplt.title('Relationship of Pluto’s orbit to the Kuiper Belt', fontsize=62)\nplt.savefig(\"orbit.jpg\", dpi=300)\nplt.show()\n```\n\n## 3D Visualization of Pluto's Orbit and the Kuiper Belt\n\nThe following images provide different perspectives on Pluto's orbit and the Kuiper Belt, showcasing the 3D modeling capabilities of `matplotlib`. These images can be generated from various viewing angles to illustrate the complex spatial relationships within this region of our solar system.\n\n| Inner Solar System With Jupiter | Solar System With Kuiper Belt |\n|---------------|-----------------------------|\n| ![Inner Solar System With Jupiter](https://github.com/ThomasAFink/visualization_of_plutos_orbit_and_the_kuiper_belt/blob/main/output/3d/1_inner_solar_system_with_jupiter.jpg?raw=true) | ![Solar System With Kuiper Belt](https://github.com/ThomasAFink/visualization_of_plutos_orbit_and_the_kuiper_belt/blob/main/output/3d/2_solar_system_with_kuiper_belt.jpg?raw=true) |\n\n| Solar System With Oort Cloud | Solar System with Alpha Centauri |\n|-----------------------------|-----------------------------|\n| ![Solar System With Oort Cloud](https://github.com/ThomasAFink/visualization_of_plutos_orbit_and_the_kuiper_belt/blob/main/output/3d/3_solar_system_with_oort_cloud.jpg?raw=true) | ![Solar System with Alpha Centauri](https://github.com/ThomasAFink/visualization_of_plutos_orbit_and_the_kuiper_belt/blob/main/output/3d/4_solar_system_with_alpha_centauri.jpg?raw=true) |\n\n| Interstellar Neighbors Within 10 Light Years | Interstellar Neighbors Within 25 Light Years |\n|-----------------------------|-----------------------------|\n| ![Interstellar Neighbors Within 10 Light Years](https://github.com/ThomasAFink/visualization_of_plutos_orbit_and_the_kuiper_belt/blob/main/output/3d/5_solar_system_with_nearest_stars_10.jpg?raw=true) | ![Interstellar Neighbors Within 25 Light Years](https://github.com/ThomasAFink/visualization_of_plutos_orbit_and_the_kuiper_belt/blob/main/output/3d/6_solar_system_with_nearest_stars_25.jpg?raw=true) |\n\n## Conclusion\nThis script is an educational tool that visualizes the orbits within our solar system, with a focus on Pluto and the Kuiper Belt. It demonstrates the power of numpy and matplotlib in creating complex scientific visualizations. Feel free to modify the constants and functions to explore other celestial mechanics or solar system objects.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthomasafink%2Fvisualization_of_the_solar_system_on_an_interstellar_scale","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthomasafink%2Fvisualization_of_the_solar_system_on_an_interstellar_scale","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthomasafink%2Fvisualization_of_the_solar_system_on_an_interstellar_scale/lists"}