Calculate Intersection Point for Shooting Drifting Ship in Video Game

  • Thread starter Thread starter Rythious
  • Start date Start date
  • Tags Tags
    Homework
AI Thread Summary
To calculate the intersection point for shooting a drifting ship in a video game, one must derive the ship's velocity from two sets of coordinates collected over time. The turret's position and bullet speed are also essential for determining the firing line. A successful intercept requires that the flight time of the bullet equals the flight time of the ship, leading to the equation |HS|/vs = |HT|/vb. This results in a quadratic equation that can be solved by eliminating one variable, typically y, using the ship's trajectory. It’s important to check for valid roots to ensure the intersection point is on the ship's forward path.
Rythious
Messages
1
Reaction score
0
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 traveling speed and the ships traveling speed.
 
Physics news on Phys.org
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).
 
Thread 'Collision of a bullet on a rod-string system: query'
In this question, I have a question. I am NOT trying to solve it, but it is just a conceptual question. Consider the point on the rod, which connects the string and the rod. My question: just before and after the collision, is ANGULAR momentum CONSERVED about this point? Lets call the point which connects the string and rod as P. Why am I asking this? : it is clear from the scenario that the point of concern, which connects the string and the rod, moves in a circular path due to the string...
Thread 'A cylinder connected to a hanged mass'
Let's declare that for the cylinder, mass = M = 10 kg Radius = R = 4 m For the wall and the floor, Friction coeff = ##\mu## = 0.5 For the hanging mass, mass = m = 11 kg First, we divide the force according to their respective plane (x and y thing, correct me if I'm wrong) and according to which, cylinder or the hanging mass, they're working on. Force on the hanging mass $$mg - T = ma$$ Force(Cylinder) on y $$N_f + f_w - Mg = 0$$ Force(Cylinder) on x $$T + f_f - N_w = Ma$$ There's also...

Similar threads

Replies
15
Views
3K
Replies
98
Views
7K
Replies
4
Views
3K
  • Poll Poll
Replies
12
Views
2K
2
Replies
52
Views
7K
2
Replies
96
Views
9K
Replies
7
Views
510
Back
Top