You probably mean,Originally Posted by tony873004
So what is the problem?
How?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:
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
But where the vectors are not in absolute value brackets, I don't know what to do. I can't punch
into my calculator.
Similarly, in the formula for Eccentric anomoly ( http://en.wikipedia.org/wiki/Eccentric_anomaly ):
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?
Originally Posted by ThePerfectHackerYes, that's what I meant. The problem is that r appears both in and out of abs brackets in the formulaOriginally Posted by ThePerfectHacker
and v, also a vector, appears only out of brackets. So, for example, if an object had a position of:
and a velocity of
and mu = 1.3E20 (mu is G, the gravitational constant times mass of the object being orbited)
and I don't know how to translate that into a line of computer code
or even punch it into my calculator. (Because of the hats ).
I don't understand what "how?" refers to.How?
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
9. well... 60
10. Tried once, failed and gave up.
Sorry latex is too long. I just put my x,y&z values with i,j,k hats in place of the non |vectors|
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.Originally Posted by CaptainBlack
** 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.
My earlier reply gave a definition of the dot product for 3-vectors,Originally Posted by tony873004
in general for N-vectors:
No, this would be a triple dot or scalar product of some sort, which is not commonly usedWould I be correct to assume that:
A*B*C = AxBxCx+AyByCy ?
and to use a notation like for this would be a confusing abuse of notation.
Sorry, I overlooked that. You did give it.Originally Posted by CaptainBlack
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:
Did I make a dumb mistake somewhere?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
Your code looks OK to me. Works OK for me:Originally Posted by tony873004
I assume Vz=0, is that right?
So either your code has a error in it (I cant see it) )or there is a loss ofCode:>..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 >
precission somewhere. What is the default floating type in VB? Is
it a double (64bit) or single(32bit)?
There are two equations for Ex. The second one should be for Ez.Originally Posted by tony873004
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)
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.