2

I'm trying to draw the arc of an ellipse which is centered at the origin. I'd like it to start drawing at an initial angle of 45 degrees and end at 90 degrees.

From this question on this site, there is a comment that indicates one way to do it is

\documentclass{article}
\usepackage{tikz}
\usepackage[dvipsnames]{xcolor}

\begin{document}

\begin{tikzpicture}
\draw[fill=ProcessBlue!30] (45:2cm and 1cm) arc [start angle = 45.0, end angle=90.0, x radius = 2cm, y radius = 1cm];
\end{tikzpicture}

\end{document}

which produces

enter image description here

Unless I am being stupid, this doesn't appear to actually be the drawing at the angle of 45 degrees relative to the horizontal. The coordinates of that point are (r*cos(pi/4), r*sin(pi/4)), where r is calculated using this formula from wikipedia. That point is outlined in red below. I also drew a line from the origin to show that that point is calculated correctly.

enter image description here

Here's what I used to make the above.

\documentclass{article}
\usepackage{tikz}
\usepackage[dvipsnames]{xcolor}

\begin{document}
\begin{tikzpicture}
    \draw (-4,0) -- (4,0);
    \draw (0,-4) -- (0,4);
    
    \draw[fill=blue] (45:2cm and 1cm) circle (0.05cm);
    \draw[fill=ProcessBlue!30] (45:2cm and 1cm) arc [start angle = 45.0, end angle=90.0, x radius = 2cm, y radius = 1cm];
    \draw[fill=red] (0.894427190999916, 0.894427190999916) circle (0.05cm);
    \draw[dashed] (0,0) ellipse (2cm and 1cm);
    \draw (0,0) -- (1,1);
\end{tikzpicture}

\end{document}

My question: It appears that the command \draw[fill=ProcessBlue!30] (45:2cm and 1cm) arc... is NOT drawing an arc which starts from the point on the ellipse with axes 2cm and 1cm, that makes a 45 degree angle with the horizontal (Confusingly, that IS how one would do it for a circle...). I think this is the first time I've found TikZ syntax to be so wildly off of what I'd naturally expect. So, what is it actually doing (i.e., why did it start at the blue point)? Is there a simple way to do what I originally aimed to do (I emphasize simple because what I want to do is not very advanced.)?

1
  • The blue circle should be at \draw[fill=blue] (63.43:2cm and 1cm) circle (0.05cm);. You want 45 degrees in the 2x stretched ellipse coordinates. So you want the angle associated with atan(1/2), not atan(1), which is 26.5 degrees. But we want the complement, which is 63.43 deg Commented Apr 1, 2021 at 20:10

2 Answers 2

1

Regarding my comment...I changed all the 45 to 63.43, which is 90-atan(1/2).

With the 45, you are drawing the arc from the 45 of an unstretched circle. After stretching the circle into an ellipse, the 45 degree angle becomes flattened.

In conclusion, 63.43 deg on the unit circle relative to the x axis becomes 45 degrees after you stretch the x axis by a factor of 2x.

\documentclass{article}
\usepackage{tikz}
\usepackage{xcolor}

\begin{document}
\begin{tikzpicture}
    \draw (-4,0) -- (4,0);
    \draw (0,-4) -- (0,4);
    
    \draw[fill=blue] (63.43:2cm and 1cm) circle (0.05cm);
    \draw[fill=blue!30] (63.43:2cm and 1cm) arc [start angle = 63.43, end angle=90.0, x radius = 2cm, y radius = 1cm];
    \draw[fill=red] (0.894427190999916, 0.894427190999916) circle (0.05cm);
    \draw[dashed] (0,0) ellipse (2cm and 1cm);
    \draw (0,0) -- (1,1);
\end{tikzpicture}

\end{document}

enter image description here

1
  • 1
    I had a feeling it was something silly like this, I understand now, thank you!
    – trujello
    Commented Apr 1, 2021 at 23:37
1

There is no inconsistency. The points are parametrized by (a cos(angle), b sin(angle)).

enter image description here

\documentclass{article}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
    \draw (-4,0) -- (4,0);
    \draw (0,-4) -- (0,4);
    \draw[fill=blue] 
        (45:2cm and 1cm) arc [start angle = 45.0, 
        end angle=90.0, x radius = 2cm, y radius = 1cm];
    \draw[dashed] (0,0) ellipse[x radius=2cm,y radius=1cm];
    \path ({2*cos(45)},{1*sin(45)}) node[circle,inner sep=1pt,fill=red,
        label={[text width=4cm]above right:{I am sitting at 
        $\bigl(a\,\cos(45),b\,\sin(45)\bigr)$ with $a=2$ and $b=1$.}}]{};   
\end{tikzpicture}

\end{document}
2
  • To a nontrikz expert like myself, \draw (45:2cm:1cm) arc ... means draw an arc of an ellipse starting at the angle of 45 degrees. However, as you pointed out, it's actually a parameter. But what's confusing is that 45 nevertheless gets passed into an argument called start_angle. That's what seems a bit inconsistent (45 is not the angle)...
    – trujello
    Commented Apr 1, 2021 at 23:36
  • 1
    @trujello There is not much what I can say, and it is perfectly fine if you choose to accept the answer that makes you happy, but it is perfectly consistent to parametrize ellipses like this, it is one of the most common parametrizations, and computationally not overly expensive. And, in particular, this makes it clear what the interpretation of the parameter is, which you can definitely call an angle.
    – user238301
    Commented Apr 2, 2021 at 0:53

You must log in to answer this question.

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