2
$\begingroup$

Blue is Earth, Red is Mars, Orange is Jupiter, and all the whites are Earth to Mars trajectories.

Blue is Earth, Red is Mars, Orange is Jupiter and all the whites are Earth to Mars trajectories. The odd trajectory lines in the middle are the problem I'm trying to solve.

As you can see in the image, I have a good Kepler solver (in fact I've implemented 3 while debugging this trajectory problem, to ensure that wasn't where the issue was). But in using the Gauss Problem/Method to calculate trajectories given the position of Earth at launch time, the position of Mars at arrival time, and travel duration, there are times when the solution results in a semi-major-axis with a negative value.

My main resource for the Gauss algorithm has been this site: http://www.braeunig.us/space/interpl.htm.

Reading http://www.braeunig.us/space/orbmech.htm, it seems that the semi-major-axis is negative for hyperbolas and that hyperbolas are used when the ships velocity is strong enough to escape the gravity of its primary. So perhaps my problem isn't that my Gauss solver and Kepler to cartesian are wrong, but that the trajectory I'm trying to solve requires a different type of solution?

I think it really comes down to the question What do I do when the semi-major-axis is negative? Is there a different set of equations to get the orbital mechanics (and then convert to cartesian coordinates) for hyperbolic transfers?

$\endgroup$
11
  • 2
    $\begingroup$ If you remove the details about orbits and limit yourself to the problem of failing to fit conic sections (i.e. getting an illegal semimajor axis), you'll find this is exactly a pure coding problem. $\endgroup$ Commented Mar 3, 2020 at 14:14
  • 1
    $\begingroup$ There are one or two "please debug my space exploration code for me" questions here a year, and their problems are almost never resolved here. $\endgroup$
    – uhoh
    Commented Mar 3, 2020 at 14:54
  • 5
    $\begingroup$ I think the site should be more lenient with programming questions if the essence of the problem is about astronomy and not programming, and I feel a strong motivation to vote it so. However, your problem looks like a "debug my code for me" problem. This is nowhere welcomed, not on the StackOverflow and not here. I click now "Skip" (this is a moderation vote, what to do with your question), but please improve your post ASAP. $\endgroup$
    – peterh
    Commented Mar 3, 2020 at 15:08
  • 3
    $\begingroup$ @lancew This is an excellent question because 1) it is fundamental to space exploration. "Buzz" Aldrin acquired his nickname for his incessant talk of orbital mechanics. He did his doctoral thesis on orbital rendezvous techniques at MIT. 2) It points up the paradigm shift in engineering and science brought about by digital computers. Assuming closed form solutions to differential equations is no longer required. $\endgroup$
    – DrBunny
    Commented Mar 3, 2020 at 18:21
  • 3
    $\begingroup$ I would say, "Yes, The equations for going from Mean Anomaly to Eccentric Anomaly to True Anomaly are indeed different for hyperbolic orbits than for elliptical ones, if that's part of your process." The biggest differences are sign-flipping on some of the terms, and the use of hyperbolic trigonometric functions rather than the circular trig functions. $\endgroup$
    – notovny
    Commented Mar 3, 2020 at 19:55

1 Answer 1

1
$\begingroup$

Is there a different set of equations to get the orbital mechanics?

The general formulation is a set of coupled ODEs, ordinary differential equations. These equations work just fine. The Gauss algorithm you cited is but one way to approach their solution.

My recommendation is to learn numerical solution methods for integrating the ODEs. In one dimension, this goes something like: initialize velocity v0 and position x0 of your mass m, sum up all the gravitational forces acting F, calculate acceleration a = F/m, increment time by dt, increment velocity by v = v0 + adt, increment position by x = x0 + vdt. Repeat until you get where you are going. WARNING, this is not an efficient numerical method, only the simplest. It requires a very small value of dt to give accurate solutions.

You will find reliable and accurate ODE integrators built into high level languages like MATLAB, and even in MathCAD.

With numerical methods, you do not need to assume a closed-form function that describes your trajectory.

Methods which depend on assuming exact closed-form solutions, like hyperbolas, always rest on assumptions. The website you gave illustrates the complexity of justifying the applicability of the assumptions underlying their method. They require you to estimate "how high is up", i.e., where is the point past which you can ignore Earth or Mars or Moon.

$\endgroup$
3
  • $\begingroup$ That sounds like you're talking about an N-body simulation, which isn't feasible with the number of space objects I want to support in a browser application. I'm familiar with differential equations, but what do you mean by 'coupled'? $\endgroup$
    – lancew
    Commented Mar 3, 2020 at 18:28
  • 1
    $\begingroup$ @lancew There is a discussion of orbital mechanics on this answer, unless you want to stick with Gauss. space.stackexchange.com/questions/41755/… $\endgroup$
    – DrBunny
    Commented Mar 3, 2020 at 18:41
  • $\begingroup$ @lancew The DE is second order, since acceleration is second time derivative of position. The DE is rewritten as a pair of first-order equations, one for v as dx/dt, and another for a as dv/dt. $\endgroup$
    – DrBunny
    Commented Mar 3, 2020 at 18:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.