• Welcome to the new COTI server. We've moved the Citizens to a new server. Please let us know in the COTI Website issue forum if you find any problems.
  • We, the systems administration staff, apologize for this unexpected outage of the boards. We have resolved the root cause of the problem and there should be no further disruptions.

Rendezvous Math

whartung

SOC-14 5K
So, year or so ago, I did this post:


Someone was kind enough to upvote it the other day, and I thought I could readdress it.

With the new ChatGPT features to learn math to blockheads like me, we were able to solve the equations and get some numbers. One of the results were interesting and unintuitive, but it works out.

To summarize, the scenario is you have a ship trying to rendezvous with a planet. The initial use case is the ship is trailing the planet. There's no gravity involved, and the planet is going in a straight line (these are magic planets that fit right in with Traveller M-Drives).

When a ship is trailing the planet, an the ship is not going as fast as the planet, then in order to catch the planet it must first accelerate to be faster than the planet, and the decelerate until it matches the planet velocity and its position

So, this was the core math involved:

sx + sv + .5 * a * t1^2 + (sv + a * t1) + .5 * -a * t2^2 = px + pv * (t1 + t2)
sv + (a * t1) - (a * t2) = pv

What this says is that the final ship position must be how far it travels under acceleration for period t1 + how far it travels under deceleration (the -a) for period t2, and it must match the planets position which is px (the original planet position) plus how far it travels over the total time (t1 + t2) and speed pv.

At the same time, the ships final velocity, which is it current velocity plus how fast its going after t1 and how much its slowed down at t2. That must match the planets constant velocity.

So, turns out this is a simple algebra problem. Since I have always sucked at algebra, I don't see algebraic solutions.

But ChatGPT does!

The way to solve these two equations was that it took the velocity equation, and rewrote it to calculate t2 in terms of t1.

Like this: t2 = sv + a * t1 - pv / a.

Then you substitutes all instances of t2 in the first equation with this new equation (which I won't do). Then you rewrite that equation in terms of t1.

In the end you get an equation that can be solved as a quadratic equation. Once you have t1 calculated, you can then put that in the formula for t2 and voila!

So, given all that, I have a java program that will calculate this stuff for us.

Turns out there's two fundamental scenarios. Ship trailing the planet, where you need to accelerate and then decelerate. There's then the other side where you need to decelerate and then accelerate. For example, if you're in front of the planet. Using "accelerate" and "decelerate" are a bit confusing because of the signs of everything. For example, to accelerate, you use positive a (say, 10), and decelerate you use negative a (like -10).

But that gets weird. For example, say you're in front of the planet by a large margin. In that case, you'll want to accelerate TOWARD the planet and then decelerate into the planet. But, since you're in front of the planet, you need a "negative" velocity, even though its going "up" (i.e. more negative). Because I visualize acceleration as thrust in the direction I want to go, and deceleration as thrust against the direction I'm going. In the end, it's a rocket with a flame racing out the back, the universe doesn't really care.

That said, while playing with it there was an unintuitive solution. You're in front of the planet, and it turns out the best path is to accelerate AWAY from the planet and then decel into it. But that's the best path.

So, anyway, this code "does the right thing". Give the parameters (sx, sv, px, pv, a), it will tell you what the two phases are, and whether youre accelerating (positive a) or decelerating.

Finally, I did not write this code, the AI did. I just chatted with it for about 6 hours to get it to this state lol.

Given this scenario. You're leaving an Earth size planet (12Kkm in diameter) with a 1G drive. So you accelerate to 100D (1.2Bm).

At the end, you end up having a velocity of 154919.33 m/s.

So, you're arriving at another Earth planet. Should you arrive behind the planet, or in front of the planet? Earth travels at roughly 30km/s.

Here's some example results.

In the first case, you arrive behind the planet at 100D (12B m), your velocity is toward the planet.

The second case, you arrive at the 100D mark in front of the planet, with your velocity toward the planet (since you're in front, your velocity is negative).

Which route gets you into the Star Bar faster?

Code:
--- Calculating Rendezvous ---
Ship Position: 0.00, Ship Velocity: 154919.33
Planet Position: 1200000000.00, Planet Velocity: 30000.00
Acceleration: 10.00
Optimal Strategy: Decelerate first (Trailing scenario).
t1 (Acceleration Time): 1580.17 seconds
t2 (Deceleration Time): 14072.11 seconds
Total Time: 15652.28 seconds

Acceleration: 10.00 m/s²

After t1: Ship Position: 257284244.40 | Planet Position: 1247405219.59
After t2: Ship Position: 1669568429.19 | Planet Position: 1669568429.19

--- Calculating Rendezvous ---
Ship Position: 1200000000.00, Ship Velocity: -154919.33
Planet Position: 0.00, Planet Velocity: 30000.00
Acceleration: 10.00
Optimal Strategy: Decelerate first (Trailing scenario).
t1 (Acceleration Time): 25631.67 seconds
t2 (Deceleration Time): 7139.73 seconds
Total Time: 32771.40 seconds

Acceleration: 10.00 m/s²

After t1: Ship Position: 514071026.84 | Planet Position: 768949992.03
After t2: Ship Position: 983141994.06 | Planet Position: 983141994.06

As you can see, arriving behind the planet gets you there twice as fast. 4.3 hours vs 9.1. Also note for the second scenario, you need to start slowing down right away, and you pass the planet, and then you need to pass the planet, but you're still going faster than the planet, which is why you're decelerating on the final phase.

Anyway, it was a fun project arguing with the AI to get this to work. Answers some interesting questions (to me at least).

For some reason it won't let me attach the code as a file.

Code is in the next message cuz limits.
 
Code:
public class RendezvousCalculator {

    public static void main(String[] args) {
        // Test case: Ship trailing, but traveling too slow
        calculateRendezvous(0, 154919.33, 1200000000, 30000, 10);
        calculateRendezvous(1200000000, -154919.33, 0, 30000, 10);
        calculateRendezvous(0, 0, 0, 30000, 10);
        calculateRendezvous(45000000, 0, 0, 30000, 10);
        calculateRendezvous(0, 10000, 1000000, 30000, 10);
        calculateRendezvous(0, -10000, 1000000, 30000, 10);
        calculateRendezvous(1000000, -10000, 0, 30000, 10);
        // Test case: Ship trailing but traveling too fast
        calculateRendezvous(0, 50000, 1000000, 30000, 10);
        calculateRendezvous(200000000, 10000, 0, 30000, 10);
    }

    public static void calculateRendezvous(double sx, double sv, double px, double pv, double a) {
        System.out.println("\n--- Calculating Rendezvous ---");
        System.out.printf("Ship Position: %.2f, Ship Velocity: %.2f\n", sx, sv);
        System.out.printf("Planet Position: %.2f, Planet Velocity: %.2f\n", px, pv);
        System.out.printf("Acceleration: %.2f\n", a);

        // Calculate for Strategy 1: Trailing scenario (decelerate first)
        double[] resultTrailing = calculateTimes(sx, sv, px, pv, a);
        double t1Trailing = resultTrailing[0];
        double t2Trailing = resultTrailing[1];
        double totalTimeTrailing = t1Trailing + t2Trailing;

        // Check if trailing scenario is valid
        boolean trailingValid = t1Trailing >= 0 && t2Trailing >= 0;

        // If trailing scenario is invalid, switch to leading scenario
        double[] resultLeading = calculateTimes(sx, sv, px, pv, -a);
        double t1Leading = resultLeading[0];
        double t2Leading = resultLeading[1];
        double totalTimeLeading = t1Leading + t2Leading;

        // Check if leading scenario is valid
        boolean leadingValid = t1Leading >= 0 && t2Leading >= 0;

        // Choose the optimal strategy
        if (trailingValid && (!leadingValid || totalTimeTrailing <= totalTimeLeading)) {
            System.out.println("Optimal Strategy: Decelerate first (Trailing scenario).");
            displayResults(sx, sv, px, pv, a, t1Trailing, t2Trailing);
        } else if (leadingValid) {
            System.out.println("Optimal Strategy: Switch to leading scenario.");
            displayResults(sx, sv, px, pv, -a, t1Leading, t2Leading);
        } else {
            System.out.println("No valid solution: Both strategies result in negative values.");
        }
    }

    public static double[] calculateTimes(double sx, double sv, double px, double pv, double a) {
        // Relative position and velocity
        double relativePosition = px - sx;
        double relativeVelocity = pv - sv;

        // Calculate the discriminant for the kinematic equation
        double discriminant = a * relativePosition + 0.5 * (pv * pv - 2 * pv * sv + sv * sv);

        if (discriminant < 0) {
            return new double[]{-1, -1}; // No real solution exists
        }

        // Calculate potential t1 values (acceleration time)
        double sqrtDiscriminant = Math.sqrt(discriminant);
        double t1_1 = (relativeVelocity + sqrtDiscriminant) / a;
        double t1_2 = (relativeVelocity - sqrtDiscriminant) / a;

        // Calculate corresponding t2 values
        double t2_1 = (sv + a * t1_1 - pv) / a;
        double t2_2 = (sv + a * t1_2 - pv) / a;

        // Select the valid (t1, t2) pair where both t1 and t2 are non-negative
        if (t1_1 >= 0 && t2_1 >= 0) {
            return new double[]{t1_1, t2_1};
        } else if (t1_2 >= 0 && t2_2 >= 0) {
            return new double[]{t1_2, t2_2};
        } else {
            return new double[]{-1, -1}; // No valid solution
        }
    }

    public static void displayResults(double sx, double sv, double px, double pv, double a, double t1, double t2) {
        String phase1Label = (a > 0) ? "Acceleration" : "Deceleration";
        String phase2Label = (a > 0) ? "Deceleration" : "Acceleration";

        System.out.printf("t1 (%s Time): %.2f seconds\n", phase1Label, t1);
        System.out.printf("t2 (%s Time): %.2f seconds\n", phase2Label, t2);
        System.out.printf("Total Time: %.2f seconds\n", t1 + t2);
        System.out.printf("Acceleration: %.2f m/s²\n", a);

        // Position after t1
        double shipPositionAfterT1 = sx + sv * t1 + 0.5 * a * t1 * t1;
        double planetPositionAfterT1 = px + pv * t1;
        System.out.printf("\nAfter t1: Ship Position: %.2f | Planet Position: %.2f\n", shipPositionAfterT1, planetPositionAfterT1);

        // Position after t2
        double svAfterT1 = sv + a * t1;
        double shipPositionAfterT2 = shipPositionAfterT1 + svAfterT1 * t2 - 0.5 * a * t2 * t2;
        double planetPositionAfterT2 = planetPositionAfterT1 + pv * t2;
        System.out.printf("After t2: Ship Position: %.2f | Planet Position: %.2f\n", shipPositionAfterT2, planetPositionAfterT2);
    }
}
 
Missed this when it was made but funnily enough I have always assumed Jumping in would be in front of or behind the planet.

But in working out some scenarios on Chat GPT it turns out that L2 is the best place to Jump into.

That’s the Lagrange point further away from the Sun than the Earth but in line with it. It’s the place the James Webb telescope is.

The orbital velocity is similar to Earth’s and you have less decelerating or accelerating to do.
 
But in working out some scenarios on Chat GPT it turns out that L2 is the best place to Jump into.
Can you show the math you were using?

I didn't explore that because that makes the problem 2 dimensional, and a much different problem mathematically. Mine is a simple, contrived single dimension use case.
 
Wouldn't the planet be on an orbit circling the star? If so, it doesn't really matter how fast the planet is going, because it would be easier to calculate an intercept point along its orbital path by predicting its future position when the ship arrives at it. Instead of chasing the planet, you use a collision course intercept.
 
Wouldn't the planet be on an orbit circling the star?
It is, but you're arriving at least 100D away from said planet. So that's the problem we're trying to solve. "Given that I have to arrive 100D out, where should I pop out of space in regards to my destination."

I can see how the L2 point could be better, I just not familiar with the math to demonstrate it. The math for the synthetic 1D problem was eye opening in itself. Very surprised to see the trailing arrival to be more efficient. That was not intuitive.
 
But in working out some scenarios on Chat GPT it turns out that L2 is the best place to Jump into.

Maybe I'm wrong, but aren't L2 points (both, sun-Earth and Earth-Moon) inside the 100 D jump limit in Solar System?

If so, they are ruled out as jump arrival point...
 
Maybe I'm wrong, but aren't L2 points (both, sun-Earth and Earth-Moon) inside the 100 D jump limit in Solar System?
The 100D jump shadow of Sol lies at 0.94 AU.
L1 is 1.5 million km / 0.01 AU closer to Sol than Terra and thus lies at 0.99 AU from Sol ... outside the jump shadow of Sol.
L2 is 1.5 million km / 0.01 AU farther from Sol than Terra and thus lies at 1.01 AU from Sol ... outside the jump shadow of Sol.

The 1D of Terra is 12,800 km.
Therefore, the 100D jump shadow of Terra is 1,280,000 km ... which is smaller than the distance from Terra either L1 or L2 @ 1,500,000 km.
Maybe I'm wrong
I'll let someone else break the news to you. 😅



However ... you're not entirely wrong ... because depending on star system orientations, the 100D jump shadow of Sol CAN BE interposed between a system of origin and Terra, depending on where Terra lies within the orbital ephemera of a year.

So if Terra is "in orbit on the far side of Sol" from the perspective of the star system of origin for a jump, such that in order to reach Terra (via straight line from origin to destination) it needs to PASS THROUGH the jump shadow of Sol to reach Terra (via secant line across the circle/sphere), then YES ... the jump shadow of Sol would block a "direct" path to either L1 or L2 of Terra because the jump shadow of Sol is "in the way" from the jump point of origin.

In that case, potentially "quite a lot" of maneuvering (possibly multiple days of it!) would be necessary to accelerate AROUND the jump shadow to reach the Terra-Luna system @ 1 AU from Sol.

It all depends on where Terra is in orbit and if the planet is being occulted/blocked by the jump shadow of Sol.
 
Last edited:
The 1D of Terra is 12,800 km.
Therefore, the 100D jump shadow of Terra is 1,280,000 km ... which is smaller than the distance from Terra either L1 or L2 @ 1,500,000 km.

Well, I don’t know how to calculate it, but, according Wikipedia, the L2 point on the Sun-Earth relation is at 151.1 x 109 meters (measured from the center of gravity of the larger body, so from the Sun), so about 151.1 million kilometers. Main distance from Earth to sun (1 AU) is 150 million kilometers, so L2 point is about 1.1 million km from Earth, so, just under the 100 D limit, that, as you say, is 1.28 million km…

On the relation Earth-Moon, the L2 point is, according the same page, 0.4489 x 109 meters, so about 0.45 (let me round it) million Km, well inside the 1.28 million km that mark the 100 D limit…

So, if Wikipedia is right (and I have no reason to believe otherways), both L2 points are unusable as jump exit points...
 
It is, but you're arriving at least 100D away from said planet. So that's the problem we're trying to solve. "Given that I have to arrive 100D out, where should I pop out of space in regards to my destination."

I can see how the L2 point could be better, I just not familiar with the math to demonstrate it. The math for the synthetic 1D problem was eye opening in itself. Very surprised to see the trailing arrival to be more efficient. That was not intuitive.
I'd solve it by:

Draw a 100D circle around the planet.
Draw the circle(ish) orbit of the planet.
You know the speed of the planet along the arc of its orbit.
You know the speed of the ship and the time it should take to reach the planet if it weren't moving. Remember to account for gravity too!
Create an arc segment for the planet's motion for the time above.
The line along the leading edge of that arc segment (eg, the point from where the ship arrives at 100D and where the planet will be when the ship gets there should be the shortest time.
 
Last sentence of paragraph 5 from the top of the link provided says ... (emphasis added for clarity).

I guess the difference is due to 1 AU being in fact, if not rounded, and according the same table 149.598 million km, and so the 151.1 million means the distance from earth to be 1.502 (so keeping with your comment). Then, its (barely) usable as jump exit point, but I'm not sure about other planets, and so about what would happen in other systems...

We're not talking only about Solar System.
 
I guess the difference is due to
A problem with math and ESL.
You provided the link ... so I'm going to point you right back at it ... and show you what you're missing.

Wikipedia: Lagrange Point
Have a screenshot AND and quote (with relevant text bolded for emphasis).

3FLUvv7.png


L1 point​

The L1 point lies on the line defined between the two large masses M1 and M2. It is the point where the gravitational attraction of M2 and that of M1 combine to produce an equilibrium. An object that orbits the Sun more closely than Earth would typically have a shorter orbital period than Earth, but that ignores the effect of Earth's gravitational pull. If the object is directly between Earth and the Sun, then Earth's gravity counteracts some of the Sun's pull on the object, increasing the object's orbital period. The closer to Earth the object is, the greater this effect is. At the L1 point, the object's orbital period becomes exactly equal to Earth's orbital period. L1 is about 1.5 million kilometers, or 0.01 au, from Earth in the direction of the Sun.

L2 point​

The L2 point lies on the line through the two large masses beyond the smaller of the two. Here, the combined gravitational forces of the two large masses balance the centrifugal force on a body at L2. On the opposite side of Earth from the Sun, the orbital period of an object would normally be greater than Earth's. The extra pull of Earth's gravity decreases the object's orbital period, and at the L2 point, that orbital period becomes equal to Earth's. Like L1, L2 is about 1.5 million kilometers or 0.01 au from Earth (away from the sun). An example of a spacecraft designed to operate near the Earth–Sun L2 is the James Webb Space Telescope. Earlier examples include the Wilkinson Microwave Anisotropy Probe and its successor, Planck.

Please ... stop getting your math WRONG. :mad:
It's NOT HELPING. :mad::mad::mad:

1 - 0.01 = 0.99
1 + 0.01 = 1.01
Check my math if you don't/can't believe what I'm telling you. 😅
 
Please ... stop getting your math WRONG.
Then, please, tell me where I did get my math wrong, so I will learn...

I just pointed that the difference may be because I dubtracted from the sitance L2 to sun the rounded AU (150 Mkm), while in fact it's a little less (149.598 Mkm), and so you were right in pointing the 1.5 Mkm against the 1.1 I initially said. Even If I reached the mumber myslef, instead of taking it from the text, where do my math fail there?

And, just to say what this is not a general case, if you take the example of Venus, the table tells main distance to be 108.21 Mkm (this time I will not round, to avoid the same problem), and L2 to be 109.22 Mkm, so distance from Venus to its L2 point to be 1.01 Mkm. As Venus radius (again according it Wiki entry) is about 6051 km, so its diameter is abour 12100 km, and its 100 D jump limit about 1.2 MKm. So, in this case, L2 would not be able to be used as jump exit point.

Why would anyone want to jump to Venus? I don't know, but it's an example that not every planet can use L2 as jump arrival point, as in some cases it may well be inside its 100 D limit, that was my point from the begining, even if in the case of Earth it could.
 
The line along the leading edge of that arc segment (eg, the point from where the ship arrives at 100D and where the planet will be when the ship gets there should be the shortest time.
Now, mind, I have not drawn this out, but right off the bat, this does not account for velocities and acceleration. Intercept (same place, same time) is actually rather straightforward. Rendezvous (same place, same vector, same time) is a completely different problem.

And the 1D math does not readily scale up into the 2D space, complexity goes, well, ballistic.
 
Now, mind, I have not drawn this out, but right off the bat, this does not account for velocities and acceleration. Intercept (same place, same time) is actually rather straightforward. Rendezvous (same place, same vector, same time) is a completely different problem.

And the 1D math does not readily scale up into the 2D space, complexity goes, well, ballistic.
Essentially, the problem is similar to a surface-to-air missile intercepting a target. I was simplifying some, but you can do it using a polar or Cartesian set of mapping. With two points, the ship and the planet, you are always 2D, it's just how you arrange the points on either a circle or x-y coordinates.
 
Back
Top