Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.
    \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}
share|improve this question
4  
Transformations are applied only to coordinates... –  Paul Gaborit Jan 23 '13 at 15:59
    
You can remove the \includegraphics, which is not required to show the problem and prevents the compilation of your code (since we don't have the jpg). Also, add the minimal preamble to transform that code into a MWE. –  JLDiaz Jan 23 '13 at 16:12
    
Welcome to TeX.SX. It is always preferable to post complete minimal working examples rather than code snippets because this helps people to answer you. –  Claudio Fiandrino Jan 23 '13 at 16:19
    
We've had similar questions before. Paul Gaborit's comment is spot on. For more, I recommend reading tex.stackexchange.com/q/38501/86, tex.stackexchange.com/q/98924/86, tex.stackexchange.com/q/1537/86 (note the quote from the manual in Caramdir's answer there). –  Loop Space Feb 22 '13 at 10:57
add comment

1 Answer 1

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.