6
    \begin{tikzpicture}
\node [draw=black, anchor=south west] (label) at (0,0){\includegraphics[width=300mm]{th.jpg}};
\coordinate (ZX) at (157mm,104mm);
\coordinate (YB) at (249mm,39mm);
\coordinate (YY) at ($(ZX)!1.5!(YB)$);
\coordinate (ZZ) at ($(YB)!2.5!(ZX)$);
\draw[blue!20,very thick] (ZZ)--(YY);
\draw[red!20,very thick, rotate around={90:(ZX)}] (157mm,104mm)--(249mm,39mm);%It works
\draw[red!20,very thick, rotate around={-90:(ZX)}] (ZX)--(YB);%It doesn't work
\filldraw[white] (ZX) circle (2mm);
\filldraw[white] (YB) circle (2mm);
\end{tikzpicture}

a working example

     \documentclass{minimal}
\usepackage{tikz,tikz-3dplot}

\begin{document}

  \tdplotsetmaincoords{70}{115}

  \begin{tikzpicture}[scale=4,tdplot_main_coords]
\pgfmathsetmacro{\rvec}{.8}
\pgfmathsetmacro{\thetavec}{30}
\pgfmathsetmacro{\phivec}{60}

\tdplotsetrotatedcoords{\phivec}{\thetavec}{0}

 \coordinate (O) at (1,1,1);

 %these 2 lines overlap
\draw[thick,->] (O) -- (0,.5,0);
\draw[thick,tdplot_rotated_coords,->] (O) -- (0,.5,0);

 %these 2 lines dont overlap
\draw[thick,->] (1,1,1) -- (0,.5,0);
\draw[thick,tdplot_rotated_coords,->] (1,1,1) -- (0,.5,0);
\end{tikzpicture}
\end{document}
4

1 Answer 1

7
+100

In TikZ/pgf, transformations are applied only to numeric coordinates. You can retrieve original numeric coordinates (only 2D) from nodes or coordinates via a let operation:

\draw[red,very thick] let \p1=(ZX),\p2=(YB) in
[rotate around={-90:(ZX)}] (\p1)--(\p2);

A complete example:

enter image description here

\documentclass[tikz]{standalone}
\usetikzlibrary{calc} 
\begin{document}
\begin{tikzpicture}
  \node [draw=black, anchor=south west] (label) at (0,0){\includegraphics[width=300mm]{example-image}};
  \coordinate (ZX) at (157mm,104mm);
  \coordinate (YB) at (249mm,39mm);
  \coordinate (YY) at ($(ZX)!1.5!(YB)$);
  \coordinate (ZZ) at ($(YB)!2.5!(ZX)$);
  \draw[blue!20,very thick] (ZZ)--(YY);
  \draw[red!20,very thick, rotate around={90:(ZX)}]
  (157mm,104mm)--(249mm,39mm);%It works

  \draw[red,very thick] let \p1=(ZX),\p2=(YB) in
  [rotate around={-90:(ZX)}] (\p1)--(\p2);
  \filldraw[white] (ZX) circle (2mm);
  \filldraw[white] (YB) circle (2mm);
\end{tikzpicture}
\end{document}

Note: This method can't work with 3D coordinates and 3D transformations since node and coordinate stores the 2D projections.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .