Advanced Question Predicting longitude at apogee.

asbjos

tuanibrO
Addon Developer
Joined
Jun 22, 2011
Messages
696
Reaction score
259
Points
78
Location
This place called "home".
Hello again!

I want to predict what my longitude is at the spacecraft's apoapsis, assuming that I'm burning the engines right now.

I thought that I could just look at the longitude of periapsis which I can find with the GetElements method, add 180 degrees to get the apoapsis and then subtract the amount of degrees the Earth will rotate beneath until apoapsis. I discovered that longitude of periapsis is given in radians after the ascending node, so I used this code to predict longitude of apoapsis:

Code:
double LongApo = LAN + LongPer + PI - (PI2/oapiGetPlanetPeriod(RefPlanet))*HypApTime;
where the variables are defined as:
Code:
ELEMENTS el;
ORBITPARAM prm;
Vessel->GetElements (RefPlanet, el, &prm, oapiGetSimMJD(), FRAME_EQU);

double LAN = el.theta;
double LongPer = el.omegab;
double HypSMa = (TargetRadius + prm.PeR)/2
double HypApTime = PI*sqrt(pow(HypSMa,3)/(GGRAV*oapiGetMass(RefPlanet)));

Now, this doesn't work correctly. The longitude of periapsis is given in a fixed reference frame, not taking into account that the Earth is rotating, so this will not give the right answer over time.
My guess is that I have to find out the orientation of the Earth and add that to the equation, but I don't know how to find that.

Is it right? If so: how do I find the planet's orientation? If not: how can I find the longitude of apoapsis?

Thanks in advance!
 

Enjo

Mostly harmless
Addon Developer
Tutorial Publisher
Donator
Joined
Nov 25, 2007
Messages
1,665
Reaction score
13
Points
38
Location
Germany
Website
www.enderspace.de
Preferred Pronouns
Can't you smell my T levels?
Try subtracting oapiGetPlanetCurrentRotation(RefPlanet)

Is adding LAN necessary?
 

Enjo

Mostly harmless
Addon Developer
Tutorial Publisher
Donator
Joined
Nov 25, 2007
Messages
1,665
Reaction score
13
Points
38
Location
Germany
Website
www.enderspace.de
Preferred Pronouns
Can't you smell my T levels?
And? Does it work?
 

dgatsoulis

ele2png user
Donator
Joined
Dec 2, 2009
Messages
1,927
Reaction score
340
Points
98
Location
Sparta
Can't you simply get your longitude at the time of the burn with GetEquPos?

I was trying to do something similar a while back.
I wanted to know in advance at which longitude to make a burn, in order to get a ship at a synchronous orbit, over a specific longitude.

If the burns are instantaneous, it is a very simple.

1. Long(d) = Desired longitude at apogee.
2. dlong = Time to apogee * rate of planet's rotation
3. Long at perigee = [Long(d)-180] - dlong

Since the altitude of the synchronous orbit is known, it is very easy to calculate the Time to apogee, from the semimajor axis of the transfer orbit.

The problem is that there is no such thing as an instantaneous burn.
Both burns (at periapsis and apoapsis) take time and during that time the spacecraft is moving and the planet is rotating.

A spacecraft at a low equatorial orbit is moving at ~4°/min due East and Earth is rotating at ~0.25°/min in the same direction. (assuming a prograde direction for the ship).

It gets even more complicated if the initial orbit is inclined and/or elliptical.
IIRC the solution involved the airspeed of the ship at Tburn and at Tburnout (I had used the airspeed because it already compensated for the planet's rotation), the distance from the planet and the cos of the inclination.
I'll have to go through my notes to see if I still have the solution.
 

asbjos

tuanibrO
Addon Developer
Joined
Jun 22, 2011
Messages
696
Reaction score
259
Points
78
Location
This place called "home".
And? Does it work?

Sorry for the lack of response, but thank you for your interest!

First, the reason that I added LAN was lack of knowledge. I had unknowingly mixed the two parameters "argument of periapsis" (APe) and "longitude of periapsis" (LPe). I wanted to get LPe and thought that el.omegab gave me APe. I then wanted to convert to LPe with the correct equation:
[MATH]LPe=APe+LAN[/MATH]But el.omegab gives LPe, so as you pointed out: adding LAN was not correct.

Then, removing the LAN and subtracting oapiGetPlanetCurrentRotation still gave me the wrong answer, so I did as dgatsoulis: I used oapiGetEquPos.
I now use this method:
Code:
double Long, Lat, Rad;
oapiGetEquPos(&Long, &Lat, &Rad);
double LongApo = Long - HypApTime*PI2/oapiGetPlanetPeriod(RefPlanet);
This works nicely. It gives me the correct longitude, but I'm not 100 % satisfied as this breaks with my own rule of universal use, as oapiGetEquPos only can give coordinates with respect to the closest celestial body. I want to be able to select the reference planet freely.
A worst case scenario would be if I'm in orbit around Mars and it gives me the coordinates for Phobos.
Also, as dgatsoulis mentions, the resulting longitude assumes an engine burn which takes 0 seconds, but with my programming "skills", this is the most advanced and correct result that I can get.

I used a similar method to show current apogee longitude. The equation I used there was (TrA is true anomaly):
Code:
double CurrApoLong = Long - TrA - ApT*PI2/oapiGetPlanetPeriod(RefPlanet);
The result is slightly moving over time, probably because of elliptical orbit or inclination not equal to zero. This is probably happening to the prediction of apogee longitude too.
Also, I fear that the result would be completely off in an orbit with a significant inclination, like a polar or retrograde orbit (I haven't checked it out yet).
I believe I have to multiply something with the cosine of the inclination, but I don't know.
I'm still experimenting and hoping to improve my predictions.

Thank you for your answers and thoughts!
 

dgatsoulis

ele2png user
Donator
Joined
Dec 2, 2009
Messages
1,927
Reaction score
340
Points
98
Location
Sparta
This works nicely. It gives me the correct longitude, but I'm not 100 % satisfied as this breaks with my own rule of universal use, as oapiGetEquPos only can give coordinates with respect to the closest celestial body. I want to be able to select the reference planet freely.

If you are not already very near the reference body, what good is knowing the longitude that the ship is flying over? I do get the point you made about Phobos, but that's probably the only case in the solar system.

True, universality is a good thing, after all there are lots of custom solar systems out there. How about GlobalToEqu ? You can select the reference point you want.
 
Top