Jump to content

Calculating an orbit so the time spent on either side of a threshold alt is the same.


Recommended Posts

Lets take an example.  We are at the Mun with an Pe of 20km.  We know the cutoff between low/high space is at 60km.  What does my Ap need to be so that the vessel spends about the same amount of time both above and below the 60km border during a single orbit?  

Link to comment
Share on other sites

I think it depends on the definition of "about" the same amount of time. 

I didn't crunch any numbers, and the census guy just woke me up so I'm groggy and grumpy, but instinctively, I think this isn't possible.     If you spend the same amount of time on each side of the AN/DN, then you have a circular orbit.   Lowering your Pe means that half of the orbit is not only shorter, but the craft will be moving faster. 

So I don't think it's possible to have Ap/Pe's set to have equal time above/below a mean Altitude.

Now if you're looking to gather science, that's a different story.    I would think being +/- 1km from your mean altitude should given you plenty of time to do all the experiments you want to do.    Throw in some inclination, and you could cover the majority of the body's orbital biomes pretty easily.

So if the cutoff is 60km, then a 59x61km orbit should suit your needs fine. 

Link to comment
Share on other sites

54 minutes ago, Gargamel said:

I didn't crunch any numbers, and the census guy just woke me up so I'm groggy and grumpy, but instinctively, I think this isn't possible.     If you spend the same amount of time on each side of the AN/DN, then you have a circular orbit.   Lowering your Pe means that half of the orbit is not only shorter, but the craft will be moving faster. 

Your grogginess is indeed doing you a disservice ;)

It is in fact possible to create an orbit where you spend the same amount of time both below and above a certain altitude. Think about it: if you move faster in the low part of the orbit, then the high part of the orbit simply must be less than half of an orbit. For example, if you have a PE of 20 km and an AP of 65 km, then the part of the orbit that is above 60 km will not be half an orbit, but rather noticably less. You move slower across that section, but because it is shorter, it will not take as long to move through.

That said, I don't know how to precalculate such an orbit. If I wanted to do it ingame, I'd probably guess an apoapsis altitude, make a maneuver node to plan it, note the resulting orbital period, and then mouse over the two 60 km altitude points and measure the time difference between them. Then adjust AP until the time difference between the 60 km points is half the orbital period.

How do you find out where the 60 km altitude line is? No idea! At least not without cheating. You could use the set orbit cheat to put a disposable probe into a circular 60 km orbit at the inclination and LAN that you need, use it to help plot your orbit, and then delete the cheated object again.

 

Edited by Streetwind
Link to comment
Share on other sites

5 minutes ago, Streetwind said:

That said, I don't know how to precalculate such an orbit.

I think that's the rub here.   Since we're not, assumedly, dealing with some need for a wonky Polynya style orbit, where exact position and timing is required, I don't see why just going slightly above and below our mean altitude wouldn't work here.   Yes, the times aren't even, but I don't think it matters.   If you just want to get science (which I believe is the OP's intent), then just having some significant portion above and below should suffice.   It shouldn't matter that it's 54%/46% or whatever, as long as you have enough time to do all the science you want, and the orbit precesses over the surface. 

But while this might be the most fuel efficient method, having one orbit that covers all situations and biomes, the amount of Dv required to make a sub 60km circular orbit and then bump it to an over 60km circular orbit should be minuscule.    That way you can get all the science you want for one situation in a single orbit or two, and then bump it up, and do it again.   Gameplay, this would take far less time than waiting for above/below orbit to precess over the body. 

This is, of course, assuming science is the goal, which was implied in the OP, but not specifically stated. 

Link to comment
Share on other sites

This is an interesting mathematical problem. Not impossible, I reckon, but the difference between your periapsis and the mean altitude would have to be larger than the difference between the mean altitude and your apoapsis, since objects always travel faster the lower in the gravitational well they get. In mathematical terms: 

|M - P| > |A - M|

where M is the "dividing" altitude (60 km in your example), A and P are Apoapsis and Periapsis respectively.

Not sure how serious you are about the answer, but I could imagine the simplest way to calculate this using the Kepler's laws.

The second Kepler's law tells you that the ratio of time spent on any two segments of an elliptical orbit is exactly the same as the surface area covered by a line segment between your vessel and the centre of the celestial body you're orbiting. The request of t1 = t2 thus translates into S1 = S2. Now all you have to do is pick an eccentricity of an ellipse, write down its analytical equation and integrate it to get the surface area.

 

hrtrm3o1n1bzeowzg.jpg

EDIT: And by altitude in the picture above I mean altitude above the centre of the body, not its surface. It tends to be easier to just forget about the size of the celestial body and simply view it as a point. :) You can always subtract its radius from your result.

Edited by Aelipse
Link to comment
Share on other sites

11 hours ago, Aelipse said:

This is an interesting mathematical problem. Not impossible, I reckon, but the difference between your periapsis and the mean altitude would have to be larger than the difference between the mean altitude and your apoapsis, since objects always travel faster the lower in the gravitational well they get. In mathematical terms: 

|M - P| > |A - M|

where M is the "dividing" altitude (60 km in your example), A and P are Apoapsis and Periapsis respectively.

Not sure how serious you are about the answer, but I could imagine the simplest way to calculate this using the Kepler's laws.

The second Kepler's law tells you that the ratio of time spent on any two segments of an elliptical orbit is exactly the same as the surface area covered by a line segment between your vessel and the centre of the celestial body you're orbiting. The request of t1 = t2 thus translates into S1 = S2. Now all you have to do is pick an eccentricity of an ellipse, write down its analytical equation and integrate it to get the surface area.

 

hrtrm3o1n1bzeowzg.jpg

EDIT: And by altitude in the picture above I mean altitude above the centre of the body, not its surface. It tends to be easier to just forget about the size of the celestial body and simply view it as a point. :) You can always subtract its radius from your result.

For funsies, I decided to take a stab at this and uhh, it's not pretty at all...

Link to comment
Share on other sites

It's a solved problem for elliptical orbits using the function between mean anomaly (time based from periapsis) and eccentric anomaly (angle based from periapsis).

https://en.wikipedia.org/wiki/Mean_anomaly

At the end of the article just before the references, there's a infinite equation to calculate the eccentric anomaly from the mean anomaly that can be used to figure out the position.  From that, should be able to calculate the required orbital parameters.

Link to comment
Share on other sites

I think at this point, to satisfy my own curiosity, is this highly mathematical orbit any better for gathering science than one that barely dips above and below the stated mean?

I'm still curious to hear the solution to the more complex problem, though. 

Link to comment
Share on other sites

33 minutes ago, Gargamel said:

I think at this point, to satisfy my own curiosity, is this highly mathematical orbit any better for gathering science than one that barely dips above and below the stated mean?

I'm still curious to hear the solution to the more complex problem, though. 

The mathematical solutions satisfying the given time requirement does actually involve orbits that barely dip above and below a chosen mean altitude. :)

Link to comment
Share on other sites

We can solve numerically using Kepler's equation.

Mean anomaly (M) is zero at periapsis, increases uniformly to π at as the craft reaches apoapis, then increases to 2π as the craft returns to periapsis. If we want to find the altitude that half the orbital time is spent above, then we set M to 0.5 * π. (As another example, if we wanted the radius above which 30% of the time is spent, then we would set M = 0.7 * π).

Kepler's equation relating mean anomaly and eccentric anomaly (E) is:
(1) M = E - e * sin(E)

So we have:
(2) 0 = E - e * sin(E) - 0.5 * π

Define:

  • Periapsis radius = rp = 220000 km (from center of Mun)
  • Threshold radius = rt = 260000 km
  • Apoapsis radius = r = ?

Eccentricity (e) in terms of our unknown (r):
(3) e = (r - rp) / (r + rp)
Derivative of equation 3:
(4) de/dr = e' = 2rp / (r + rp)2

Cosine of eccentric anomaly (E) in terms of our unknown (r):
(5) cos(E) = c = (r + rp - 2rt) / (r - rp)
Derivative of equation 5:
(6) d(cos(E))/dr = c' = 2 * (rt - rp) / (r - rp)2

For convenience:
(7) sin(E) = s = sqrt(1 - c2)
(8) E = cos-1(c)


Putting (2), (7) and (8) together, our function to find r (will be zero when r is our desired apoapsis):
f(r) = cos-1(c) - e * s - 0.5 * π
The derivative of this function (liberally applying chain and product rules) is:
f'(r) = -c` / sqrt(1 - c2) - [e' * s - e * c * c' / sqrt(1-c2)]
Tidying:
f'(r) = c` * (e * c - 1) / s - (e' * s)

Solve numerically using your favorite method (e.g Newton's method). kOS code in the spoiler

Spoiler

local rp is mun:radius + 20000.
local rt is mun:radius + 60000.
local M is 0.5 * constant:pi.

local ra is rt + 1. // Initial guess
local delta is 1.
local iterations is 0.

until abs(delta) < 1 or iterations = 15 {
    local e is (ra - rp) / (ra + rp).
    local de is (2 * rp) / ((ra + rp) ^ 2).

    local c is (rp + ra - 2 * rt) / (ra - rp).
    local dc is 2 * (rt - rp) / ((ra - rp) ^ 2).

    local s is sqrt(1 - c ^ 2).
    local EA is arccos(c) * constant:degtorad.

    local f is EA - e * s - M.
    local df is dc * (e * c - 1 ) / s - de * s.

    set delta to f / df.
    set ra to ra - delta.
    set iterations to iterations + 1.
}

print ra.


290,408m (from center of Mun) ≈ 90,408m in-game altitude.

Edited by ManEatingApe
Link to comment
Share on other sites

1 hour ago, Lt_Duckweed said:

Yeah, that's way better than the integrals I was doing in rectangular coordinates lol.

This can be actually done in the Cartesian coordinates. The function for the upper half of the ellipse (we can only take one half since it's symmetrical) is:

y = b * sqrt( 1 - x2/a2 ). Integrating it over dx requires a clever trick of substituting x for for a new variable z with this condition: x = a * cos(z). 

You get this formula for the surface area under the ellipse curve: S = a * b * integral( sin(z)2 * dz )

This can be tackled easily with the knowledge of the trigonometric equality cos(2z) = cos(z)2 - sin(z)2, which gives you sin(z)2 = ( 1 - cos(2z) ) / 2

Your integral is then S = a * b * integral( (1 - cos(2z)) / 2 ) dz, which then can be torn apart into two integrals, both for x running from -a to a (after having reversed the substitution). You end up with a formula for the surface area of an ellipse (a whole ellipse would yield pi * a * b, by the way). Then you simply subtract the surface area of the yellow triangle below the line segment dividing the green and the yellow areas and you get a nice formula for the green surface area (the upper half of it rather). Then you have to solve what you got for T, where T is the x coordinate of the dividing point which we are really trying to find.

I did a very similar calculation with my high school students and many of them got the gist of it, although admittedly none were too keen to be tested on this. :D

EDIT: A big shout out to the administrators of the forum. Why do we not have an equation editor? :P

Edited by Aelipse
Link to comment
Share on other sites

4 hours ago, Aelipse said:

This can be actually done in the Cartesian coordinates. The function for the upper half of the ellipse (we can only take one half since it's symmetrical) is:

y = b * sqrt( 1 - x2/a2 ). Integrating it over dx requires a clever trick of substituting x for for a new variable z with this condition: x = a * cos(z). 

You get this formula for the surface area under the ellipse curve: S = a * b * integral( sin(z)2 * dz )

This can be tackled easily with the knowledge of the trigonometric equality cos(2z) = cos(z)2 - sin(z)2, which gives you sin(z)2 = ( 1 - cos(2z) ) / 2

Your integral is then S = a * b * integral( (1 - cos(2z)) / 2 ) dz, which then can be torn apart into two integrals, both for x running from -a to a (after having reversed the substitution). You end up with a formula for the surface area of an ellipse (a whole ellipse would yield pi * a * b, by the way). Then you simply subtract the surface area of the yellow triangle below the line segment dividing the green and the yellow areas and you get a nice formula for the green surface area (the upper half of it rather). Then you have to solve what you got for T, where T is the x coordinate of the dividing point which we are really trying to find.

I did a very similar calculation with my high school students and many of them got the gist of it, although admittedly none were too keen to be tested on this. :D

EDIT: A big shout out to the administrators of the forum. Why do we not have an equation editor? :P

The approach that I took was to get the explicit equation for an ellipse with one foci at (0, 0), then perform 3 integrals
1. The integral for the ellipse from c-a to n (where n is the x coordinate point we are interested in)
2. The line radiating out from the origin to the point in interest expressed with slope as a function of n, then integrated from 0 to n
3. The ellipse integrated from n to c+a.

After much variable wrangling and simplification, I got to the equation n= a*sin((c/a)(1-((n-c)/a)^2)^(1/2))+c where n is the x coord of the point, a is the semimajor axis, and c is the distance from the foci to the center of the ellipse (in other words a*eccentricity).  I'm sure you can see the issue here.  while I have a nice clean n by itself on the left, I also have one buried deep within the sin term on the right.

Link to comment
Share on other sites

15 hours ago, Gargamel said:

is this highly mathematical orbit any better for gathering science than one that barely dips above and below the stated mean?

No.  At least not for stock.  You just have to below the border for long enough to activate your instruments, a minute or so max.  If you can't do it that fast for whatever reason, just timewarp ahead until you drop below the border again.  Lather, rinse, repeat as needed.

Edited by DerekL1963
Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...