Edge cases are evil!

So, I’m in the middle of putting together a bunch of code under a project called “Project Navigator”. Navigator is supposed to help me perform astrodynamics calculations.

While the math involved has been easy, the programming has been a nightmare. Why? Edge cases. I don’t know how many times I thought I was almost done, only to have some obscure numerical condition come up to bite me. If there are hyperbolic transfers, I need code to handle all the period counters to make sure I don’t wander off to infinity in a finite time. I also need to be able to integrate clockwise and counterclockwise around the conic section without bridging any critical angles.

My prior attempt at solving for transfer orbits attempted to avoid all this minutia by running a generalized solver to fit one conic section to bridge the departure and arrival points of the other two. Unfortunately, there are all sorts of perverse local minima lurking in configuration space which my solver delighted in bombing out on. It was also waaay to slow.

Okay, so I did some math and worked through everything on the plane with only one variable. I finally managed to beat all those problems into submission. Only I didn’t. When I tried to map the projected orbit back into three dimensions, I discovered that there was something screwed up about the projection – now there *are* no angles I can pick to match the transfer plane to the departure and arrival points, and I have no idea why, because I quadruple checked my rotation matrices and angle math.

I attempted a C3 plot of the delta-v for departure to Mars. See that blob? It’s supposed to be relatively contiguous, with two minima. Instead it is cut up, folded over, and scattered all over the plot.

Gaah!

I spent an entire week trying to *fix* all the bugs. At this point I’m not learning anything new, I’m just bogging down trying to find out why the code is blowing up.

The most galling thing is that none of this *should* be difficult. It shouldn’t require 4000 lines of code, it shouldn’t need 15 levels of nested if statements to handle everything that goes wrong. I can solve these cases by hand faster than I can via computer!

I’ll take a break, but won’t give up on the project entirely. I seem to have made a few key corrections. It looks (jinx) like I am approaching the end of the fatal bugs.

Comments (0)

› No comments yet.

Leave a Reply


Allowed Tags - You may use these HTML tags and attributes in your comment.

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Pingbacks (0)

› No pingbacks yet.