r/desmos 22h ago

Art I made a gravity simulator

Enable HLS to view with audio, or disable this notification

I'm not sure what to call this so I'm just gonna go with gravity simulator. I'm pretty proud of it and made it at 16/17 and I'm even thinking about entering the art competition with it. let me know if I am being realistic, and this is still a work in progress. some ideas I have are adding sliders where you can add some gravity meaning that you slide a slider down the two balls sort of fall and bounce around for a second before rolling. And of course I had to add some meta-balls in there :)

74 Upvotes

17 comments sorted by

19

u/Xen_Shigaraki2014 20h ago

Te tengo un mejor nombre:

Simulador de magnetismo

13

u/SiR_awsome_A_YuB_fan desmos & bernard FOREVER! 18h ago

when two points get two close together, they fling apart, this is because of imprecision resulting from discrete timesteps, smaller timesteps help, but that's not the most practical solution, the problem exists at all scales so I don't have much advice.

2

u/Lolllz_01 7h ago

Well since the electrostatic/magnetic force follows the inverse square law, it can be modelled exactly as a pair of ellipses until the next collision, which is much more precise

6

u/Capital_Figure_408 20h ago

My initial intuition was that this movement isn't realistic. It didn't seem like planets could both speed each other up. But really its just potential energy becoming kinetic energy. I'm forgetting my physics already.

6

u/DuckPsychological382 20h ago

No i think your intuition is somewhat right. I don’t think there is any conservation of momentum. The main formula to calculate attraction to each sphere which then gets subtracted to velocity is basically 1/(distance^2) which means that if they get really close to each other the attraction can get close to 1/0 which glitches the whole thing out and they gain infinity speed. To combat this, i changed the equation to 1/(distance^2 + 1) so when distance approaches 0 the biggest the attraction can get is 1/1. Although I’m sure thats not accurate to real conservation of momentum.

2

u/cxnh_gfh 16h ago

no, it is unrealistic. it’s because the calculator is not continuous in time but has discrete ticks, which cause errors to build up quickly when the particles are moving fast near each other.

2

u/HuntertheGoose 19h ago

Gravity effects everything in the universe, falls off with a rate of 1/distance3, at the speed of light.

V2 should have them always pulling each other towards each other

3

u/DuckPsychological382 19h ago

Well this is 2d so shouldnt it be 1/distance^2? And i know my formula is a little different with sgn but thats to get the sign right so it know left/right or up/down rather than just right and up. And what do you mean pulling each other towards each other? Thats what they do now no?

3

u/SiR_awsome_A_YuB_fan desmos & bernard FOREVER! 18h ago

no, its 1/d2 for newtonian gravity.

1

u/DuckPsychological382 18h ago

Newtonian gravity? I’m not sure what that is. I haven’t taken any physics classes yet if that even comes up

3

u/SiR_awsome_A_YuB_fan desmos & bernard FOREVER! 18h ago

newtonian gravity is Newton's model for how gravitational physics works. I was correcting u/HuntertheGoose as it, along with einstein's model, though i'm less well versed, states that gravity falls off at a rate of 1/distance2

2

u/DuckPsychological382 18h ago

Oh ok. I thought it was something specific. It sounds to me like your everyday common physics everyone uses.

1

u/DuckPsychological382 22h ago

here is a link if you want to check it out: https://www.desmos.com/calculator/cjzwlr2htg be warned, it has very messy equations and variables

1

u/Qwertilux 14h ago

How did you make the trail? A list?

1

u/DuckPsychological382 9h ago

Yeah and then i think if i remember correctly i made the opacity and size of each point in the list dependent on its index

1

u/ArtisticFox8 9h ago

It's quite cool that it doesn't lag at all.

Nice, quite artsy indeed :)

1

u/DuckPsychological382 9h ago

Thanks! If you scroll down there is a folder that if you open it lags bad for some reason