Computer Science Canada Question : Finding the closest intersection point for two moving objects |
Author: | TerranceN [ Tue May 25, 2010 8:16 pm ] |
Post subject: | Question : Finding the closest intersection point for two moving objects |
Since this is not language specific I figured I would put this here. Explanation of Question For my geometry wars clone, I am trying to create an enemy that can cut the player off instead of just following the player. Here is a diagram of the problem: ![]() P is the position of the player Vp is the velocity of the player Ω is the angle the player is moving in standard position (this is why I drew the horizontal lines) E is the position of the enemy Ve is the velocity of the enemy Θ is the angle the enemy is moving in standard position I is where the interception will occur t is the time it takes for the enemy to intercept the player Things I know: P Vp Ω E Ve Things I don't know: Θ I t My question is how would I go about finding any of the unknowns (once I know one it is easy to plug that in to the equations I know (see below)). What I Have Tried I started off with some equations that I know are true (note that I split 2d points into their x and y components): ![]() The next thing I did is try to remove an unknown by isolating t in two different equations (I'm only showing one cause the other is the same rearranging but it is y instead of x and sine instead of cosine): ![]() then I set the two equations equal to each other: ![]() Then I tried to solve for Θ using this equation solver, but it told me that it is not solvable. I then tried the same precess, but isolating Θ in two different equations and trying to solve for t: ![]() ![]() But once again this is unsolvable. I don't know what to do from here, and this problem has stumped my MSIP teacher (who is a math teacher), any help will be rewarded with bits and a solution (or something that directly leads me to one) will be rewarded with karma. |
Author: | The_Bean [ Tue May 25, 2010 10:50 pm ] | ||
Post subject: | Re: Question : Finding the closest intersection point for two moving objects | ||
Potentially found a solution for the unknown angle. Everything else should be simple after that. Starting with this diagram (messed up one variable from yours) ![]() Using the sin law, t can be easily removed ![]() where ![]() finally tan inverse has to be modified for quadrents. and heres a very basic example in turing. (black=player , red=enemy)
|
Author: | TerranceN [ Wed May 26, 2010 6:18 am ] |
Post subject: | RE:Question : Finding the closest intersection point for two moving objects |
Thanks! I will try this solution today, but from what I have read in your post and seen in your example it is exactly what I was looking for. +1 Karma +100 Bits |