Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

It would be convenient sometimes to be able to draw an arc in tikz by specifying

  • the center of the corresponding circle
  • its radius
  • the initial/final angle

i.e., the "natural" way an arc is defined, instead of the "first point of the arc".

Is there a way to do it?

share|improve this question

5 Answers 5

up vote 24 down vote accepted

Or perhaps parametrically using

x(t)=a+r*cos(t)
y(t)=b+r*sin(t)

where r is the radius of the circle centered on (a,b)

screenshot

\documentclass{article}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
   \draw [red,thick,domain=0:90] plot ({cos(\x)}, {sin(\x)});
   \draw [blue,thick,domain=180:270] plot ({cos(\x)}, {sin(\x)});
\end{tikzpicture}

\end{document}

Depending on your application, you might like to do this using the pgfplots package.

share|improve this answer
    
Thank you very much! –  niels Aug 7 '12 at 16:26
    
@niels you're welcome :) –  cmhughes Aug 7 '12 at 16:26
1  
Clever solution! –  percusse Aug 9 '12 at 0:43
6  
Very nice, I used the idea to define this command: \def\centerarc[#1](#2)(#3:#4:#5)% [draw options] (center) (initial angle:final angle:radius) { \draw[#1] ($(#2)+({#5*cos(#3)},{#5*sin(#3)})$) arc (#3:#4:#5); } It. can be used e.g. likr this: \centerarc[red,thick](0,0)(5:85:1) –  Tom Bombadil Aug 21 '12 at 22:35

You should use a coordinate transformation for this, to get a proper starting point of the arc. Say, ([shift=(t:r)] x, y) is the proper starting point, where (x,y) is the center and (t:r) is the polar coordinate of starting point.

Full example:

enter image description here

\documentclass{article}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
\draw[help lines] (0,0) grid (4,3);
\draw (2,1) -- ++(30:2cm)
      (2,1) -- ++(60:2cm);
% Draw the arc which center is (2,1)
\draw[thick,red] ([shift=(30:1cm)]2,1) arc (30:60:1cm);
\end{tikzpicture}

\end{document}
share|improve this answer
    
Oh this is very clever. I'm going to use this technique to answer my own question here –  bobobobo Aug 9 '12 at 16:53

Notation: each arc is defined by <center>, <radius>, <init angle> and <final angle>.

If you want to be able to link several arcs in a single path, you can use shift with following syntax:

  • initial point:([shift={(<init angle>:<radius>)}]<center>)

  • to draw your arc: arc (<init angle>:<final angle>:<radius>)

Example (orange path uses proposed syntax and cyan path uses a style):

\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
  \draw[fill=orange]
  ([shift={(-40:1cm)}]-1.1,0) arc (-40:40:1cm)
  --
  ([shift={(-40+180:1cm)}]1.1,0) arc (-40+180:40+180:1cm)
  -- cycle;
\end{tikzpicture}
\begin{tikzpicture}
  \tikzset{translate/.style={shift={(#1)}}}
  \draw[fill=cyan]
  ([translate=-40:1cm]-1.1,0) arc (-40:40:1cm)
  --
  ([translate=-40+180:1cm]1.1,0) arc (-40+180:40+180:1cm)
  -- cycle;
\end{tikzpicture}
\end{document}

enter image description here

Edit: a simpler notation!

Using calc TikZ library, you can use a simpler notation:

  • initial point: ($(<center>) + (<init angle>:<radius>)$).

Example:

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
  % center c1
  \coordinate (c1) at (0,0);

  \draw[fill=green]
  % radius=3mm, initial=0, final=90
  %([shift={(0:3mm)}]c1) arc (0:90:3mm)
  ($(c1) + (0:3mm)$) arc (0:90:3mm)
  --
  % radius=4mm, reversed
  ($(c1) + (90:4mm)$) arc (90:0:4mm)
  -- cycle;

  \draw[fill=yellow]
  % radius=4mm, initial=22.5, final=180
  ($(c1) + (22.5:4mm)$) arc (22.5:180:4mm)
  --
  % radius=5mm, reversed
  ($(c1) + (180:5mm)$) arc (180:22.5:5mm)
  -- cycle;

  % center c2
  \coordinate (c2) at (0,12mm);

  \draw[fill=red]
  % radius=5mm, initial=45, final=270
  ($(c2) + (45:5mm)$) arc (45:270:5mm)
  --
  % radius=6mm, reversed
  ($(c2) + (270:6mm)$) arc (270:45:6mm)
  -- cycle;

  \draw[fill=gray]
  % radius=6mm, initial=67.5, final=360
  ($(c2) + (67.5:6mm)$) arc (67.5:360:6mm)
  --
  % radius=7mm, reversed
  ($(c2) + (360:7mm)$) arc (360:67.5:7mm)
  -- cycle;
\end{tikzpicture}
\end{document}

enter image description here

share|improve this answer

Possible is to use tkz-euclide. I f you want something independent of tkz-euclide you can take the code inside the file tkz-obj-arcs.tex. In each cases, I use the center

1) \tkzDrawArc and towards

towards is the option by defaut so it's not necessary to indicate this option. In the the example, the arc starts from A towards the axe OB.

 \begin{tikzpicture}[scale=1.5]
  \tkzDefPoint(0,0){O}
  \tkzDefPoint(2,-1){A}
  \tkzDefPoint(1,1){B}
  \tkzDrawArc[color=blue](O,A)(B)
  \tkzDrawArc[color=Maroon](O,B)(A)
  \tkzDrawArc(O,B)(A)
  \tkzDrawLines[add = 0 and .5](O,A O,B)
  \tkzDrawPoints(O,A,B)
  \tkzLabelPoints[below](O,A,B)
 \end{tikzpicture}

enter image description here

2) \tkzDrawArc and rotate

Here the center is O, the arc starts from A and the measure of the angle is 180 degrees.

\begin{tikzpicture}
  \tkzDefPoint(0,0){O}
  \tkzDefPoint(2,-2){A}
  \tkzDefPoint(60:2){B}
  \tkzDrawLines[add = 0 and .5](O,A O,B)
  \tkzDrawArc[rotate,color=red](O,A)(180)
  \tkzDrawPoints(O,A,B)
  \tkzLabelPoints[below](O,A,B)
\end{tikzpicture}

enter image description here

3) \tkzDrawArc and R

In this case the center is O and you need to give the radius R and two angles

\begin{tikzpicture}
  \tkzDefPoints{0/0/O}
  \tikzset{compass style/.append style={<->}}
  \tkzDrawArc[R, color=orange,double](O,3cm)(270,360)
  \tkzDrawArc[R, color=blue,double](O,2cm)(0,270)
  \tkzDrawPoint(O)
  \tkzLabelPoint[below](O){$O$}
\end{tikzpicture}

enter image description here

4) \tkzDrawArc and R with nodes In this case, we need to know the center, the radius and the arc starts from the line BA towards the line BO

\begin{tikzpicture}
  \tkzDefPoint(0,0){O}
  \tkzDefPoint(2,-1){A}
  \tkzDefPoint(1,1){B}
  \tkzCalcLength(B,A)\tkzGetLength{radius}
  \tkzDrawArc[R with nodes](B,\radius pt)(A,O)
\end{tikzpicture}

enter image description here

5) \tkzDrawArc and delta

Useful to add an arc like with a compass.

\begin{tikzpicture}
\tkzInit
\tkzDefPoint(0,0){A} \tkzDefPoint(5,0){B} \tkzDefPointBy[rotation= center A%
                angle 60](B) \tkzGetPoint{C}
 \tkzSetUpLine[color=gray]
 \tkzDefPointBy[symmetry= center C](A)
    \tkzGetPoint{D}
 \tkzDrawSegments(A,B A,D)
 \tkzDrawLine(B,D)
 \tkzSetUpCompass[color=orange]
 \tkzDrawArc[delta=10](A,B)(C)
 \tkzDrawArc[delta=10](B,C)(A)
 \tkzDrawArc[delta=10](C,D)(D)
 \tkzDrawPoints(A,B,C,D)
 \tkzLabelPoints(A,B,C,D)
 \tkzMarkRightAngle(D,B,A)
\end{tikzpicture}

enter image description here

share|improve this answer
    
I cannot get this code to work. I've loaded tkz-euclide, but LaTeX complains that \tkzDrawArc is not defined. Is there something else I need to load? –  A.Ellett Mar 16 at 14:46
    
You need to add in the preamble \usetkzobj{arcs} or \usetkzobj{all} –  Alain Matthes Mar 16 at 15:04
    
@AlainMatthes Would like to reproduce Example (1) in plain TeX. I looked at tkz-obj-arcs.tex, but am confused about what to extract from that to translate to plain TeX. Please advise. –  user1823664 Mar 16 at 18:06

You can create a new command, like this one

\documentclass[12pt]{standalone}
\usepackage{tikz}


\newcommand{\cercle}[4]{
\node[circle,inner sep=0,minimum size={2*#2}](a) at (#1) {};
\draw[red,thick] (a.#3) arc (#3:{#3+#4}:#2);
}
\begin{document}
\begin{tikzpicture}

\coordinate (center) at (3,2);

\cercle{center}{2cm}{25}{-90}
![\cercle{4,5}{1cm}{15}{130}][1]

\end{tikzpicture}
\end{document}

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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