shooting mars

roleybob

New member
Joined
Jul 21, 2010
Messages
5
ok, so I am making a computer game and i need some help working out an equation.

I think it is easiest to understand the problem if you think of a view of the solar system looking from 'above' (looking from an angle where the sun would be in the middle and you can see each of the planets orbiting it). Now imagine that we want to shoot a rocket from the Earth and hit one of the other planets with it. I need an equation which the AI can use to know which direction to shoot in to hit the target planet. The target planet could have a smaller orbit than the Earth or a larger one so the equation will need to work for both.

To make it easier, we only need to work in 2 dimensions, we are assuming that the planets are orbiting in perfectly concentric circles (not ellipses), the planets can be considered points in space and we can ignore gravity (the rocket moves at a constant speed in a straight line).

At any point in time, we know the position of the Earth and of the target planet (the radius of their orbits and at what point they each are in those orbits) and we know the speed the target is travelling and how fast the rocket will travel when shot.

So, can anyone help with an equation that will tell the AI which direction to shoot the rocket and an explanation so that I can understand it please?
 
IN OTHER WORDS (using gun and bullet!):
you are standing, with a gun, some distance away from a circle;
a point is moving at constant speed along circumference of the circle;
you want to shoot and hit the moving point;
by the time bullet gets there, moving point will have travelled the length of an arc on the circumference:
example: if point travels clockwise and you shoot when point is at 1 o'clock position,
you would be aiming at a point on circumference, something like 1:02 position;
means that point would have travelled an arc of length calculated from its speed during 2 minutes.

YES??

b= speed of bullet shot from gun
p = speed of point travelling on circumference
r = radius of circle
d = distance of gun from circle
A = position of point when gun fired
B = position of point at impact

From time gun fired to impact, point will travel arcAB;
during that time, bullet will travel straight line distance d.
So time to travel d = time to travel arcAB; simple distance formula s = d/t can be used.
Knowledge of how to calculate arc from radius required.

Did you follow that?
Do you agree?
Are you ok now?

Note: may be a little more complicated if bullet path is at an angle;
needed would be how high above shooter is the circle; then use pythagorean theorem.
 
Yes, that is the question and I follow what you are saying but I think that it only works if the position you are firing from is at the origin of the circle. If you are not firing from the origin then the bullet would reach different parts of the circle in different amounts of time as some parts of the circle are closer than others, so I need to be able to work out which part of the circle would make the bullet and the point take the same amount of time to reach it.

thanks
 
roleybob said:
.....but I think that it only works if the position you are firing from is at the origin of the circle.
What d'heck does that mean?

Do you mean the gun is initially horizontally aimed at the CENTER of the circle?
You then need to "angle" it up or down or left or right depending where the target will be?

If so, the bullet's path length will always be the hypotenuse created by the circle's radius
and the distance from gun to center of circle; as example, if radius = 120 and gun distance from center = 160,
then bullet will travel SQRT(120^2 + 160^2) = 200 no matter where aimed at on circumference.

Please clarify. Supply a diagram if you can, or an example; not interested in guessing any further.
 
i dont know how to post diagrams.

if we say that the centre of the circle is position [0,0], the radius of the circle is 10 so one of the points on the circle is [10,0] and the gun is at position [20,0], then the gun is 10 away from the closest part of the circle and 30 away from the far edge of the circle
 
That simple, heyyyyyyyyyyyyy :shock:

Circle center (0,0) has radius = r.
Point G (the gun!) is on x-axis, distance from (0,0) = g ; g > r.
Point P(x,y) is on circle's circumference.
Calculate distance GP.

GP = SQRT[(g - x)^2 + y^2]

Using your g = 20 and r = 10 example; assume P(6,8):
GP = SQRT[(20 - 6)^2 + 8^2] = SQRT(260) = ~16.12

The ball she's now in your court :idea:
 
Right, sorry, have been working a lot over the last few days.

The previous example I posted was just to show how the gun is not the same distance from all parts of the circle.

Firstly, the gun may be at any point on the x and y axes so rather than g > r, distance g may be greater or smaller than r.

I know how to work out GP when P is static, the problem is that point P is moving around the circle so i need to work out the exact position on the circle that the bullet and the point will meet when the gun is fired.

At any given time, we know the exact position of the gun and the point, and we know the speed that the point is travelling around the circle and the speed that the bullet will travel when fired. How do I work out what direction the gun needs to be fired in to hit the point as it moves around the circle?
 
roleybob said:
First, the gun may be at any point on x and y axes so rather than g > r, distance g may be greater or smaller than r.
So the gun can be INSIDE the "circle" ? I guess ON the circle's circumference as well?

QUESTION: if a point travels 11 feet (an arc = 11 feet) along the circumference
of a circle with diameter = 90 feet, how many degrees has it travelled?
 
yes, the gun could be inside the circle or outside the circle. For my needs, it will never be on the circumference but that possibility would not be excluded in the equation

about 14 degrees, why?


EDIT: actually I may need to use the equation in circumstances where the gun is on the circumference after all
 
roleybob said:
about 14 degrees, why?
Correct.
Why?
You gave no indication in your post of where YOU're at ; so didn't know if you understood arcs : central angles.
I had been thinking that a way could be to have the point move in degrees, then convert that to arc lengths;
from there, calculate the related "chord", which would make it easier to calculate the point's position,
as the chord would be a straight line joining the point's 2 positions....but that's just an idea for now...

I don't know how much I can contribute to this: HEY you other helpers here: STEP IN, WILL YA!?
 
Top