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.

I clipped a circle along the line atan(2/3). Where the circle is clipped I would like to put an arrow. I thought it would be as simple as (atan(2/3) + 180)/360 to get its percentage location along the path. Unfortunately, it wasn't. I ended up subtracting 32.5 degrees due to trial and error. I would like to make a more exact placement though.

\documentclass[tikz]{standalone}
\usetikzlibrary{decorations.markings}

\begin{document}
\begin{tikzpicture}
  \pgfmathsetmacro{\angle}{atan(2/3)};
  \pgfmathsetmacro{\ppi}{\angle + 180};
  \pgfmathsetmacro{\percent}{(\ppi - 32.5)/360};

  \begin{scope}[rotate = \angle, decoration = {
      markings,
      mark = at position \percent with {\arrow{stealth}}
    }]
    \clip (0, .4) rectangle (-.45, 0);

    \draw[postaction = decorate] (cylinder) circle[radius = .395cm];
  \end{scope}
\end{tikzpicture}
\end{document}

enter image description here

share|improve this question

1 Answer 1

up vote 9 down vote accepted

Let us analyse. Without \clip,without rotation and the drawn rectangle this is your circle:

enter image description here

This shows that the \percent value should be 50. With

\pgfmathsetmacro{\ppi}{\angle + 180};
\pgfmathsetmacro{\percent}{(\ppi)/360};

You are certainly not giving 50% but more than that. To be exact, you are giving atan(2/3) more to \ppi. If we make \ppi = 180, then \percent will be 50.

\documentclass[tikz]{standalone}
\usetikzlibrary{decorations.markings}

\begin{document}
\begin{tikzpicture}
  \pgfmathsetmacro{\angle}{atan(2/3)};
  \pgfmathsetmacro{\ppi}{180};
  \pgfmathsetmacro{\percent}{(\ppi)/360};

  \begin{scope}[rotate = 0, decoration = {%     % change rotate to \angle
      markings,
      mark = at position \percent with {\arrow{stealth}}
    }]
    %\clip (0, .4) rectangle (-.45, 0);
    \draw (0, .4) rectangle (-.45, 0);

    \draw[postaction = decorate] (0,0) circle[radius = .395cm];
  \end{scope}
\end{tikzpicture}
\end{document}

enter image description here

Now you can rotate and clip to get:

\documentclass[tikz]{standalone}
\usetikzlibrary{decorations.markings}

\begin{document}
\begin{tikzpicture}
  \pgfmathsetmacro{\angle}{atan(2/3)};
  \pgfmathsetmacro{\ppi}{180};
  \pgfmathsetmacro{\percent}{(\ppi)/360};

  \begin{scope}[rotate = \angle, decoration = {
      markings,
      mark = at position \percent with {\arrow{stealth}}
    }]
    \clip (0, .4) rectangle (-.45, 0);
    %\draw (0, .4) rectangle (-.45, 0);

    \draw[postaction = decorate] (0,0) circle[radius = .395cm];
  \end{scope}
\end{tikzpicture}
\end{document}

enter image description here

share|improve this answer

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.