Read the following-:
a) Bomber's path xb(t), yb(t) for t=0,1,2...12
b) initial position of fighter xf(0) and yf(0)
c) fighter's velocity vf
while(1)
{
dist(t)=sqrt((xb(t)-xf(t))²+(yb(t)-yf(t))²)
if dist<=10kms=>print target caught at time "t"mins and distance "dist" kms=>stop
else if t>11=>print "target escaped"=>stop
else
cos(th)=[yb(t)-yf(t)]/[dist(t)]
sin(th)=[xb(t)-xf(t)]/[dist(t)]
t=t+1
xf(t)=xf(t)+vf*cos(th)
yf(t)=yf(t)+vf*sin(th)
}
But by " semantic by running" you can switch to debug mode and go through it step by step to check the values to ensure you didn't over flow them or miscalculate. You can analyse all you want but a mistake may not show until you do acutal test. I think if you were to run this code the ships would jump all over the place and display random data, which is correct if thats what you want to do.
also maybe its just me but i dont understand why you are using (t), are you keeping each of the values for somthing or are there multiple planes? you are going to overload your memory doing this too much.
and what is (th)?
and does the bomber ever move?
and i dont think you are using the dist calculation properly, but that could be me.
actually psudo code is ment to be more in english, to express exactly what is to be done, i can see here you are attempting to calculate vectors and positions and causing a little motion but thats about it.
I would reccomend to think of psudo code as the comment lines before you do the actual code.
Read the following-:
a) Bomber's path xb(t), yb(t) for t=0,1,2...12
b) initial position of fighter xf(0) and yf(0)
c) fighter's velocity vf
while(1)
{
dist(t)=sqrt((xb(t)-xf(t))²+(yb(t)-yf(t))²)
if dist<=10kms=>print target caught at time "t"mins and distance "dist" kms=>stop
else if t>11=>print "target escaped"=>stop
else
cos(th)=[yb(t)-yf(t)]/[dist(t)]
sin(th)=[xb(t)-xf(t)]/[dist(t)]
t=t+1
xf(t)=xf(t)+vf*cos(th)
yf(t)=yf(t)+vf*sin(th)
}
then this bit, is just getting the difference of the two positions and normalizing it, then the fighter is attenuating his position with it, vf being the speed of the fighter.
that last bit should be
xf(t)=xf(t-1)+vf*cos(th)
cause u need to grab the last position off the last time frame, not that its that important cause u probably wouldn't want to keep a history of values anyway.
This looks like good code to put into analogue hardware!!! (transistors or opamps!!!)