Skip to main content

🌌 Astronomy Plugin for Manim

Logo

✨ A Manim Extension for Creating Astronomical Visualizations

⚠️ Currently in Development: This plugin is a work in progress. Features and functionality may change as we refine the project!


⚠️ Disclaimer

This plugin is not a scientific simulation tool and may not depict accurate physics or astronomical phenomena. It is designed for visualization purposes only. For accurate astronomical simulations, consider using specialized tools!

Features

  • 🪐 Elliptical Orbits: Visualize planetary orbits with elliptical paths.
  • 🌟 Celestial Bodies: Create and animate stars, planets, moons, and more in a 3D space.
  • ☀️ Solar System Models: Build solar system representations .
  • 🕳️ Space-Time Grids: Visualize the concept of spacetime curvature using space-time grids.

Installation

pip install manim-Astronomy

Usage

Here's a quick example of how to use the plugin to create an animation of a planet orbiting a star:

from manim import *
from manim_Astronomy.stellar_objects import Planet,Star

config.renderer = "opengl"

class KeplersSecondLaw(ThreeDScene):
    def construct(self):
        star = Star(radius=1, size_of_particle=0.001, colors=[YELLOW])
        self.add(star)
        planet = Planet(center=[1, 0, 0], radius=0.05)
        self.add(planet)
        a = 4  
        b = 6 
        orbit = ParametricFunction(
            lambda t: np.array([a * np.cos(t), b * np.sin(t), 0]),
            t_range=[0, TAU],
            color=BLUE
        )
        self.add(orbit)
        last_pos = [orbit.point_from_proportion(1)]

        def trace(mob):
            curr_pos = mob.get_center()  
            self.add(Line3D(last_pos[0], curr_pos, color=BLUE))  
            last_pos[0] = curr_pos 

        time_tracker = ValueTracker(0)
        planet.add_updater(lambda mob: mob.move_to(orbit.point_from_proportion(time_tracker.get_value())))
        
        def get_swept_sector(start, end, close_factor=0.1):
            num_points = 50  
            start = np.clip(start, 0, 1)
            end = np.clip(end, 0, 1)
            points = [orbit.point_from_proportion(start)]
            for alpha in np.linspace(start, end, num_points):
                points.append(orbit.point_from_proportion(alpha))
            last_point = orbit.point_from_proportion(end)
            closing_point = last_point * close_factor 
            points.append(closing_point)  
            return Polygon(*points, fill_opacity=0.3, color=YELLOW)

        
        sweep_intervals = [(0.1, 0.2), (0.4, 0.5), (0.7, 0.8)]
        cumulative_sweep = VGroup()
        
        def update_swept_area():
            current_time = time_tracker.get_value()
            for start, end in sweep_intervals:
                if start <= current_time <= end:
                    new_swept_area = get_swept_sector(start, current_time)
                    cumulative_sweep.add(new_swept_area)  
            return cumulative_sweep  

        sweep_area = always_redraw(lambda: update_swept_area())
        self.add(sweep_area)
        self.move_camera(phi=70 * DEGREES, theta=-90 * DEGREES)
        planet.add_updater(trace)
        self.play(time_tracker.animate.set_value(1), run_time=5, rate_func=linear)
        self.wait(5)

Rendered Scene

📚 Documentation

For detailed documentation, please visit: Documentation Link

Main Components

  • Planet: Create spherical objects representing planets.
  • Star: Create a Star using particles.
  • SpaceTimeFabric: A grid-like representation of space-time, often used to demonstrate the concept of gravitational curvature.

Contributing

We welcome contributions! Please submit issues or pull requests to help improve the plugin. Make sure to follow our contribution guidelines for code style and testing. 🤝

License

This project is licensed under the MIT License - see the LICENSE file for details. 📜

Credits

Developed by Hassam ul Haq. Special thanks to the Manim Community for making this project possible! 🌟

Release files for manim-Astronomy 0.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for manim-Astronomy 0.0.5
File Size Uploaded
manim_astronomy-0.0.5.tar.gz 1.3 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for manim-Astronomy 0.0.5
File Interpreter ABI Platform
manim_astronomy-0.0.5-py3-none-any.whl Python 3 none any Details

Total release size: 2.7 MB

Release files / manim_astronomy-0.0.5.tar.gz

Download URL manim_astronomy-0.0.5.tar.gz
Size 1.3 MB
Tags Source
SHA-256 checksum
How to use checksums
7011b254e5851a1f328314c05ef9b1cb936027baf98d91a6560b3e3e7b3052f6
BLAKE2b-256 checksum
How to use checksums
f50513c3428c716c9467b21f0ee875240652c2ef7625f088d05a6d5917bb15eb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.1

Release files / manim_astronomy-0.0.5-py3-none-any.whl

Download URL manim_astronomy-0.0.5-py3-none-any.whl
Size 1.3 MB
Tags Python 3
SHA-256 checksum
How to use checksums
740238e30be5bf08b4d206de1c7745ffcb05d1711c5f0bec79106c29e123eff9
BLAKE2b-256 checksum
How to use checksums
9afafc7f10dc7129ea36405443be085458a8c1b06172fafbb54358ca987e171d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.1

Release history Release notifications | RSS feed

This release

0.0.5 This release

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page