Hallo David,

> In the second image in this file, I am disappointed to find that the
> vector doesn't look tangent to the path at the tip of the position
> vector.
[...]

OK, there are several issues here, that might be confusing.


> %initialize scale
>  numeric u; 6u=3in;
>
> %draw coordinate axes

[...] 

> %calculate the velocity vector
>  numeric t;
>  t:=directiontime (1u,2u) of p;
wrong: directiontime looks at the path p and tries to find a slope of 
(1u,2u). Since it cannot find one, t gets -1 (check with show t).

>  pair d;
>  d:=direction t of p;
since t = -1 it looks at the first point and finds the direction there. 

>  drawarrow ((0,0)--d) scaled u shifted (1u,2u);
This is messy, since d has the correct correct direction but a "somewhat 
arbitrary" magnitude. See the Metapost manual p. 28.
 
>  p:=p scaled u;
If you do some calculations with path p, you have to scale it before doing 
these calculations!

So here is my solution (tested with context/metafun)

----------------------------------
%initialize scale
 numeric u; 6u=3in;

%draw coordinate axes
 drawdblarrow (-1u,0)--(5u,0);
 label.rt(btex $x$ etex, (5u,0));
 drawdblarrow (0,-1u)--(0,3u);
 label.top(btex $y$ etex, (0,3u));
 
%path
 path p;
 p:=(-1,1)...(1,2)...(5,2.5);
 p:=p scaled u;
%position vector
 drawarrow (0,0)--(1u,2u) withcolor red;
 label.lrt(btex ${\bf r}(t)$ etex, 0.5[(0,0),(1u,2u)]);
 dotlabel.ulft(btex $(x(t),y(t))$ etex, (1u,2u));

%calculate the velocity vector
 numeric t;
 % at what time does my point intersect w/ the path?
 (t,whatever) = p intersectiontimes ((1u,-infinity)--(1u,infinity));
 
 pair d;
 d:=direction t of p;
 %warning! d now has the correct direction but not!! magnitude

 drawarrow (origin -- ((2u,0) rotated angle d)) 
         shifted (1u,2u) 
         withcolor green;

 draw p withcolor blue;
---------------------------------------


-- 
Viele Gr��e, 

    Patrick Gundlach

Reply via email to