0

When I draw an arc I get, through the coordinate command, the point at the end of the arc (mypoint in the code below) for further drawing, but it does not correspond to the expected point.

See the drawing: the green circle should lay at the end of the red arc (where I have placed manually a blue circle), as expected in the code, but it lays some millimetres away.

How could I get the "right" point at the end of the arc for further drawing?

arc with circle

Here is my code:

\documentclass[tikz, border=0.3cm]{standalone}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}[scale=1.5]
\newcommand{\xradius}{0.22}
\newcommand{\yradius}{0.17}
%Ellipses centre
\newcommand{\xcent}{2}
\newcommand{\ycent}{2}

\newcommand{\myrotation}{20} %Ellipse rotation angle
\newcommand{\myangle}{30} %Angle before axis

\coordinate (center) at (\xcent, \ycent);

\draw (center) circle [x radius=\xradius, y radius=\yradius, rotate=\myrotation]; %Drawing black ellipse

\path (center) ++({-90+\myrotation}:\yradius) coordinate (startpoint); %Starting point of red arc

\draw [color=red] (startpoint) arc [x radius=\xradius, y radius=\yradius, start angle={-90}, delta angle={90-\myangle/2}, 
rotate=\myrotation] coordinate (mypoint);  %Drawing red arc and getting the end point
\path [fill=green, radius=0.02] (mypoint) circle; %Drawing green circle

\draw [help lines] (center) -- +(\myrotation:{4*\xradius}); %Gray reference axis

\end{tikzpicture}


\end{document}

Oh, yes, thanks in advance for the answers.

2

The following suggestions will work with both the current pgf version (3.0.1a) and the old version 2.10.

Use rotate=\myrotation as option for the whole path:

enter image description here

\documentclass[tikz, border=0.3cm]{standalone}
\begin{document}
\begin{tikzpicture}[scale=1.5]
  \newcommand{\xradius}{0.22}
  \newcommand{\yradius}{0.17}
  %Ellipses centre
  \newcommand{\xcent}{2}
  \newcommand{\ycent}{2}

  \newcommand{\myrotation}{20} %Ellipse rotation angle
  \newcommand{\myangle}{30} %Angle before axis

  \coordinate (center) at (\xcent, \ycent);
  \draw[rotate=\myrotation] (center) circle [x radius=\xradius, y radius=\yradius];
  \path[rotate=\myrotation] (center) ++(-90:\yradius) coordinate (startpoint); 
  \draw [color=red,rotate=\myrotation] (startpoint) 
    arc [x radius=\xradius, y radius=\yradius, start angle={-90}, delta angle={90-\myangle/2}] 
    coordinate (mypoint);
  \path [fill=green, radius=0.02] (mypoint) circle;
  \draw [help lines] (center) -- +(\myrotation:{4*\xradius});
\end{tikzpicture}
\end{document}

Or using a scope for the rotation:

\documentclass[tikz, border=2pt]{standalone}
\begin{document}
\begin{tikzpicture}[scale=1.5]
  \newcommand{\xradius}{0.22}
  \newcommand{\yradius}{0.17}
  %Ellipses centre
  \newcommand{\xcent}{2}
  \newcommand{\ycent}{2}

  \newcommand{\myrotation}{20} %Ellipse rotation angle
  \newcommand{\myangle}{30} %Angle before axis

  \coordinate (center) at (\xcent, \ycent);

  \begin{scope}[rotate=\myrotation]
    \draw (center) circle [x radius=\xradius, y radius=\yradius];
    \path (center) ++(-90:\yradius) coordinate (startpoint); 
    \draw [color=red] (startpoint) 
      arc [x radius=\xradius, y radius=\yradius, start angle={-90}, delta angle={90-\myangle/2}] 
      coordinate (mypoint);
    \draw [help lines] (center) -- +({4*\xradius},0);
  \end{scope}

  \path [fill=green, radius=0.02] (mypoint) circle;
\end{tikzpicture}
\end{document}
  • Amazing! the trick of using rotate=\myrotation for the whole path did it. Thanks again @esdd! By the way, nice suggestion of creating a scope for the rotation, that's what I'll use! :) – loved.by.Jesus Dec 9 '15 at 11:54
2

Compiling your MWE results in this: enter image description here

Seems to me that the green spot is spot on!

  • Did you get that with my code? How can it be that the same code by me produces my picture?? – loved.by.Jesus Dec 9 '15 at 11:01
  • 2
    @loved.by.Jesus, I got the same, my guess is that you need to update your LaTeX installation – daleif Dec 9 '15 at 11:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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