View Single Post
  #37  
Old August 17th, 2007, 10:14 PM
Suicide Junkie's Avatar
Suicide Junkie Suicide Junkie is offline
Shrapnel Fanatic
 
Join Date: Feb 2001
Location: Waterloo, Ontario, Canada
Posts: 11,451
Thanks: 1
Thanked 4 Times in 4 Posts
Suicide Junkie is on a distinguished road
Default Re: OT: Looking for a good physics site

The acceleration for X will be cos(theta) times the ship's engine power, while the acceleration for Y will be sin(theta) times the engine power.

And theta will be the direction to accelerate in.

So, lets see. (x,y are coords, * is multiplication)
For X:
S1x-S2x = (V1x-V2x) * T + ((A1*cos(Theta)) -A2x) * T * T
For Y:
S1y-S2y = (V1y-V2y) * T + ((A1*sin(Theta)) - A2y) * T * T

Unknowns are Theta and T, common to both.
You can rearrange the first formula to get Theta = F(T)... there will be inverse cos or inverse sin in it.
Replace the Theta in the second equation with F(T).

Now you've got a big horrid, fearsome beasty with only T as an unknown. Solve for T. You'll probably need a big sheet of paper, or maybe maple to simplify it down to a one-line equation to code in.

Plug T into the first formula again, and Solve for Theta.

Your ship/missile can then accelerate in the direction of Theta for time T. (Theta = 0 means the +X direction, 90 degrees = +Y)
Reply With Quote