53

The TiKz command for an arc:

\draw (0,0) arc (-30:30:2) ;

Draws an arc that starts at (0,0), and would be the part of the circle from -30 degrees to +30 degrees of radius 2.

arc1

It is very hard to place these arc sometimes. This is the symbol i want to draw:

eye

(This represents an eye and needs more detail).

I want to draw the arc as _part of a circle with center at where the < meets, but I have to currently fudge the start location of the arc so it properly crosses the < (and it's not even exact).

If I could do a circle from -45 to +45 degrees CENTERED at the <, then that would be much easier.

1

3 Answers 3

68

Here is an answer, using the technique described here, with more detail,

\pgfmathsetmacro{\ex}{0}
\pgfmathsetmacro{\ey}{1}

\draw (\ex,\ey) -- ++(-15:1)
      (\ex,\ey) -- ++(15:1);
\draw (\ex,\ey) ++(45:.8) arc (45:-45:.8);

eye right

The secret to this is in the last line,

\draw (\ex,\ey) ++(45:.8)

Jumps the draw cursor to "the 45 degree position on a circle of radius 0.8", without drawing anything (achieved by using only ++ and not any -- in the command)

Then, from there, we draw an arc

arc (45:-45:.8);

from 45 degrees to -45 degrees, of what would be a circle of radius .8.

Pretty roundabout way to do this, but still it works fine.

Edit:

My finished eye:

finished eye

\begin{tikzpicture}

%eye
\pgfmathsetmacro{\eyeSize}{1}
\pgfmathsetmacro{\ex}{0}
\pgfmathsetmacro{\ey}{1}
\pgfmathsetmacro{\eRot}{-10}
\pgfmathsetmacro{\eAp}{-55}
\draw[rotate around={\eRot:(\ex,\ey)}] (\ex,\ey) -- ++(-.5*\eAp:\eyeSize)
     (\ex,\ey) -- ++(.5*\eAp:\eyeSize);
\draw (\ex,\ey) ++(\eRot+\eAp:.75*\eyeSize) arc (\eRot+\eAp:\eRot-\eAp:.75*\eyeSize);

% IRIS
\draw[fill=gray] (\ex,\ey) ++(\eRot+\eAp/3:.75*\eyeSize) % start point
  arc (\eRot+180-\eAp:\eRot+180+\eAp:.28*\eyeSize);

%PUPIL, a filled arc 
\draw[fill=black] (\ex,\ey) ++(\eRot+\eAp/3:.75*\eyeSize) % start point
  arc (\eRot+\eAp/3:\eRot-\eAp/3:.75*\eyeSize);

\end{tikzpicture}
48

Now as TikZ 3.0 is here we can use pic.

\documentclass[tikz,border=5]{standalone}
\tikzset{
  pics/carc/.style args={#1:#2:#3}{
    code={
      \draw[pic actions] (#1:#3) arc(#1:#2:#3);
    }
  }
}
\begin{document}
\begin{tikzpicture}
  \pic{carc=-30:30:2cm};
  \draw[thick] (4,0) circle (1 cm) pic[red, -latex]{carc=100:150:1.3cm};
\end{tikzpicture}
\end{document}

enter image description here

Note 1: This question was treated before here How to extend TikZ drawing commands

Note 2: I arrived here from this closed quastion Tikz: Curved parallel arrow around a circle, so I gave the answer here too.


EDIT: Here are some examples how we can use carc to create logos ;)

enter image description here

\documentclass[varwidth,border=50]{standalone}
\usepackage{tikz}
\tikzset{
  pics/carc/.style args={#1:#2:#3}{
    code={
      \draw[pic actions] (#1:#3) arc(#1:#2:#3);
    }
  }
}
\begin{document}
  \begin{tikzpicture}
    % --- RSS
    \begin{scope}[xshift=-1.5cm]
      \fill[orange, rounded corners=5mm] (-0.5,-0.5) rectangle (3.7,3.7);
      \fill[white] (0.5,0.5) circle (0.5);
      \draw[white, line width=7mm] (0,0) pic{carc=0:90:1.9} pic{carc=0:90:3};
    \end{scope}

    % --- Radioactif
    \begin{scope}[yshift=-4cm, yellow, line width=1.4cm]
      \fill[black] circle (2.5);
      \fill circle (.5);
      \draw pic{carc=-60:0:1.4} pic{carc=60:120:1.4} pic{carc=180:240:1.4};
    \end{scope}

    % --- Wi-Fi
    \begin{scope}[yshift=-10cm, purple, line width=7mm]
      \fill circle (0.5);
      \foreach \d in  {0,1,2}
          \draw pic{carc=135:225:1.55+1.4*\d} pic{carc=-45:45:1.55+1.4*\d};
      \pic[line width=3.9cm]{carc=-105:-75:3.1};
    \end{scope}

    \begin{scope}[yshift=-21cm, blue]
      \fill (0,0) circle (0.5);
      \foreach \d in  {0,1,2}
        \draw[line width=7mm, line cap=round] (0,0) pic{carc=45:135:1.55+1.4*\d};
    \end{scope}

    % --- Goethe Institut
    \begin{scope}[yshift=-25cm, xshift=-5cm, green, line width=1.25 mm]
      \draw (2.5,2.5) circle (0.5);
      \foreach \d in  {0,1,...,4}
          \draw (1.5,1.5) pic{carc=90:360:0.5+0.25*\d};
      \node[anchor=north west, scale=2, black, draw] at (3.2,1.6) {\textsf{GOETHE-INSTITUT}};
    \end{scope}

    % --- off
    \begin{scope}[yshift=-29cm, line width=7mm, line cap=round]
      \draw[black] (0,0) pic{carc=130:410:2};
      \draw[red] (0,0) -- (0,2.2);
    \end{scope}

  \end{tikzpicture}
\end{document}
2

Adopted for an arc with x and y radius (ellipse).

\documentclass[10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{math}
\begin{document}
\begin{tikzpicture}

% Grid 
\draw [step = 1, black!60!white ] (0,0) grid (9,4);

\tikzmath{
   \l= 6;     % length of cylinder
   \rx= 0.5;  % x radius of ellipse
   \ry= 1.5;  % y radius of ellipse
};

% right - left
\coordinate  (A) at (2,2);
\coordinate  (B) at ($ (A) + (\l,0) $);

% B above and below
\coordinate  (Bo) at ($ (B) + (0,   \ry) $);
\coordinate  (Bu) at ($ (B) + (0,  -\ry) $);

% A above and below
\coordinate  (Ao) at ($ (A) + (0,   \ry) $);
\coordinate  (Au) at ($ (A) + (0,  -\ry) $);

% Axis
 \draw [blue] (A) -- (B);
 
 % Annotation
 \node [above] at (A) {A};
 \node [above] at (B) {B};
 \node [above] at (Ao) {Ao};
 \node [above] at (Bo) {Bo};
 \node [below] at (Au) {Au};
 \node [below] at (Bu) {Bu};
 

% Ellipse at B (right)
\draw [ultra thick] (B) ++({\rx*cos(0)},{\ry*sin(0)}) 
               arc [start angle=0, end angle=360,
                         x radius=\rx, y radius=\ry];

% Ellipse at A (left)
\draw [ultra thick] (A) ++({\rx*cos(90)},{\ry*sin(90)}) 
               arc [start angle=90, end angle=270,
                         x radius=\rx, y radius=\ry];

% lines of cylinder
\draw[ultra thick] (Ao) -- (Bo);
\draw[ultra thick] (Au) -- (Bu);

% Patch on cylinder surface
\coordinate (C) at ($(A)!0.2!(B)$);
\draw [ultra thick] (C) ++({\rx*cos(110)},{\ry*sin(110)}) coordinate (C1)
               arc [start angle=110, end angle=140,
                         x radius=\rx, y radius=\ry] coordinate (C2);
                         
\coordinate (D) at ($(A)!0.3!(B)$);
\draw [ultra thick] (D) ++({\rx*cos(110)},{\ry*sin(110)}) coordinate (D1)
               arc [start angle=110, end angle=140,
                         x radius=\rx, y radius=\ry] coordinate (D2);
                        
\draw[ultra thick] (C1) -- (D1) (C2) -- (D2);

 % Annotation
 \node [above] at (C1) {C1};
 \node [below] at (C2) {C2};
 \node [above] at (D1) {D1};
 \node [below] at (D2) {D2};
 

\end{tikzpicture}
\end{document}

enter image description here

1
  • Thanks for the beautifully written code. It's been very informative. I wish there were more annotated examples, like yours, to learn from.
    – Atcold
    Mar 23, 2022 at 18:01

You must log in to answer this question.

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