# Is it possible to detect if orbits intersect or not and positions where they intersect if you know Keplerian elements (2D)?

I have two orbits and I know their Keplerian elements. Is it possible to find positions where two orbits are crossing if those positions exist?

Is it possible to do it if spacecrafts are on orbits of different bodies: i.e. orbit of a spacecraft around the sun and orbit of spacecraft around earth, moon orbit and earth orbit, hyperbolic trajectory of asteroid and spacecraft's orbit around planet.

I need it to create spacecraft collision avoidance algorithm in 2D top down.

• What does "crossing" mean? If the orbits are 2D (i.e. drawn on paper) then intersection is the same as crossing, and it happens when they have the same radius (except when they just perfectly touch (kiss or osculate)). However, what does it mean in 3D? Do they have to lie in exactly the same plane to cross? (i.e. 2D) or does it just mean that which one is closest to the center changes?
– uhoh
Nov 17, 2021 at 10:09
• "it happens when they have the same radius" - it happens when it have different excentricity and semi-major axis. Nov 17, 2021 at 10:22
• "However, what does it mean in 3D? Do they have to lie in exactly the same plane to cross?" I mean to detect intersection where possible the collision between two spacecrafts Nov 17, 2021 at 10:23
• I see so you are asking for more than the points where the orbits intersect. You really want to as about conjunctions which is when the two objects are both at the intersection point at the same time? Something like Algorithmic methods or techniques to find conjunctions in high N Keplerian element ensembles? or perhaps What is the numerical procedure to find the next closest approach between two bodies on keplerian orbits?
– uhoh
Nov 17, 2021 at 13:46
• However you do it, it's called "conjunction detection" and the hardest part about it is that the orbital elements for each has an uncertainty. So there is no single "intersection point". Of course mathematically the chances of two random orbits exactly intersecting is zero. The challenge is that both orbits have uncertainty in their elements, so you really have two clouds of probability passing through each other. I recommend you take a look through those linked pages.
– uhoh
Nov 17, 2021 at 13:56

It's possible to find intersections of orbits around same planet through polar coordinates

In polar view, orbit takes form: $$r(\theta) = \frac{a \times(1-e^2)}{1-e \times \cos(\theta - \phi)}$$

We're looking for intersections, i.e. $$r_1 = r_2$$ :
$$r_1(\theta)=r_2(\theta)$$ $$\frac{a_1 \times (1-e_1^2)}{1-e_1\times \cos(\theta - \phi_1)} = \frac{a_2 \times (1-e_2^2)}{1-e_2\times \cos(\theta - \phi_2)}$$ $$a_1\times(1-e_1^2)\times \bigl(1-e_2\times \cos(\theta - \phi_2)\bigr) = a_2\times(1-e_2^2)\times \bigl(1-e_1\times \cos(\theta - \phi_1)\bigr)$$ $$a_1\times(1-e_1^2)-a_2\times (1-e_2^2) = - a_2\times (1-e_2^2) \times e_1 \times \cos(\theta - \phi_1) + a_1\times(1-e_1^2)\times e_2 \times \cos(\theta - \phi_2)$$ Now this long equation compacts down.
Let $$A$$ be the left side and $$B_1$$ and $$B_2$$ be the coefficients in front of cosinuses: $$A = a_1\times(1-e_1^2)-a_2\times (1-e_2^2)$$ $$B_1 = - a_2\times (1-e_2^2) \times e_1$$ $$B_2 = a_1\times(1-e_1^2)\times e_2$$ Function takes form: $$A = B_1 \times \cos(\theta - \phi_1)+B_2\times \cos(\theta - \phi_2)$$ Both cosines have same frequency, so they can be combined: $$B = \sqrt{B_1^2+B_2^2+2\times B_1\times B_2\times \cos(\phi_1-\phi_2)}$$ $$\Phi = arctg(\frac{B_1\times \cos(\phi_1)+B_2\times\cos(\phi_2)}{B_1\times \sin(\phi_1)+B_2\times\sin(\phi_2)})$$ And we get $$A = B\times \sin(\theta-\Phi)$$ From which $$\theta = \arcsin(\frac{A}{B})+\Phi$$ (arcsin can get 0,1 or 2 roots) From that you can get $$r = r(\theta)$$ and from both polar coordinates you can get position in whatever form you need.

As for "orbits around different bodies", usually it is solved by moving objects "between spheres of influence" (think KSP), so only same-body orbits can collide.
Otherwise, ellipse-ellipse collision can be probably approximated via bounding rectangle (if you don't track it already for drawing, it is found via cartesian function of ellipse: focus is at $$x = -e\times a$$, $$y = 0$$; bounds of rectangle are at $$x = \pm a$$ and $$y=\pm a\times \sqrt{1-e^2}$$, return to global coords via rotation matrix and body coordinate offset)
And rectangle-rectangle collision check is either AABB or 4x4 line_segment-line_segment checks.

• FWIW, for two planes around the same primary, you can find the line where the planes intersect from the cross product of the normals of the planes. Nov 18, 2021 at 2:27
• @PM2Ring what planes? isn't the question about 2D? Nov 18, 2021 at 2:48
• I admit that it's not not totally clear from the way this question is written, but from their other questions on this topic I'm pretty sure that the OP wants to find any possible collisions. However, they're working with a 2D top-down view. Nov 18, 2021 at 3:05
• Will this trick work with hyperbola and hyperbola intersection? Nov 24, 2021 at 9:37
• @Robotex Intersection of polar coordinates should work the same... I guess there can be a problem if intersection is in the "negative" second arc of hyperbola -> you'll need to add a check that $r(\theta) > 0$ at the end Nov 28, 2021 at 13:48

Where the orbits cross is only part of assessing collision probability. You also have to know the time at which the two spacecraft reach the same point. Unless the crossing happens at the same time both spacecraft are there, no collision can happen.

For example, it is perfectly safe to put multiple satellites in identical orbits, but separated from each other by a small amount of time. This is exactly what is done in many operational constellations, the most extreme of which is StarLink. They have sixty satellites sharing each orbit, but they will never collide because they are spaced equally around the circle and all moving at the same speed.

Similarly, multiple sets of circular orbits can cross each other safely, as long as the satellites in each plane are phased properly. For example, again picking on StarLink, six circles of sixty satellites can all cross at one point and still keep at least 1 degree separation between them, if one circle goes through the crossing at 0, 6, 12... degrees of mean motion, the next at 1, 7, 13..., the next at 2, 8, 14... etc. The standard way to design one of these is the Walker Star constellation.

Different semi-major axis or different eccentricity can each alone cause collision, depending on the time phasing. Both together don't have to cause it, depending on orbit planes and time phasing. Orbits in different planes can and do cross, and have historically caused actual collisions. The trouble with collision avoidance (also called conjunction assessment) is that Kepler's equation, which describes the time behavior, is not analytically solvable for non-circular orbits. Therefore, you can't avoid having to do some numerical solution, and you quickly discover that you can't predict probability of actual collision without a good propagator and a good covariance estimate.

• you managed to say "this question is stupid and more complex version of it is impossible" and at the same time did not answer the question itself... wonderful Nov 17, 2021 at 21:39
• @NooneAtAll no, I said this question is incomplete, but here are some of the other things you need to consider if you want to make a useful tool for yourself. Nov 17, 2021 at 22:07
• True, you can't invert Kepler's equation $M=E-e\sin E$ analytically. But if you know the eccentric angle $E$ of a potential collision point then it's easy to get the mean anomaly $M$, and hence the time that the body reaches that angle. Of course, in reality it's more complicated because actual Solar System bodies and spacecraft don't have unvarying Keplerian elements, and the elements we do have aren't precise down to the dimensions of a spacecraft. Nov 18, 2021 at 2:22
• Looks like, this position can be found by solving system of two ellipses equations. And time can be found by formula of orbital period because we know initial position and position of intersection Nov 24, 2021 at 9:35
• Yes, that works, but only if your orbits are actually ellipses. If you have a spacecraft orbiting a non-spherical Earth, or one with density variations (e.g., oceans vs. mountains), or the Sun or Moon exists, or you account for drag or solar radiation pressure or many other real-life effects, you will find that the resulting orbits are not ellipses, and don't exactly repeat, so you will need to program or learn to use a differential equation solver (almost every one of which you meet will be a wrapper around some old Fortran) to determine both the orbits and the times numerically. Nov 24, 2021 at 23:09