7

How can I reproduce this image with TikZ.

enter image description here

Here's what I've tried.

\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{pict2e}
\usepackage{pgfplots}
\pgfplotsset{compat=1.15}
\usepackage{mathrsfs}
\usetikzlibrary{arrows}
\usetikzlibrary{fadings}
\usepackage{graphicx}
\usepackage{tikz,tkz-tab}

\usepackage[T1]{fontenc}
\usepackage{beton, euler}

\begin{document}

\begin{tikzpicture}[scale=1] 
 %simple flèche 
\tikzstyle simple=[postaction={decorate,decoration={markings, mark=at position .5 with {\arrow[scale=1,>=stealth]{>}}}}]  

%simple flèches inverse 
\tikzstyle simpleinv=[postaction={decorate,decoration={markings, mark=at position .5 with {\arrow[scale=1,>=stealth]{<}}}}] 


\def \rayon{2};
\def \i{40};
\def \r{25.4}; 

\draw (0,0) circle (\rayon); 
\foreach \y in {10,20,...,360} \draw({\rayon*cos(\y)},{\rayon*sin(\y)})--++(\y:-0.2); 
\foreach \y in {0,90,...,270} \draw[thick]({\rayon*cos(\y)},{\rayon*sin(\y)})--++(\y:-0.3); 
\draw[dotted](0,\rayon)--++(0,-2*\rayon); 
\draw[dotted](-\rayon,0)--++(2*\rayon,0); 
\end{tikzpicture}
\end{document}
6
  • 3
    Questions that look like "Please do this complicated thing for me" tend to get closed because they are either "off topic", "too broad", or "unclear". Please post some minimal code.
    – campa
    Aug 30, 2023 at 17:17
  • 2
    @Fractal, just by looking at your code fragment it's missing ate least TWO tikzlibrary. In other words: it can't compile, and each one of us has to spend some time just to make it run. PLEASE ONLY POST CODE THAT COMPILES. // Also it would be nice to include a screenshot of your current result from this code. Thank you // Somehow you have a track record for positng insufficient questions ... something relevant is always missing. Please learn and change. Thank you
    – MS-SPO
    Aug 30, 2023 at 17:27
  • Well, now you overdid it ... we are not going to skim through your many lines of code ... PLEASE DELETE WHAT'S NOT NEEDED TO MAKE YOUR FIRST CODE SNIPPET COMPILE ... it's simple as that ....
    – MS-SPO
    Aug 30, 2023 at 17:31
  • 2
  • 3
    How is this not a duplicate? What do you struggle with? What don't you like? What's that one thing the other Q&As on this site don't solve? Aug 30, 2023 at 22:36

4 Answers 4

20

I strongly recommend the use of polar coordinates (θ:r).

enter image description here

\documentclass{article}

\usepackage{tikz}

\newcommand{\rayon}{2}

\begin{document}

\begin{tikzpicture}[every node/.style={scale=.4}]
\draw[thick] (0:\rayon) arc(0:180:\rayon);
\draw (0:\rayon-.1) arc(0:180:\rayon-.1);
\foreach \t in {0,...,180}{\draw[very thin](\t:\rayon)--(\t:\rayon-.1);}
\foreach \t in {0,5,...,180}{\draw(\t:\rayon)--(\t:\rayon-.2);}
\foreach \t in {0,10,...,180}{\draw(\t:\rayon)--(\t:\rayon-.3)node[pos=1.2, rotate=\t-90]{\t};}
\foreach \t[count=\n from 0] in {0,30,...,180}{\fill(\t:\rayon-.5)circle[radius=.4pt]--++(180+\t:.2)node{$M_\n$};}
\draw(180:\rayon-.9)--(0:\rayon-.9)(90:\rayon-.9)--(0,0)node[below]{0}node[above right]{$(\Delta)$}node{$\times$};
\end{tikzpicture}

\end{document}
1
  • Maybe a TikZ piccould be more useful. Just a remark from a lazy coder. ;-)
    – projetmbc
    Aug 30, 2023 at 20:28
15

Here's one I also happened to have lying around, that might make a suitable starting point.

enter image description here

This one is done in Metapost, wrapped up in luamplib so please compile it with lualatex.

\documentclass[border=5mm]{standalone}
\usepackage{luamplib}
\usepackage{fontspec}
\setmainfont{TeX Gyre Heros}
\begin{document}
\mplibtextextlabel{enable}
\begin{mplibcode}
beginfig(1);
    color plastic; plastic = 1/256(215,205,190);

    path lower_base, upper_base, inner_arc, outer_arc;

    upper_base = (left--right) scaled 5.2 cm;
    lower_base = upper_base shifted (0,-1.6cm);
    inner_arc = halfcircle scaled 5.4cm;
    outer_arc = halfcircle scaled 8.8cm;

    % make the plastic body
    fill lower_base -- point 1 of upper_base -- outer_arc -- point 0 of upper_base -- cycle withcolor plastic;
    unfill inner_arc -- cycle;

    % draw the scale along the base
    for t = 0 upto 100:
       x := 50-t;
       draw (origin -- if x mod 10 = 0: 8 elseif x mod 5 = 0: 6 else: 5 fi up) shifted (x*mm, ypart point 0 of lower_base);
       if x mod 10 = 0:
         label.top(decimal (t/10) infont defaultfont scaled 0.7
         rotated 180, (x*mm,ypart point 0 of lower_base + 9)); 
       fi
    endfor

    % and the scale around the arc
    for t = 0 upto 180:
       draw (origin -- if t mod 10=0: 16 elseif t mod 5=0: 12 else: 8 fi left)
            shifted point 0 of outer_arc rotated t;
       if t mod 10=0:
          if t=90:
              label("90" infont defaultfont scaled 1.4, 26 down shifted point 2 of outer_arc);
          else:
              label(decimal       t infont defaultfont scaled 0.7 rotated (t-90), 22 left shifted point 0 of outer_arc rotated t);
              label(decimal (180-t) infont defaultfont scaled 0.7 rotated (t-90), 30 left shifted point 0 of outer_arc rotated t)
              withcolor .78 red;
          fi
       fi
    endfor
    
    % finally mark the middle
    draw origin -- 4 down;
    unfill fullcircle scaled 2;

endfig;
\end{mplibcode}
\end{document}
15

The package OutilsGeomTikz provides a command to draw a protactor. The package documentation and commands are in french though. I don't think an English translation of the documentation exists, as of now.

\documentclass{article}

\usepackage{OutilsGeomTikz}

\begin{document}
    \begin{tikzpicture}
        \tkzRapporteur
    \end{tikzpicture}
\end{document}

protactor outilsgeomtikz

2
  • The best answer so far. Why reinvent the wheel if someone else already did it?
    – Trang Oul
    Sep 1, 2023 at 10:22
  • @TrangOul and @others The tkz-euclide package provides a command for a protractor as well: \tkzProtractor, as answered in a question linked by Werner. The documentation of tkz-eulide is in English and the package provides many tools for drawing Euclidean geometry. Sep 1, 2023 at 11:40
12

Happen to have this lying around:

\documentclass{article}
\thispagestyle{empty}
\usepackage[landscape]{geometry}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}[scale=2]
\draw (-4,0) -- (4,0) arc[radius=4,start angle=0,delta angle=180];
\foreach \ang in {1,...,179}
{
  \pgfmathsetmacro\len{mod(\ang,5) == 0 ? .5 : .2}
  \pgfmathsetmacro\lbl{mod(\ang,5) == 0 ? \ang : ""}
  \draw (\ang:4) -- (\ang:4-\len) node[circle,anchor=\ang] {\lbl};
  \draw (\ang:2.5) -- (\ang:2.5+\len);
}
\draw (0,0) -- +(0,.5);
\draw (2.5,0) arc[radius=2.5, start angle=0, delta angle=180];
\draw (-2.45,.5) -- (2.45,.5);
\end{tikzpicture}
\end{document}

Standard protractor in degrees

You must log in to answer this question.

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