1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

No exactly homework

  1. Jul 3, 2007 #1
    I didn't know where else to place this as I have yet to do the work, but I want to, I just don't know what formulas I need. I've been out of school for a while and can't remember or can't figure out all the formulas I need so I'll tell you my problem and if someone could just post the relevant equations I'd like to solve the problem myself.

    I used to play this video game which was a top down space shooter, you controlled a ship which would drift if you stopped using the boosters. There was no acceleration (positive or negative) while the boosters weren't used, you'd just drift in a straight line. I wanted to try and program a turret to shoot at these drifting ships. This is all done in virtual space and there is no acceleration at all, even the bullets shot reached their target velocity instantly and remained there. So, here's what I know. Given two times to collect coordinates of the ship, I can formulate the line it's traveling. I already know that part. But knowing the time in between those two captured sets of coordinates I know I should be able to derive the ships velocity. While knowing the coordinates of the turret itself and the speed at which it's own bullets travel, I'm trying to find what line it should fire on to intersect with the ship at the right time. I'm probably forgetting something, but I'm off to work, just wanted to throw this up quick. I'll post in about 16 hours if there's any thing I left out. If you think all the info is there I'd really appreciate someone just posting the formula to calculate which intersection point I could hit given my bullet's travelling speed and the ships travelling speed.
     
  2. jcsd
  3. Jul 3, 2007 #2

    Dick

    User Avatar
    Science Advisor
    Homework Helper

    Ok. Here's one approach. Let the position of the ship be S, the position of the turret be T, position where bullet collides with the ship be H, velocity of the ship=vs and velocity of bullets=vb. It's easiest to talk about this if we choose a special coordinate system, so let S=(0,0), T=(d,0), H=(x,y), now we can write the path of the ship as y=m*x for some slope m. One condition for a successful intercept is that the flight time of the ship is equal to the flight time of the bullet. So set |HS|/vs=|HT|/vb (time=distance/velocity). Squaring both sides gives a quadratic in x and y. Eliminate y (e.g.) from the quadratic by setting y=mx. Solve the resulting quadratic. Bingo. Be sure and check for spurious roots (e.g. the intersection point may be on the reverse path of the ship, not the forward part - there may also be no roots or multiple good roots).
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?