At the moment, I try to learn automation of graphic drawing with latex (tikz) and R.
I need to determine the coordinates of the point with the smallest distance to a defined point "North"
Thats what I found out so far:
Code: Select all
\begin{tikzpicture}
\coordinate (North) at (0,5);
\path let
\p1 = ($(North)-(node_1)$), \n1 = {veclen(\x1,\y1)}
, \p2 = ($(North)-(node_2)$), \n2 = {veclen(\x2,\y2)}
, \p3 = ($(North)-(node_3)$), \n3 = {veclen(\x3,\y3)}
, \p4 = ($(North)-(node_4)$), \n4 = {veclen(\x4,\y4)}
in coordinate (dummy1) at (\x1, \y1)
coordinate (dummy2) at (\x2, \y2)
coordinate (dummy3) at (\x3, \y3)
coordinate (dummy4) at (\x4, \y4);
\end{tikzpicture}
My basic idea was to implement something like an if loop:
if \n1 == min(n1, \n2, \n3,\n4) then coordinate (nearest_to_north) at (node_1)
elseif \n2 == min(n1, \n2, \n3,\n4) then coordinate (nearest_to_north) at (node_2)
elseif...
The whole Latex-codes is embedded in an *.Rnw-File so it would also be possibel to implement the loop in R-code but I also dont understand how to transfair the latex commands \n1, \x1, \y1 to R.
The tikz syntax is very confusing to me...so Im looking forward to any suggestions or help


I also asked this question here in German: https://golatex.de/viewtopic,p,106794.html#106794
and here in English: https://tex.stackexchange.com/questions ... ther-point