I want to try create charts or animation Pursuit Curve. I coped code from this file but it doesn’t work. I have no idea why.
Unit[l_] := l/Sqrt[l.l]
PursuitCurve[a_, p0_, {t_, t0_, t1_, dt_}, r_: 1., opts___] := Module[
{
soln, curve,
x, y, f
},
soln = NDSolve[{
Unit[a - {x[t], y[t]}].{x'[t], y'[t]} == 1,
x'[t]^2 + y'[t]^2 == 1,
x[0] == p0[[1]],
y[0] == p0[[2]]
}, {x[t], y[t]}, {t, t0, t1}];
targetpath = ParametricPlot[a, {t, t0, t1},
DisplayFunction -> Identity][[1]];
curve = ParametricPlot[Evaluate[{x[t], y[t]} /. soln], {t, t0, t1},
PlotRange -> All, AspectRatio -> Automatic,
DisplayFunction -> Identity,
PlotStyle -> Red][[1]];
d = D[a, t];
movie = Show /@ Table[Graphics[{
Arrow[a, a + r d],
{Thickness[.02], targetpath},
{Dashing[{1, 1} .02], Blue,
Line[{pt = {x[t], y[t]} /. soln[[1]], a}]
},
{Red, curve},
{PointSize[.08], Point[a]},
{Blue, Arrow[pt, pt + r Unit[a - pt]]},
{Red, PointSize[.05], Point[pt]}
},
opts,
AspectRatio -> Automatic],
{t, t0, t1, dt}]
]
PursuitCurve[{0, t}, {1, -1}, {t, 0, 2, .05}, .2,
PlotRange -> {{-.1, 1.1}, {-1.1, 2.1}}]
