Skip to main content

A Manim extension for creating astronomical visualizations

Project description

🌌 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! 🌟

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

manim_astronomy-0.0.4.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

manim_astronomy-0.0.4-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file manim_astronomy-0.0.4.tar.gz.

File metadata

  • Download URL: manim_astronomy-0.0.4.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.1

File hashes

Hashes for manim_astronomy-0.0.4.tar.gz
Algorithm Hash digest
SHA256 5a1acd0abb7088b485bbf30a224096a997ae0491d9f93b390db07e2e4dae5111
MD5 1b66b8d28c61160544bb87a4b15581e2
BLAKE2b-256 cf4c3ccffd4fee30d9e1693f079c25ac7251fad37a7ade100d9e96f246c9a908

See more details on using hashes here.

File details

Details for the file manim_astronomy-0.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for manim_astronomy-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 35becbd0210dfed070e8a1021a4a3879db13470ad0d6d299f34f558f48952bb3
MD5 f878f2b70169e1bcb9f37ff01333aac1
BLAKE2b-256 d34d1c00d1634e544cd652da63b7501e5c40dd3297875c1661881e38c095f36f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page