Assuming that I have the path
P given, and let the
T be a point outside the path
Is there an easy way to find the point
X on the path
P such that the tangent on point
X going through the point
Example in Metapost:
outputformat := "svg"; outputtemplate := "%j-%c.svg"; beginfig(1) pair T,X; path P; T:=(800,900); P:=(0,0)..(300,100)..(200,600); draw P withpen pencircle scaled 10; draw T withpen pencircle scaled 20 withcolor red; endfig; end
Basically, what I need is:
X = directionpoint (T-X) of P (this is, of course, an error).
The only solution I can think of is to check an every point on the path until I found it, something like:
numeric v; v:=0; forever: X:=point v of P; exitif abs(angle(T-X) - angle(direction v of P)) < 0.001; % for example v:=v+epsilon; endfor;
Of course, this specific code will not work in the every case. Plus, it's very slow.
Is there a better solution? Of course, in a general case it's possible that there is no the solution, or more than just one solution.