Originally Posted by

**tony873004** Sorry, I overlooked that. You did give it.

If I'm understanding this correctly, I'd like to get rid of all r's and v's in the equation, replacing them with rx, ry, rz, vx, vy, vz so I can plug in the actual values.

So solving for ex should look like:

But I suspect I made a mistake somewhere because:

Code:

'Visual Basic 6.0
'where mu= 1.32673637E+20 (mks units)
' Rx = -46720169584.3259 m
' Ry = 115742152531.547
' Rz = 0
' Vx = -30938.7102458567 m/s
' Vy = -16802.9119738538
Ex = (1 / mu) * ((Vx ^ 2 + Vy ^ 2 + Vz ^ 2 - (mu / Sqr(Rx ^ 2 + Ry ^ 2 + Rz ^ 2))) * Rx - (Rx * Vx + Ry * Vy + Rz * Vz) * Vx)
Ey = (1 / mu) * ((Vx ^ 2 + Vy ^ 2 + Vz ^ 2 - (mu / Sqr(Rx ^ 2 + Ry ^ 2 + Rz ^ 2))) * Ry - (Rx * Vx + Ry * Vy + Rz * Vz) * Vy)
Ex = (1 / mu) * ((Vx ^ 2 + Vy ^ 2 + Vz ^ 2 - (mu / Sqr(Rx ^ 2 + Ry ^ 2 + Rz ^ 2))) * Rz - (Rx * Vx + Ry * Vy + Rz * Vz) * Vz)
EccentricityVector = Sqr(Ex ^ 2 + Ey ^ 2 + Ez ^ 2)
Eccentricity = Abs(EccentricityVector)
'I should get Eccentricity = 0.2
'Instead, I get Eccentricity = 9.08106826571385E-02

Did I make a dumb mistake somewhere?

Your code looks OK to me. Works OK for me:

I assume Vz=0, is that right?

Code:

>..Euler console session:
>
>..Define R
>..-------
>R=[-46720169584.3259,115742152531.547,0]
-4.67202e+10 1.15742e+11 0
>
>..Define V
>..-------
>V=[-30938.7102458567,-16802.9119738538,0]
-30938.7 -16802.9 0
>
>..Define mu
>..---------
>mu=1.32673637E+20
1.32674e+20
>
>
>..compute e
>..----------
>e=1/mu*((V.V'-mu/(sqrt(R.R')))*R-(R.V')*V)
-0.178628 0.0908107 0
>
>sqrt(e.e')
0.200386
>

So either your code has a error in it (I cant see it) )or there is a loss of

precission somewhere. What is the default floating type in VB? Is

it a double (64bit) or single(32bit)?

RonL