Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to predict encounters between a ship and a body's sphere of influence in 2D

Long time listener, first time caller. I'm making a little hobby game in XNA, its about transport ships in space, analogous to container ships at sea. I need to be able to predict the encounter between a Ship and a planet/moons gravitational sphere of influence in a restricted 2D environment. The positions at time of the Ship and planet/moon, Body for short, are determined from keplerian orbital elements. The Ship and Body both orbit the same centre of attraction.

The approach I have devised so far is first to do some preliminary checks on the apoapsis and periapsis (farthest and closest points from centre of attraction) to see if an encounter is possible. Between checks such as this and if the Ship's orbit is open (hyperbolic, I approximate the parabola case to a hyperbola), it can rule out many scenarios where there could not be an encounter.

If these checks determine an encounter is possible, I determine the minimum and maximum distance from centre of attraction that the Ship is eligible for an encounter. I then get the intersection points of the ships orbit with the two circles defined by that minimum and maximum. This results in zero, two, or four, points on the Ship's orbit, defining zero, one, or two periods where it could encounter the sphere of the Body. At this point if there are zero intersections it is possible the whole of the Ship orbit is in the encounter zone, this is probably an uncommon extreme case but would need to be covered.

I can get the times that the Ship will pass those points on it's orbit, giving one or two windows of time to check for encounter, but from there my best solution is searching the time span by dividing it into steps, calculating the Body's position at those times, and then testing for encounter.

The trouble with that approach is knowing the size to make the steps to efficiently find the encounter. Getting the Body's position at time is somewhat expensive so I'd rather do it as little as possible, but steps too large could potentially miss the encounter.

Are there any properties of confocal conic shapes that could help reduce the search space? Or are there other ways to predict encounter/collision between what is effectively a point moving along a conic path and a circle moving along an ellipse sharing a focal point.

like image 682
pagnatious Avatar asked Feb 22 '13 17:02

pagnatious


People also ask

How do you find the sphere of influence?

F=GMmR2 where G is gravitational constant, M is mass of the planet, m is mass of your orbiter and R is the distance between them. To make maps of influences you can use F=MR2 for a planet because G and m are the same for all planets. You can make sphere-of-influence spheres with this formula.

How far out is Earth's sphere of influence?

But very near to the planet, the gravity of the planet becomes stronger than that of the Sun. This region around the planet is referred to as the sphere of influence (SOI), Isro said. The sphere of influence of Earth is 9.25 lakh km. Orbits of the Moon and all the artificial satellites of Earth fall inside this sphere.

What is sphere of influence in space?

A sphere of influence (SOI) in astrodynamics and astronomy is the oblate-spheroid-shaped region around a celestial body where the primary gravitational influence on an orbiting object is that body.

What is gravitational sphere?

Gravitational Sphere of the Planets We now will discuss the gravitational sphere of a planet, by which we mean the region of space within which the attraction of the planet is greater than solar attraction.


2 Answers

Use radial collision detection (circles), with one circle representing the planet's gravity influence (will be larger than the planet itself), another circle for each ship, and cause the center point of each circle to move toward each other in a straight line ever so slightly as the distance decreases.

Apply the amount of pull each circle has to the rate of movement of each ship. Movement can be done with just simple trig, cos() for x, sin() for y, no need for any more complex math. When the distance between any two objects is less than the sum of their radii, then a collision has occurred.

But when doing this form of collision on just the "gravity circles", so to speak, when they collide, you can increase the speed of the ship by a small amount every iteration to simulate the pull of gravity.

like image 80
Jon Harbour Avatar answered Oct 02 '22 15:10

Jon Harbour


You could try constructing the function describing the (square of the) distance between the planet and the ship as a function of time, using the usual Pythagoras distance expression. You are looking for zeros of this function, so Newton's method or similar can be applied to find them.

This should work well provided that the planet's motion is much slower than the ship's -- then the function will be relatively smooth, and Newton's method will have no trouble converging. However if the planet's motion is much faster than the ship's, then this distance function will bounce up and down, like a "spring" superimposed on some parabola-like curve, and will possibly intersect the x axis several times. Newton's method can have trouble with such functions, where the derivative changes direction rapidly.

Hopefully some terms will cancel out when you construct the distance function, or the expression can be otherwise simplified or approximated, but if not it may be sufficient to look for zeros in the vertical and horizontal directions. (You could in fact choose distances along any axis -- e.g. the major axis of the planet's orbit.) Zeros in either of these functions are necessary but not sufficient conditions for collision, and may be simpler to calculate. If you have a list of x-direction zeros sorted by time and the same for y-direction zeros, you can find any true collisions by calculating their intersection with a list merge (a la mergesort).

like image 37
j_random_hacker Avatar answered Oct 02 '22 15:10

j_random_hacker