Calculating distance between two planets in the same system

edited June 2015 in AstroSynthesis General
I'm trying to figure out the time periods in which 2 planets (2nd and 3rd in their system) are within a particular distance X from each other (say, for example, when they are 90 million kilometers or less away from each other).

I imagine there is no one or two-click way to do this, so what I've tried doing is use the Travel Calculator between the 2 planets, plugging in date after date, and jotting down the distance that pops up each time, to figure out when these planets get that close to each other, then drift apart again. (Basically, I want to figure out what the cycle for this event is).

Does this sound like it would work? I tried it a bit yesterday and I got a bit confused. Sometimes the planets at date A look far closer to each other in the orbit view than at date B, yet when I use the Travel Calculator, the distances between them are practically the same for each case. (The third planets' orbits is very eccentric, so it, so to speak, crosses the other's orbit at 2 points.)

Any suggestions or comments would be appreciated.


  • If you don't mind some scripting, there's an Orbit object that can be created in a script that will give you absolute x, y, and z coordinates at a given time. You'd have to 'brute force' the orbits through time to check distances to get the periods when they are within a desired range.
  • I don't mind brute force,I can make the time for it:)

    Thanks for the advice. I'm getting a runtime error with the script below. I tried writing the UABI for the planet I need in SelectBody, also tried putting the name of the planets in quotation marks, but no luck. Any help would be much appreciated!

    sector = GetCurrentSector()
    planet = sector.SelectBody()
    orbit = planet.GetOrbit()

    x = orbit.PositionX
    y = orbit.PositionY
    z= orbit.PositionZ

    MsgBox ("Coordinates X, Y, Z are" & x & "-" & y & "-" & z & ".")
  • Try something like this:
    #plugin	Orbit Example
    #author	NBOS
    #desc	Example of using Orbit class
    Sub DoOrbitStuff
    	body = EditingBody()
    	If IsNull( body) Then Exit Sub  
    	orbit = body.GetOrbit()
    	For i = 1 to 10
    		'set the time of the orbit in days past the epoch (starting point)
    		orbit.SetTime( i)
    		x = round( orbit.PositionX)
    		y = round( orbit.PositionY)
    		z = round( orbit.PositionZ)
    		MsgBox & " at day " & i & " = " & x & " , " & y & " , " & z
    End Sub 	

    This will get the body selected in the system data display, and then report the orbital position for 10 days. You pass the day number into settime(), which updates the orbitals positions, which can then be grabbed with PositionX, etc. The day is the number of days past your sector's 'epoch', or starting date.
  • Ed, this is excellent, thank you. With your explanation I'm able to tweak the days (I'll use "step" to do fractions) as needed. I'll be able to start crunching numbers and figure out the patterns I need. Cheers!

Leave a Comment