You are browsing as a guest. Sign up (or log in) to start making projects!

1h 53m 15s logged

Project Complete: Evolving the Lagrange Calculator from 1D Math to Interactive Web App

Self-reflection note: I got so incredibly locked into solving the math, debugging the terminal environment, and optimizing the graphics that I completely forgot to frequently upload individual devlogs along the way! So, here is my entire multi-day engineering journey packed into one comprehensive project chronicle.

What started as a raw physics equation in a terminal has been fully built out into an interactive browser dashboard! Here is a detailed look at the complete development journey and the engineering hurdles I cleared to make this simulation engine work:

I began by coding the absolute foundations of orbital mechanics in Python. Using the mass parameters of the Sun ($1.989 \times 10^{30}\text{ kg}$) and Earth ($5.972 \times 10^{24}\text{ kg}$), I derived the system mass ratio ($\mu$) and solved the planetary sphere of influence using the Hill Radius calculation:
r_h = R * (mu / 3) ** (1/3)
This successfully output the exact locations of the collinear L1, L2, and L3 points directly to the terminal console.

Text outputs aren’t enough to see space geometry, so I integrated Matplotlib to map the system visually. Using equilateral triangle geometry ($\cos(60^\circ)$ and $\sin(60^\circ)$ rules), I mapped out the stable L4 and L5 points. I applied a clean light-mode interface canvas and resolved a massive coordinate scaling bug by forcing the aspect ratios to stay square so the markers wouldn’t flatten out or disappear.

Next, I tried to calculate a general relativity-inspired mesh grid that bent toward the star and planet. While the vertical line bowing worked beautifully, I discovered a massive cosmic scaling issue: because the real-world mass gaps and distance parameters are so vast ($150\text{ billion meters}$), the planet’s gravity well was a microscopic dot compared to the star, causing lines to collapse and text to overlap.

The Solution: I pivoted to Dimensionless Units. I locked the Sun at (0,0), the planet orbit path at a clean radius of 10, and allowed all Lagrange coordinates to calculate dynamically relative to that fixed 10-unit visual workspace framework.

To turn this into a true interactive app, I migrated the script over to the Streamlit web framework. I built three reactive sidebar sliders allowing anyone to manipulate the Star Mass, Planet Mass, and Orbit Scale dynamically. The browser app crunches the math live, showing metric cards on the left and re-rendering the vector graphic map instantly on the right.

I wrote a preset engine so users can toggle between real-world balances like Sun-Earth, Sun-Jupiter, and a physics-breaking “Inverse Scenario” where the planet completely out-masses the star!


Codebase and full structural system checklist have been officially deployed and pushed to my public GitHub repository!

**Note: The attached image shows the sun-earth system preset

0
1

Comments 0

No comments yet. Be the first!