Message Boards Message Boards

Plot chase curve

Posted 4 years ago

I'm currently investigating the following problem: Adam cycles along the y axis with a constant speed. A dog sits 50 meters from the origo on the x axis. When Adam reaches (0,0) the dog notices him and starts chasing him with constants speed, and every one minute the dog would modify the direction of its path so it would point to Adam. I managed to graph the "optimal" case when the dog instantly faces Adam as he moves. (u=is the speed of the dog, v=speed of adam, epsilon=when to the distance of the two is within a threshold so the dog "caught" adam)

{xF, yF} = 
  With[{u = 1, v = 1/2, \[Epsilon] = 1/10}, 
   NDSolveValue[{y'[
       t] == (y[t] - v t) x'[t]/x[t], (y'[t])^2 + (x'[t])^2 == u^2, 
     x[0] == 50, y[0] == 0, 
     WhenEvent[Abs[y[t] - v t] < \[Epsilon], "StopIntegration"]}, {x, 
     y}, {t, 0, \[Infinity]}]];

With[{tmax = xF["Domain"][[1, 2]]}, 
 ParametricPlot[{xF[t], yF[t]}, {t, 0, tmax}]] 

I'm interested in the non-optimal case when there is a "delay" with the casing path of the dog. I think I figured out a way to map the movement of the dog and Adam. In most cases the dog won't reach adam and it will oscillate around Adam. My questions are: Which are those {v,u} speeds when the dog catches Adam within finite time? And is there a way to graph the distances between Adam and the dog?

e = {0, 1};
v = 1; u = 2
F[{A_?VectorQ, B_?VectorQ}] := {A + e*v, B + Normalize[(A - B)] u}
data = NestList[F, {{0, 0}, {50, 0}}, 50]; dataA = 
 data[[All, 1]]; dataB = data[[All, 2]];
POSTED BY: Máté Gigacz

I am not quite sure whether this is what you want.

You can introduce (at least I think so) the delay either by chosing y[0] or the expression for t in yy.

yy = {0, a} (t + 1);
xx = {x[t], y[t]};
dgl0 = {(D[x[t], t] (x[t] D[x[t], t] + (-a t + y[t]) D[y[t], t]))/c ==
     x[t], a t == 
    y[t] + (D[y[t], t] (-x[t] D[x[t], t] + (a t - y[t]) D[y[t], t]))/
     c};
lsg = Solve[dgl0, {D[x[t], t], D[y[t], t]}] /. Sqrt[x_^2] -> x;
dgl2 = Join[lsg[[1]] /. Rule -> Equal, {x[0] == x0, y[0] == y0}];
werte = {c -> 1/2, a -> 1/3, x0 -> 5, y0 -> -1/5};
xvec = {x, y} /. NDSolve[dgl2 /. werte,
     {x, y}, {t, 0, 100}] // Flatten;
Animate[
 Graphics[
  {Red, PointSize[.03], Point[yy /. werte /. t -> tt],
   Blue, PointSize[.025], Point[(#[tt] & /@ xvec)]}, 
  PlotRange -> {{0, 5}, {-1, 10}}],
 {tt, 0, 10}]
POSTED BY: Hans Dolhaine
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract