So i have been teaching myself physics and then programming a simulator with this knowledge in Unity3D. So, i have recently finished eccentricity but when i programmed the script to do the calculation it always returns 1. :facepalm:
So the equation i used was :
e = Sqrt(1+(2(((v^2/2)-((G(M1+M2)/r)))*(r*(m*v)^2)))/((1/((1/M1)+(1/M2)))*(G(M1*M2))^2)) which should be the expanded form of e = Sqrt(1+((2(E*L^2))/(mred*a^2))) but this isn't working. Where
v = velocity
G = Grav. Constant
r = distance
m = M1
E = orbital energy
L = angular momentum
mred = reduced mass
a = coef. of inverse-square law
So maybe i missed a variable or something. So have any ideas on what is wrong? Ohh and to get velocity i used a built in Unity function to find velocity so i don't need to calculate for that.
So the equation i used was :
e = Sqrt(1+(2(((v^2/2)-((G(M1+M2)/r)))*(r*(m*v)^2)))/((1/((1/M1)+(1/M2)))*(G(M1*M2))^2)) which should be the expanded form of e = Sqrt(1+((2(E*L^2))/(mred*a^2))) but this isn't working. Where
v = velocity
G = Grav. Constant
r = distance
m = M1
E = orbital energy
L = angular momentum
mred = reduced mass
a = coef. of inverse-square law
So maybe i missed a variable or something. So have any ideas on what is wrong? Ohh and to get velocity i used a built in Unity function to find velocity so i don't need to calculate for that.