# Perfectly circular arc on image with non-1:1 aspect ratio

I'm looking for a way to draw a perfectly circular arc on an image.

At the moment I'm using tikz to draw the arc. The problem is that by using the following code the arc is more like part of an ellipse than of a circle. That's due to the different values for x and y in the scope environment. I cannot change the values. I need the exact position of the arc's center to be in a certain spot of the image. The position is given as a fraction of the image's width and height (e.g. at (0.5,0.62) as in the code example) because I want to remain independent of the actual scaling of the image (keeping its aspect ratio).

The code I'm using now is as follows:

\documentclass{article}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
\node[anchor=south west,inner sep=0, opacity=0.6] (image) at (0,0,0) {\includegraphics[width=8cm]{image}};
\begin{scope}[x={(image.south east)},y={(image.north west)}]
\draw[->,>=stealth,line width=1mm,red] ([shift=(0:0.2)]0.5,0.62) arc(0:90:0.2);
\end{scope}
\end{tikzpicture}
\end{document}


That way the center is in the perfect location regardless of what I choose the width of the image node to be (8cm in this case).

The arc is distorted because I provide polar coordinates and x and y have different scaling factors. In a 1:1 aspect ratio domain this would be a perfect circle. But it's not a 1:1 domain.

So, what can I do to get the 1:1 domain for the arc's radius while keeping the aspect ratio of the image for the cartesian coordinates (i.e. fraction of the corresponding image axis) of the arc's center?

### My solution

Based on Zarko's solution I've come up with this MWE that also includes calculation of the aspect ratio:

\documentclass{article}
\usepackage{tikz}

\newlength{\mywidth}
\newlength{\myheight}

\makeatletter
\newcommand{\getlength}{\pgfmathsetmacro#1{\strip@pt#2}} % to get rid of the pt dimension as a division of lengths apparently doesn't cancel it out
\makeatother

\newcommand{\pgfsize}{
\pgfextractx{#1}{\pgfpointdiff{\pgfpointanchor{current bounding box}{south west}}{\pgfpointanchor{current bounding box}{north east}}}
\pgfextracty{#2}{\pgfpointdiff{\pgfpointanchor{current bounding box}{south west}}{\pgfpointanchor{current bounding box}{north east}}}
}

\begin{document}
\begin{tikzpicture}
\node[anchor=south west,inner sep=0, opacity=0.6] (image) at (0,0,0) {\includegraphics[width=8cm]{image}};
\begin{scope}[x={(image.south east)},y={(image.north west)}]
\pgfsize{\mywidth}{\myheight};
\getlength{\aspect}{\mywidth / \myheight};
\node (0,0) {Aspect ratio is \aspect~:~1};
\draw[->,>=stealth,line width=1mm,red] ([shift=(0:0.2)]0.5,0.62) arc(0:90:0.2 and 0.2*\aspect);
\end{scope}
\end{tikzpicture}
\end{document}


You can define arc as segment of ellipse:

\draw (2,0) arc [x radius=1, y radius=2, start angle=0, end angle=180];


or shortly for example

\draw (2,0) arc  arc(0:90:0.2 and 0.4);


Considering your code snipped (you should extend it to minimal working example!) I obtain (without calculating ratio between x and y radius, this I left to you):

\usepackage[demo]{graphicx}
\usepackage{tikz}
\usetikzlibrary{matrix}

\begin{document}

\begin{tikzpicture}
\node[anchor=south west,inner sep=0, opacity=0.6] (image) at (0,0,0) {\includegraphics[width=8cm]{Bilder/panaxis}};
\begin{scope}[x={(image.south east)},y={(image.north west)}]
\draw[->,>=stealth,line width=1mm,red] ([shift=(0:0.2)]0.5,0.62) arc(0:90:0.2 and 0.4);
\end{scope}
\end{tikzpicture}
\end{document}


For exactly ratio between x-radius and y-radius you can define for example for x and than from it calculate y with considering x-scale of image.

• Thank you very much. I'll edit my question accordingly and include the solution that I've found to also calculate the aspect ratio. – Hendrik Wiese Jan 8 '17 at 17:44
• Here is habits that instead "thank you" you up-vote answer and if it help you, accept it :). Ration between bot radius is not LaTeX issue but geometry, so (because today is Sunday) I didn'd bother with it :(. – Zarko Jan 8 '17 at 17:52
• Sure thing. I just wanted to finish editing my question before kind of "closing" this issue. I've upvoted and accepted your answer. Thanks again (in addition to the upvote...)! – Hendrik Wiese Jan 8 '17 at 17:54