8.3.1 The child and the toy

Let us now solve a more general problem and suppose that a child is walking on the plane along a curve given by the two functions of time $ X(t)$ and $ Y(t)$.

Suppose now that the child is pulling or pushing some toy, by means of a rigid bar of length $ a$. We are interested in computing the orbit of the toy when the child is walking around.

Abbildung 8.3: Velocities $ {\bf v}_C$ and $ {\bf v}_T$.
Image gatr1
Let $ (x(t), y(t))$ be the position of the toy. From Figure 8.3 the following equations are obtained:
  1. The distance between the points $ (X(t),Y(t))$ and $ (x(t), y(t))$ is always the length of the bar. Therefore

    $\displaystyle (X-x)^2 + (Y-y)^2 = a^2.$ (8.4)

  2. The toy is always moving in the direction of the bar. Therefore the difference vector of the two positions is a multiple of the velocity vector of the toy, $ {\bf v}_T = ( \dot{x} , \dot{y})^T$:

    $\displaystyle {X-x \choose Y-y}= \lambda {\dot{x} \choose \dot{y}}$   with $\displaystyle \quad \lambda >0.$ (8.5)

  3. The speed of the toy depends on the direction of the velocity vector $ \bf {v}_C$ of the child. Assume, e.g., that the child is walking on a circle of radius $ a$ (length of the bar). In this special case the toy will stay at the center of the circle and will not move at all (this is the final state of the first numerical example.

    From Figure 8.3 we see that the modulus of the velocity $ \bf {v}_T$ of the toy is given by the modulus of the projection of the velocity $ \bf {v}_C$ of the child onto the bar.

Inserting Equation (8.5) into Equation (8.4), we obtain

$\displaystyle a^2 = \lambda^2 (\dot{x}^2+\dot{y}^2) \quad \longrightarrow \quad
\lambda = \frac{a}{\sqrt{\dot{x}^2+\dot{y}^2}}.
$

Therefore

$\displaystyle \frac{a}{\sqrt{\dot{x}^2+\dot{y}^2}} {\dot{x} \choose \dot{y}} = {X-x \choose Y-y} .$ (8.6)

We would like to solve Equation (8.6) for $ \dot{x}$ and $ \dot{y}$. Since we know the modulus of the velocity vector of the toy $ \vert{\bf v}_T\vert = \vert{\bf v}_C\vert\cos \alpha$, see Figure 8.3, this can be done by the following steps: Now we can write the function to evaluate the system of differential equations in MATLAB.
   function zs = f(t,z)
   %
   [X Xs Y Ys] = child(t);
   v = [Xs; Ys];
   w = [X-z(1); Y-z(2)];
   w = w/norm(w);
   zs = (v'*w)*w;
The function f calls the function child which returns the position $ (X(t),Y(t))$ and velocity of the child $ (Xs(t),Ys(t))$ for a given time t. As an example consider a child walking on the circle $ X(t) = 5 \cos t ;Y(t) = 5 \sin t$. The corresponding function child for this case is:
   function [X, Xs, Y, Ys] = child(t);
   %
   X  =  5*cos(t);  Y  =  5*sin(t);
   Xs = -5*sin(t);  Ys =  5*cos(t);

MATLAB offers two M-files ode23 and ode45 to integrate differential equations. In the following main program we will call one of these functions and also define the initial conditions (Note that for $ t=0$ the child is at the point $ (5,0)$ and the toy at $ (10,0)$):

  % main1.m
  y0 = [10 0]';
  [t y] = ode45('f',[0 100],y0);
  clf; hold on;
  axis([-6 10 -6 10]);
  axis('square');
  plot(y(:,1),y(:,2));
If we plot the two columns of $ y$ we obtain the orbit of the toy. Furthermore we add the curve of the child in the same plot with the statements:
   t = 0:0.05:6.3
   [X, Xs, Y, Ys] = child(t);
   plot(X,Y,':')
   hold off;
Note that the length of the bar $ a$ does not appear explicitly in the programs; it is defined implicitly by the position of the toy, (initial condition), and the position of the child (function child) for $ t=0$.

Peter Arbenz 2008-09-24