68

Several questions about how arc is computed:

  1. The start and end angles seem to be defined relative to the y axis, yet in the Tikz manual they are defined relative to the x axis. Is this right?

  2. Is the end angle defined between the y (or x) axis and the incoming path, or between the y (or x) axis and the extension of the path beyond the endpoint?

  3. Geometrically speaking, providing just the start and end angles (and radius) is not enough to define an arc unambiguously. Is there some other assumption, such as: Arcs must be less than 180 degrees? Or arcs must always curve counterclockwise?

0

2 Answers 2

105

\draw (x,y) arc (start:stop:radius); draws an arc

  • with radius radius
  • starts from (x,y)
  • with center (x-r*cos(start), y-r*sin(start)) and
  • ends at (x-r*cos(start)+r*cos(stop), y-r*sin(start)+r*sin(stop)).

For example,

 \draw[red] (0,0) arc (30:60:3);

draws an arc

  • of radius 3
  • starting from (0,0)
  • with center (0-3*cos(30),0-3*sin(30)) and
  • ending at (0-3*cos(30)+3*cos(60),0-3*sin(30)+3*sin(60)).
\draw[blue] (0,0) -- ++(30+180:3) -- +(60:3);

draw a blue line to the arc to make a complete sector as shown in the following figure.

enter image description here

Minimal Working Example

\documentclass[tikz,border=12pt]{standalone}


\begin{document}
\foreach \start/\stop in {30/60,45/90,135/180,0/180,45/315}
{
    \begin{tikzpicture}
        \draw[lightgray,ultra thin] (-6,-6) grid (6,6);
        \draw[red] (0,0) arc (\start:\stop:3);
        \draw[blue] (0,0) -- ++(\start+180:3) -- +(\stop:3);
        \node[anchor=north] at (0,6) {$(\start:\stop:3)$};
    \end{tikzpicture}
}
\end{document}

Other outputs for you to analyze

enter image description here

enter image description here

enter image description here

enter image description here

5
  • 4
    Thank you very much. I was completely confused about the meaning of "start angle" and "end angle". I understand now! ---David B. May 3, 2014 at 17:12
  • 1
    Just a remark on "(start:stop:radius)": both "(45:315:3)" and "(315:45:3)" draw 3/4 of a disk. To draw the missing 1/4 you need "(315:405:3)".
    – jpb
    Jan 6, 2017 at 11:16
  • 2
    @jpb: is there a way to force it to draw clockwise or anticlockwise? In my current application, I don't know what my start and stop angles will be in advance, but I know I want a clockwise arc from start to stop. Sometimes, I need to add 360, and sometimes I need to not.
    – Pi Fisher
    Feb 28, 2018 at 19:14
  • After reading this numerous times I cannot figure out how you change the location for the center of the circle with the commands given.
    – drfrankie
    Oct 18, 2020 at 22:58
  • @PiFisher You use a negative number for the angle, then it rotates clockwise.
    – Andyc
    Jul 12, 2021 at 14:55
38

For visualisation, here is a diagram:

enter image description here

where

  • theta_i is the start angle,
  • theta_f is the end angle,
  • R is the radius,
  • O is the centre of rotation (not the origin),
  • A is the starting point,
  • B is the end point.

Answers to your question

  1. The start and end angles seem to be defined relative to the y axis, yet in the Tikz manual they are defined relative to the x axis. Is this right?

The start and end angle are defined with respect to the x-axis. That convention is widespread, so it shouldn't be surprising. Although the tikz manual (v3.0) actually doesn't spell that out anywhere, as far as I know, you can gather as much from the numerous examples that use the arc operation therein.

  1. Is the end angle defined between the y (or x) axis and the incoming path, or between the y (or x) axis and the extension of the path beyond the endpoint?

See my answer to 1).

  1. Geometrically speaking, providing just the start and end angles (and radius) is not enough to define an arc unambiguously. Is there some other assumption, such as: Arcs must be less than 180 degrees? Or arcs must always curve counterclockwise?

The only assumptions are those specified in 1) and that the rotation is counterclockwise. This choice of orientation is also not spelled out in the manual either, but should also not be very surprising.

Moreover, you can have arcs that span more than 180 degrees (by having |\theta_f-\theta_i| > 180 degrees) and you can have arcs that curve clockwise (by having \theta_f<\theta_i).

5
  • 13
    Why didn't use TikZ to draw the diagram? May 3, 2014 at 15:46
  • @IamwhoIsayIam Good point :) I just jotted that down and took a picture of it. So "laziness" is the answer to your question.
    – jub0bs
    May 3, 2014 at 15:51
  • 2
    I created the diagram for you with PSTricks here (click). May 3, 2014 at 16:47
  • 1
    @IamwhoIsayIam Nice. You should use it in your own answer.
    – jub0bs
    May 3, 2014 at 18:08
  • 1
    No. Because the labels are not relevant to my explanation. :-) May 3, 2014 at 18:23

You must log in to answer this question.

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