70

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?

2 Answers2

107

\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

Display Name
  • 46,933
  • 4
    Thank you very much. I was completely confused about the meaning of "start angle" and "end angle". I understand now! ---David B. – David Brown May 03 '14 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 06 '17 at 11:16
  • 3
    @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 '18 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 '20 at 22:58
  • @PiFisher You use a negative number for the angle, then it rotates clockwise. – Andyc Jul 12 '21 at 14:55
  • Does this mean it's impossible to draw an arc with center at (0,0)? cos(x) and sin(x) can both never be zero for any x. – Parseval Nov 26 '23 at 23:04
39

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).

PatrickT
  • 2,923
jub0bs
  • 58,916