Jump to content

Finding max separation of planets


Syntax

Recommended Posts

@K^2 Whelp, I'm out of ideas at this point. I've learned enough about rotation matrices in the last few days to understand how to reproduce your transformX and transformY functions. I was hoping to find some minor discrepancy that, when resolved, would close the gap between the results. And the rotation matrices I came up with did differ slightly from yours, by a negative sign in the variable z for each. Changing it didn't make any difference at all.

I checked the rotation matrix against the orbits' orientations in my model, and they are visually identical.

As for bignumbers, I don't see how I could apply it in a way that would make any difference at all. I haven't tried it, because honestly I'm not sure where I would.

I've played around with the degree of accuracy in your code, pushing it to the limit of crashing the browser page. No luck there, either. Would a more powerful machine even help, or will the browser always be the bottleneck?

I don't understand why my model and your code agree on the max separation, but disagree on true anomaly. I'll keep thinking on it, but I'm definitely open to more ideas if you've got 'em. Maybe I'm missing something in the max2d or golden function... Again, I'll keep exploring.

Link to comment
Share on other sites

18 hours ago, Syntax said:

I don't understand why my model and your code agree on the max separation, but disagree on true anomaly.

Yeah, I don't see anything that would account for 0.05 radian difference. The steps I use to break down the arc are 0.2, and using golden section pretty much prevents it from getting stuck on 1/4 of that for some numerical reason. It's also not a precision issue, since that's well within even single precision, let alone double. The max2d is set to 10-6 as well, so again, right out.

If you want to try diagnosing it further, try computing positions using your algorithm and the JS code I provided using the same identical orbital elements and a few values for true anomaly between 0 and 2pi. If you get a difference, you can start tracking it back to see which numbers are coming up different in between.

Link to comment
Share on other sites

  • 1 year later...
On 12/5/2018 at 7:10 PM, K^2 said:

Yeah, I don't see anything that would account for 0.05 radian difference. The steps I use to break down the arc are 0.2, and using golden section pretty much prevents it from getting stuck on 1/4 of that for some numerical reason. It's also not a precision issue, since that's well within even single precision, let alone double. The max2d is set to 10-6 as well, so again, right out.

If you want to try diagnosing it further, try computing positions using your algorithm and the JS code I provided using the same identical orbital elements and a few values for true anomaly between 0 and 2pi. If you get a difference, you can start tracking it back to see which numbers are coming up different in between.

I'm sorry to necro this. I thought you might be interested in knowing that I did get to the bottom of this issue some months ago, but haven't done much with the results yet. I'm starting to work on it again... I find myself with more free time lately... Turns out the problem was a silly calculation error on my end, and both your code and my model in fact were returning identical results (long story short, I was conflating true anomaly and eccentric anomaly).

More as an exercise and diversion than anything else, I am now wondering: What would I need to change about the original code to use it to find the absolute minimum distances between two orbits? If I understand correctly, the golden section search you employed is a twist on a method to find local minima. If I could "untwist" it (whatever that might mean), could I employ it in just that fashion? I'm working on trying to reverse engineer it, but my limited background isn't getting me very far very fast. Figured I'd go to the source :)

Link to comment
Share on other sites

Yeah, the golden section search can be used to look for local minima or local maxima. You just have to flip the inequality used to decide whether you pick the left node or the right node inside the iteration. Likewise, the outer loop compares results from golden section for each arc segment to find the global optimum. You'll need to flip that inequality as well. And I don't recall how I initialized the initial best distance. Given that we were searching for maximum, it was probably set to zero. If you're looking for minimum, you should set value to something greater than theoretical maximum. Sum of semi-major axes is absolutely guaranteed to be greater than actual minimum separation, so it's a good choice.

Link to comment
Share on other sites

On 4/22/2020 at 12:50 AM, K^2 said:

Yeah, the golden section search can be used to look for local minima or local maxima. You just have to flip the inequality used to decide whether you pick the left node or the right node inside the iteration. Likewise, the outer loop compares results from golden section for each arc segment to find the global optimum. You'll need to flip that inequality as well. And I don't recall how I initialized the initial best distance. Given that we were searching for maximum, it was probably set to zero. If you're looking for minimum, you should set value to something greater than theoretical maximum. Sum of semi-major axes is absolutely guaranteed to be greater than actual minimum separation, so it's a good choice.

Nice! Thanks! I managed to make it work. I ended up leaving the initial value for the minimum distance unspecified. When I use the code below, the true anomalies spit out at the end were 0 (or whatever value I passed in that initial value array). I couldn't figure out why, as that didn't happen with the max distance array reduction.

const res = distances.reduce((a, b) => a[0] < b[0] ? a : b, [a1 + a2, 0, 0]);

But it worked without that initial value... just thought that was a bit strange. Anyway, thanks so much for your guidance! You've really helped me tie a nice bow on this :)

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...