Orbital Path
Posted: Tue Oct 20, 2015 12:54 am
Insipired by Kerbal Space Program's map I'm trying to plot the orbit of an moving object subjected to the gravitational force. As you can see in the scene (attachment), the orbit is pretty much accurate, i'm using this equation to represent the orbit and I'm getting all the necessary data through the readable [x,y] and vel converting then to polar coordinates.
I've been having some problems with the mass, when I started the Algodoo again the mass value would've changed and that's why I've defined it, but it shouldn't be like this.
My main issue with the scene is on the axis of the conic. As you can see, when the object gets near the apoapsis or periapsis of the ellipsis, the predicted orbit wobbles. I've been monitoring the numbers and I think the problem is here:
Specially with the
We know the arccos(x) function only accepts -1 < x < 1, I saw that this ((p / radius) - 1) / ecc was getting values > 1 or < -1 near those two spots, so I limited it with the correct_magnitude(x) function to not bug the scene and see what's happening. Why it is getting those values? Floating point error? I was suspecting about how I calculate the p or the ecc. First the ecc varies in some range but it was supposed to be constant, but by manually inserting the eccentricity value the wobble didn't disapear. As p is somewhat constant, i've changed its value, but the problem with it is that though it removes the wobble, it makes the orbit not to represent the real orbit. So now I have no clues anymore...Any help from these thyme guys over here?
Sorry if I've misspell something.
Edit: I also would like to tell you that my main goal is have multiple objects (Earth and Moon, for example) and make it like a game. I believe I have two ways of doing it, analitically with Patched Conic Approximation(just like KSP) or numerically by solving x and y ODE, but this is a future project...
Spoiler: show
I've been having some problems with the mass, when I started the Algodoo again the mass value would've changed and that's why I've defined it, but it shouldn't be like this.
My main issue with the scene is on the axis of the conic. As you can see, when the object gets near the apoapsis or periapsis of the ellipsis, the predicted orbit wobbles. I've been monitoring the numbers and I think the problem is here:
- Code: Select all
parameter := correct_sgn(k, 0) * math.acos(correct_magnitude(((p / radius) - 1) / ecc));
Specially with the
- Code: Select all
correct_magnitude(((p / radius) - 1) / ecc)
We know the arccos(x) function only accepts -1 < x < 1, I saw that this ((p / radius) - 1) / ecc was getting values > 1 or < -1 near those two spots, so I limited it with the correct_magnitude(x) function to not bug the scene and see what's happening. Why it is getting those values? Floating point error? I was suspecting about how I calculate the p or the ecc. First the ecc varies in some range but it was supposed to be constant, but by manually inserting the eccentricity value the wobble didn't disapear. As p is somewhat constant, i've changed its value, but the problem with it is that though it removes the wobble, it makes the orbit not to represent the real orbit. So now I have no clues anymore...Any help from these thyme guys over here?
Sorry if I've misspell something.
Edit: I also would like to tell you that my main goal is have multiple objects (Earth and Moon, for example) and make it like a game. I believe I have two ways of doing it, analitically with Patched Conic Approximation(just like KSP) or numerically by solving x and y ODE, but this is a future project...