ADDED FIGURE-8, FIXED BARNES-HUT & VERLET INTEGRATION!!
Log in to leave a comment
ADDED FIGURE-8, FIXED BARNES-HUT & VERLET INTEGRATION!!
Log in to leave a comment
ADDED BARNES-HUT ALGORITHM AND VELOCITY VERLET INTEGRATION!!
⠀
THE PROBLEM:
n² force evaluations per step.O(n²) isnt great, it would lag a lot and would even more on a higher timescale.O(n log n).θ (0.5 in this case), you stop recursively calling and treat the whole cell as a point mass. if its too close, you continue. the approximation error is a great deal under 1% and its O(n log n) from O(n^2). a great deal faster!
Log in to leave a comment
ADDED LAGRANGE POINTS
⠀
What are lagrange points?
The n-body problem asks how N objects move under gravitational forces, but what about a point where an object stays still?
⠀
In the rotating reference frame of a two body system (consider Sun-Earth), there are five points where gravity from both bodies and the centrifugal force (psuedo-force) of the frame all cancel out.
⠀
This simualation visualises these five lagrange points for five systems (Sun-Earth, Earth-Moon, Sun-Jupiter, Sun-Mars, Sun-Venus) and shows a heatmap for effective potential in the background as well. The secondary body is also animated, and orbits around the primary body.
⠀
I learnt a lot building this, like the pseudo forces (centrifugal forces) acting on the frame and how it plays a role in the effective potential calculation (didnt know about this)
⠀
One challenge I faced that took a lot of time to fix, was the potential heatmap not rendering and the canvas zooming in infinitely.
⠀
UPDATED README, REPLACED PLACEHOLDER TEXT, AND FIXED CSS BADGES
⠀
Log in to leave a comment
SOME POLISHING AND CSS CHANGES:
newton() function defined inside solveLP() got redefined on every call, so I moved it out. I also added a condition to avoid singularities.
Log in to leave a comment
ADDED ORBIT ANIMATION, POTENTIAL HEATMAP AND MORE SYSTEMS!!
⠀
EFFECTIVE POTENTIAL HEATMAP:
Ω(x,y) = -½(x² + y²) - (1-μ)/r₁ - μ/r₂). the five Lagrange points, as stated in the prev. devlog, are the saddle points of this field.ImageDAta, pixel by pixel (doing it using shapes takes too long)ADDED LAGRANGE POINTS!!
⠀
WHAT ARE LAGRANGE POINTS?
yet again, im so happy you asked this!
∛(μ/3)), which is the approx radius of the sphere where m2’s gravity is dominating. this allows for a starting point for the iteration to converge.0.5 - μ, ±√3/2). there is no further solving required for these.μ = m₂ / (m₁ + m₂))
Log in to leave a comment
I built Gravitas, an orbital mechanics simulator. it includes two simulations, n-body gravity and hohmann transfer.
⠀
N-BODY SIM.:
the n-body problem is: given N objects that all gravitationally attract each other at the same time, how do they move?
there is no closed form solution for N>=3 bodies, so you have to simulate it step by step. This simulation aims to do this.
⠀
There are two presets, a solar system and a binary stars preset, and using the simulation you can add bodies to these presets and watch them intereact with each other (merge, collide, eject out of threshold)
⠀
HOHMANN TRANSFER CALC. and VISUALISATION:
this is the 2nd sim, a hohmann trasfer is the most efficient way to move a spacecraft b/w two orbits. i tried to simulate this for two modes: planet to planet transfer and satellite transfer. you can read more about this in the devlogs.
NOTES: this took a lot of time and effort, please vote fairly!!
What did i learn?
IMP NOTE!!: if you toggle on track COM for the n-body sim. you will not be able to pan cuz you are tracking the centre of mass.
NOTES: this took a lot of time and effort, please vote fairly!!
SMALL FIXES, FAVICON AND README!! FINAL DEVLOG BEFORE SHIPPING
⠀
Log in to leave a comment
ADDED ANIMATIONSS KEPLER SOLVER AND BADGES!!
⠀
ANIMATIONS:
M = E - e·sin(E)). but you cant solve directly for E so I had to implement Newton-Raphson Iteration.speedMult × (transferDays / 20) so a slow transfer and a fast one would take about the same time real life time (at normal speed). otherwise, earth to mercury wld barely be visible and earth to Neptune would take FOREVER.Log in to leave a comment
SATELLITE MODE!!!!
⠀
PROBLEM: the planet to planet tab works in AU and yrs which is fine for interplanetary transfers but not for satellites cuz then AU doesnt work and you need km. so I added another mode.
⠀
THE FIX:
√(vt² + vc² - 2·vt·vc·cos(Δi)) - vcoffsetWidth on a panel that was just visible, it read zero. requestAnimationFrame delay fixed that.
Log in to leave a comment
HOHMANN TRANSFER!!
⠀
What even is a Hohmann transfer?
THANK GOD YOU ASKED CUZ I HAVE A BUNCH OF UNTRACKED RESEARCH TIME TO SHOWCASE
⠀
√(GM(2/r - 1/a)). it gives you the speed for the object at any point in the orbit. because for a circular orbit r = a, the equation can be simplified to v = √(GM/r).c = ecc * a). so, to account for that we docx - c before drawing the ellipse.⠀classList.toggle('disabled'))Math.random(), so they stop flickering every time the canvas redraws.
Log in to leave a comment
ADDED LANDING PAGE + BUG FIXES!!
⠀
LANDING PAGE:
for now, all the text is just placeholder text, but I plan on changing that right bfr shipping
Log in to leave a comment
CSS UPDATES, BINARY STAR PRESET, VELOCITY VECTORS… AND MORE
⠀
CSS:
Log in to leave a comment
COLLISIONS, SOFTENING, CLICK-TO-ADD BODIES AND TRAILS
⠀
COLLISIONS:
Zero Velocity will fall into the nearest star. so I added Random and Circular Orbit. The default mode, Circular Orbit computes circular orbital velocity at that point, relative to the nearest massive body. Orbit eccentricity can also be adjusted, which leads to more keplerian orbits.Log in to leave a comment
ADDED RK4 INTEGRATION AND CAMERA CONTROLS
getDerivs() temporarily overwrites positions so accel() can be evaluated at intermediate stages, then it restores them. (this took me so long to figure out… the bodies were teleporting because I forgot to restore.)
Log in to leave a comment
WE NOW HAVE 5 BODIES!!! AND THEY MOSTLY OBEY THE LAWS OF PHYSICS!!
Log in to leave a comment
MADE BLUE DOT GO WHEE AROUND YELLOW DOT
set up canvas and render loop now works!!
then added two bodies:
Log in to leave a comment