I have an orbit sim but my math is off by a bit… idk where or why so I need help.

Link:

My math:

Can you type the original equation / expression? There are a few letters I can’t read out. (You can use x^2 for x squared) btw you can also tag @CodeHelp

To calculate gravitational force, you can use this formula:

To simplify this, you can break it into X and Y velocity (you could also replace ”𝒎1𝒎2” with another value)

And the same for Y.

That’s basically all you need.

I have no idea how to help, really. But I am pretty sure COAN knows this kind of stuff, and if he can’t help you for some reason, try to ask @ThinBuffalo.

@Awesome_E, this is the equation I’m using for both x and y

https://discourse-cdn-sjc1.com/gethopscotch/uploads/default/original/3X/d/8/d83dc87af758dfdb0c207bd04fd3d5eeac3edf1c.jpeg

Distance should be distance^2

The code is actually working, but there are a couple of things you may want to change.

First of all, you could cut down a lot on the amount of variables.

- Where you calculate the ”radius”, you could change it to √((self x - sun x)
^{2}+ (self y - sun y)^{2}) instead of doing the subtraction separately. - Remove -x and -y. They aren’t used anywhere.

Second, you should give the planet an initial velocity, otherwise it will shoot straight for the sun with that slingshot effect.