1. ## vector questions

Hi all. 1st post here. I've got a math question. I hope this is the right sub-forum. This is not homework, just stuff I like to work on. This question deals with celestial mechanics. But don't worry if you know nothing about celestial mechanics. It's the math that's bothering me.

To compute the eccentric vector, ( http://en.wikipedia.org/wiki/Eccentricity_vector ) the following formula is used:

$
e = \frac{1}{\mu }\left[ {\left( {v^2 - \frac{\mu }{{\left| r \right|}}} \right)r - \left( {r \cdot v} \right)v} \right]
$

It looks pretty straightforward. If I know v, mu, and r, I should just be able to plug in and solve for e.

I do know mu. However, v and r are vectors. What I do know is the x, y, and z components of both v and r. And where r is in absolute value brackets, I believe can just do
$
r = \sqrt {x_r^2 + y_r^2 + z_r^2 }
$

But where the vectors are not in absolute value brackets, I don't know what to do. I can't punch $\hat i,\hat j,\hat k$
into my calculator.

Similarly, in the formula for Eccentric anomoly ( http://en.wikipedia.org/wiki/Eccentric_anomaly ):
$
E = \cos ^{ - 1} \frac{{1 - \left| r \right|/a}}{e}
$

r is a vector. It represents distance. Taking its absolute value will give me the same answer for 2 different points on an orbit. But every point on the orbit should have a unique Eccentric anomoly.

I've never had a math class that dealt with vectors in equations like this. Any idea how I should treat them?

Thanks.

2. Originally Posted by tony873004
I do know mu. However, v and r are vectors. What I do know is the x, y, and z components of both v and r. And where r is in absolute value brackets, I believe can just do
$
r = \sqrt {x_r^2 + y_r^2 + z_r^2 }
$
You probably mean,
$|r|=\sqrt {x_r^2 + y_r^2 + z_r^2 }$
So what is the problem?

Originally Posted by tony873004
$
E = \cos ^{ - 1} \frac{{1 - \left| r \right|/a}}{e}
$

r is a vector. It represents distance. Taking its absolute value will give me the same answer for 2 different points on an orbit. But every point on the orbit should have a unique Eccentric anomoly.
How?

3. Originally Posted by tony873004
Hi all. 1st post here. I've got a math question. I hope this is the right sub-forum. This is not homework, just stuff I like to work on. This question deals with celestial mechanics. But don't worry if you know nothing about celestial mechanics. It's the math that's bothering me.

To compute the eccentric vector, ( http://en.wikipedia.org/wiki/Eccentricity_vector ) the following formula is used:

$
e = \frac{1}{\mu }\left[ {\left( {v^2 - \frac{\mu }{{\left| r \right|}}} \right)r - \left( {r \cdot v} \right)v} \right]
$
$
v^2=v_x^2+v_y^2+v_z^2
$
,

where $v=[v_x,v_y,v_z]$, and:

$
r \cdot v=r_x v_x+r_y v_y+r_z v_z
$

is the dot product of $v$ and $r$ where $r=[r_x,r_y,r_z]$, and:

$
|r|=\sqrt {r_x^2 + r_y^2 + r_z^2 }
$
.

Then:

$
e_x = \frac{1}{\mu }\left[ {\left( {v^2 - \frac{\mu }{{\left| r \right|}}} \right)r_x - \left( {r \cdot v} \right)v_x} \right]
$

$
e_y = \frac{1}{\mu }\left[ {\left( {v^2 - \frac{\mu }{{\left| r \right|}}} \right)r_y - \left( {r \cdot v} \right)v_y} \right]
$

$
e_z = \frac{1}{\mu }\left[ {\left( {v^2 - \frac{\mu }{{\left| r \right|}}} \right)r_z - \left( {r \cdot v} \right)v_z} \right]
$

where $e=[e_x,e_y,e_z]$

RonL

4. Originally Posted by ThePerfectHacker
You probably mean,
$|r|=\sqrt {x_r^2 + y_r^2 + z_r^2 }$
So what is the problem?

How?
Originally Posted by ThePerfectHacker
You probably mean,
$|r|=\sqrt {x_r^2 + y_r^2 + z_r^2 }$
So what is the problem?

How?
Yes, that's what I meant. The problem is that r appears both in and out of abs brackets in the formula
$
e = \frac{1}{\mu }\left[ {\left( {v^2 - \frac{\mu }{{\left| r \right|}}} \right)r - \left( {r \cdot v} \right)v} \right]
$

and v, also a vector, appears only out of brackets. So, for example, if an object had a position of:
x=1 m
y=2
z=3

and a velocity of
x=0.1 m/s
y=0.2
z=0.3

and mu = 1.3E20 (mu is G, the gravitational constant times mass of the object being orbited)

I'd have:

$
\begin{array}{l}
e = \frac{1}{{1.3 \times 10^{20} }}\left[ {\left( {\left( {0.1\hat i + 0.2\hat j + 0.3\hat k} \right)^2 - \frac{{1.3 \times 10^{20} }}{{\sqrt {x_r^2 + y_r^2 + z_r^2 } }}} \right)1\hat i + 2\hat j + 3\hat k - \left( {1\hat i + 2\hat j + 3\hat k \cdot 0.1\hat i + 0.2\hat j + 0.3\hat k} \right)0.1\hat i + 0.2\hat j + 0.3\hat k} \right] \\
\\
\end{array}
$

and I don't know how to translate that into a line of computer code

e=(1/1.3e20)*((?)^2-(1.3e20)/(sqrt(rx^2+ry^2+rz^2))*(?)-?*?

or even punch it into my calculator. (Because of the hats ).

How?
I don't understand what "how?" refers to.

btw. nice sig:
1. Blue screen of death is easy
3. I know VB better than English.
5. I hate dynamic IPs or I'd have that too
7. Yes
9. well... 60
10. Tried once, failed and gave up.

** edit
Sorry latex is too long. I just put my x,y&z values with i,j,k hats in place of the non |vectors|

5. Originally Posted by CaptainBlack
$
v^2=v_x^2+v_y^2+v_z^2
$
,

where $v=[v_x,v_y,v_z]$, and:

$
r \cdot v=r_x v_x+r_y v_y+r_z v_z
$

is the dot product of $v$ and $r$ where $r=[r_x,r_y,r_z]$, and:

$
|r|=\sqrt {r_x^2 + r_y^2 + r_z^2 }
$
.

Then:

$
e_x = \frac{1}{\mu }\left[ {\left( {v^2 - \frac{\mu }{{\left| r \right|}}} \right)r_x - \left( {r \cdot v} \right)v_x} \right]
$

$
e_y = \frac{1}{\mu }\left[ {\left( {v^2 - \frac{\mu }{{\left| r \right|}}} \right)r_y - \left( {r \cdot v} \right)v_y} \right]
$

$
e_z = \frac{1}{\mu }\left[ {\left( {v^2 - \frac{\mu }{{\left| r \right|}}} \right)r_z - \left( {r \cdot v} \right)v_z} \right]
$

where $e=[e_x,e_y,e_z]$

RonL
This looks good. Give me a few minutes to digest it. Ultimately, I'm after |e|, but that would just be pothagin' e I think.

** edit. Maybe more than a few minutes. I've got to find my old Physics book. I know we did dot products. No need to ask you to explain further since my book has this. I'll post tommorow, either thanking you, or asking you more q's.

6. I can only find 2-d examples of dot products.

A*B = AxBx+AyBy

Would I be correct to assume that:

A*B*C = AxBxCx+AyByCy ?

7. Originally Posted by tony873004
I can only find 2-d examples of dot products.

A*B = AxBx+AyBy
My earlier reply gave a definition of the dot product for 3-vectors,
in general for N-vectors:

$
\bold{a} \cdot \bold{b}=\sum_{i=1}^N a_ib_i
$
,

where $\bold{a}=[a_1,a_2,\ ..\ ,a_n]$ and $\bold{b}=[b_1,b_2,\ ..\ ,b_n]$

Would I be correct to assume that:

A*B*C = AxBxCx+AyByCy ?
No, this would be a triple dot or scalar product of some sort, which is not commonly used
and to use a notation like $\bold{a}\cdot \bold{b} \cdot \bold{c}$ for this would be a confusing abuse of notation.

RonL

8. So...

A*B = AxBx+AyBy+AzBz

??

9. Originally Posted by CaptainBlack
My earlier reply gave a definition of the dot product for 3-vectors
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?

10. Originally Posted by tony873004
So...

A*B = AxBx+AyBy+AzBz

??
Yes

11. 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

12. 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?
There are two equations for Ex. The second one should be for Ez.

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)

13. Originally Posted by JakeD
There are two equations for Ex. The second one should be for Ez.

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)
That would explain the result nicely, as Ez is not not assigned and VB sets
it by default to 0, Ex is reset to what Ez shoud have been (which is 0), so
Ecentricity will be |Ey|=0.0908107

RonL

14. Vz is 0. The program actually pulls them from text boxes, not the commented lines. All variables are "Dim as Double"

After fixing the typo Jake found, it works for me now too, both for the input shown, and other input with known output that I've tested it against.

Thanks, Captain Black . There's more orbital elements I want to compute, and thanks to you, my new understanding of vectors will come in handy.