Results 1 to 9 of 9

Math Help - How to shoot Venus and Jupiter

  1. #1
    Newbie
    Joined
    Jul 2010
    Posts
    5

    How to shoot Venus and Jupiter

    Hi, I'm not sure if I'm posting this in the correct place so if not I would appreciate being told where I should be posting.

    I am making a computer game and I need some help figuring out an equation which the AI can use to help it know which direction to shoot at any given point in time.

    The best way I can describe the problem is probably to talk about it in terms of the solar system so here goes....

    We are working in 2d and our view is from 'above' the solar system so that if we drew lines following the planets, it would look like the sun was in the middle with concentric circles around it where the planets orbit.

    To make the problem simpler, imagine that the orbits of the planets around the sun are perfectly circular (not elliptical), that we can ignore gravitational effects and similar phenomena and that all objects in our model (the planets and rocket) move at a constant speed.

    Now, imagine that we want to shoot a rocket from the Earth and hit another planet with it. The target planet may have a smaller orbit than Earth or a larger one (could be closer to the sun or further away). It may also be travelling towards us or away from us. At any point in time, we know the exact location of the target planet (the radius of its orbit around the sun and where it is in that orbit) and the speed it is travelling through space (including whether it is travelling towards us or away from us). Similarly, we know the exact location of Earth and the speed it is travelling through space (although we won't need to use Earths speed in this problem). We also know the exact speed the rocket will be travelling at (remember we are ignoring gravity, etc., the rocket travels at a constant speed from when it is fired to when it impacts the target).

    For any point in time, I would like to know how to work out which direction we need to fire the rocket in order to hit the target planet?
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Super Member Bacterius's Avatar
    Joined
    Nov 2009
    From
    Wellington
    Posts
    927
    Hello !

    First let the constant velocity of your planets be c expressed in metres per second. Let the velocity of the rocket be c' expressed in metres per second.

    Now let us consider only the target planet, the earth and the rocket. The rocket is fired from the earth and keeps a constant velocity throughout the journey until it eventually hits the target planet. For simplicity we will consider the target planet as being a point in space, and the rocket will hit this exact point (so no need for radius considerations).

    So if you represent this as a diagram, you will get the earth moving in a concentric circle, and the target planet moving in a "curved parallel" fashion. Now here is the problem : the two planets move at the same time, but they don't keep a relative position to each other. We'd better consider that the Earth is located at the origin, because then the target planet is essentially rotating around the Earth at a constant velocity (since we have perfectly concentric circles).

    First step is to find the constant velocity of the target planet relative to the Earth. This is quite easy, if we assume the Earth has radius r in metres, and assume the rocket is aiming for the center of the target planet, then we know when the Earth has completed a half-rotation, the target planet will also have completed a half-rotation. Since the Earth has velocity c \ m/s, and travelled exactly \pi r metres during this half-rotation, then we have t_{\textrm{rotation}} = \frac{\pi r}{c} seconds. Now that is also the time taken for the target planet to rotate, and since its distance to the Earth is also known and denoted by r', we have v_{\textrm{target}} = \frac{d}{t} = \frac{\pi r'}{t_{\textrm{rotation}}} = \frac{r' c}{r}

    So now we know the relative velocity of the target planet. We also know its position relative to the Earth (which is achieved by a trivial origin translation). The next step is to find the distance the rocket has to travel. This is really easy, by using the distance formula. Assuming the target planet center has relative coordinates (x, y), then its relative distance to the Earth is d_{\textrm{target}} = \sqrt{x^2 + y^2}. And since the target planet rotates around the Earth in a perfect circle, this distance is constant.

    Another thing, we know the rocket travels at a velocity of c' \ m/s, so the time taken for the rocket to reach the target will be t_{\textrm{travel}} = \frac{d_{\textrm{target}}}{c'}. Since the velocity and the distance is constant, the time will be constant too.

    Now this is really easier, as we know the velocity of the target planet relative to the Earth, the time that it will take for the rocket to reach it and its distance relative to the Earth. The last thing we need to know is how much distance the target planet travels relative to the Earth during the time the rocket travels, which can be expressed in terms of curved displacement. Since the circumference of its orbit is 2 \pi r', and it takes exactly \frac{\pi r}{c} seconds to travel a half-rotation, it must travel exactly \frac{\pi r'}{\frac{\pi r}{c}} metres per second. Thus its displacement during the time the rocket is reaching its target will be :

    d_{\textrm{displacement}} = \frac{\pi r'}{\frac{\pi r}{c}} \times t_{\textrm{travel}}

    Now what is left to do is calculate the angle of the target planet when the rocket is about to be fired, calculate the angle of the target planet when it has displaced during the time the rocket fired, and that will be the shooting angle for the rocket.

    If the target planet has coordinates (x,y), then it has a relative angle to the Earth of \alpha = \arctan{\left ( \frac{y}{x} \right )}.

    Now, if the target planet has a displacement d_{\textrm{displacement}}, a radius r', and an original angle \alpha, then the new angle (after displacement) will be equal to \alpha + \frac{d_{\textrm{displacement}}}{r'}.

    Conclusion

    It turns out most of this stuff cancels out when putting it all together, so we really find ourselves with a simple formula at the end of the day :

    - c is the constant velocity of the Earth
    - c' is the constant velocity of the rocket
    - r is the radius of the Earth
    - (x, y) are the coordinates of the target planet relative to the Earth

    The rocket will hit the center of the target planet, spot on, if and only if the rocket is fired at an angle of :

    \alpha = \arctan{\left ( \frac{y}{x} \right )} + \frac{c \sqrt{x^2 + y^2}}{r c'}

    All of this in radians, of course !

    Note that this formula, if it turns out to be correct (which I hope it will be !), and if applied properly, will effectively make the rocket do a bull's eye on the target planet, it cannot possibly handle other planets getting into the way of the rocket ! If you need to handle that too, I'm afraid it is going to be quite complicated, especially if the target planet is far away. Well not that complicated actually, if you follow my reasoning you would naturally be computing the displacement of the other planets susceptible of blocking the rocket, and checking whether they can potentially get into the way of the rocket, and if yes, then delay the shot for a bit, then recheck (you can't just shoot elsewhere, you probably won't even hit the target planet)

    Also note that it would be foolish to stupidly attempt to implement this formula in your computer game, as it will probably have to do a couple of precomputations, such as translating the global coordinate system so that the Earth is the origin, and putting everything in radians ... well anyway, I suggest you really try to understand how it works. There's a lot of steps but once you get the idea it's really simple, the hardest part being to manipulate it all at once
    Last edited by Bacterius; July 15th 2010 at 10:32 PM. Reason: Small mistake
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie
    Joined
    Jul 2010
    Posts
    5
    wow, thanks a lot.

    it's been a long time since i did any maths so it's gonna take me a little while to digest all of this but i'll get there eventually! you say to imagine earth as the origin so the target is moving around it, will it still work if the target has a smaller orbit than the Earth?

    thanks for your help
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Super Member Bacterius's Avatar
    Joined
    Nov 2009
    From
    Wellington
    Posts
    927
    Yes, as long as we have perfect concentric circles then the target planet will revolve around the Earth in a circular shape, regardless of their respective orbit sizes. However, if we have more various orbits (like ellipses and circles together) then it gets hellishly complicated ... In fact all of I wrote here is only valid (and relatively easy) because we are working with circles which are simple objects.
    Follow Math Help Forum on Facebook and Google+

  5. #5
    Newbie
    Joined
    Jul 2010
    Posts
    5
    ok, i'm gonna spend some time really getting to grips with this.

    thanks again
    Follow Math Help Forum on Facebook and Google+

  6. #6
    Super Member Bacterius's Avatar
    Joined
    Nov 2009
    From
    Wellington
    Posts
    927
    Okay, feel free to ask if you have any further questions
    Follow Math Help Forum on Facebook and Google+

  7. #7
    Newbie
    Joined
    Jul 2010
    Posts
    5
    Ok, so I don't understand why you say that the target planet completes a half rotation of its orbit in exactly the same amount of time as the earth and therefore the distance between the 2 is constant. The earth and the target orbit the sun at different speeds and complete their respective orbits in different amounts of time so the distance between the 2 is constantly changing which surely also means that the relative velocity of the target to the earth is also constantly changing. Also, in the concluding equation, should c represent the velocity of the target planet? (you have written that c represents the velocity of earth but it is the target planets displacement that will affect the result)
    Follow Math Help Forum on Facebook and Google+

  8. #8
    Super Member Bacterius's Avatar
    Joined
    Nov 2009
    From
    Wellington
    Posts
    927
    Hello,
    imagine the two planets rotating in different (yet concentric and circular) orbits around the sun. Now forget the sun and look at the two planets rotating in orbit. What do you notice ? I can draw a diagram if this can help you.

    Also, in the concluding equation, should c represent the velocity of the target planet? (you have written that c represents the velocity of earth but it is the target planets displacement that will affect the result)
    The velocity of the target planet is linked to the velocity of the Earth as a function of its coordinates relative to the Earth, which is taken in account (at the best of my knowledge) in the concluding equation. But note that the concluding equation as I state it is fully simplified, this is why it may seem not obvious. I'll check over my work another time just to be sure, taking in account your comments.
    Follow Math Help Forum on Facebook and Google+

  9. #9
    Newbie
    Joined
    Jul 2010
    Posts
    5
    Sorry, been working a lot recently but got 10 days off now!

    I still haven't managed to translate this into what I need. Maybe I have miss-interpreted your information so I will take a good look through it all again and see if I can understand it all a bit better. If you have the time to check through it again though, that would be great.

    Thanks
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Replies: 2
    Last Post: December 9th 2010, 10:42 AM
  2. Help with elliptical path of Jupiter around the sun.
    Posted in the Trigonometry Forum
    Replies: 3
    Last Post: January 4th 2010, 06:47 AM
  3. Planet Venus
    Posted in the Algebra Forum
    Replies: 2
    Last Post: December 22nd 2008, 09:58 PM
  4. Gravity on Jupiter
    Posted in the Pre-Calculus Forum
    Replies: 4
    Last Post: January 19th 2007, 05:45 AM

Search Tags


/mathhelpforum @mathhelpforum