1

I tried relative coordinates, but couldn't put a coordinate in to make angles. Is this possible?

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{quotes,angles,calc,plotmarks,decorations.text}
\begin{document}   
\begin{tikzpicture}
    \draw[red,fill=red] (3:0) circle (.5ex);

%\draw[help lines] (-1,0) grid (5,5);
%\draw (0,0) --++(2,0) --++(72:2)--++(144:1.75)--++(210:1.75) --cycle ; \draw (0,0) --(2,0) -- (2.5,2) -- (1,3) --(-0.5,2) --cycle ;

\coordinate (a) at (0,0); \coordinate (b) at (2,0); \coordinate (c) at (2.5,2); \coordinate (d) at (1,3); \coordinate (e) at (-0.5,2);

\node[align=center, below ] at (a) {1};
\node[align=center, below ] at (b) {2}; \node[align=center,right ] at (c) {3}; \node[align=center,above ] at (d) {4}; \node[align=center,left ] at (e) {5};

%\pic [draw, -, "$\alpha_0$", angle eccentricity=1.5] {angle = c--b--a}; \pic [draw, -, "$\alpha_1$", angle eccentricity=1.5] {angle = a--e--d}; \pic [draw, -, "$\alpha_2$", angle eccentricity=1.5] {angle = e--d--c}; \pic [draw, -, "$\alpha_3$", angle eccentricity=1.5] {angle = d--c--b}; \pic [draw, -, "$\alpha_3$", angle eccentricity=1.5] {angle = b--a--e};

\draw pic[draw,fill=green!30,angle radius=0.4cm,"$ $" shift={(0mm,-5mm)}] {angle= c--b--a};

\end{tikzpicture} \end{document}

Sigur
  • 37,330
Jon
  • 525
  • 1
  • 3
  • 11
  • It is not clear what you want but to draw a regular pentagon you can use polar coordinates and put the center of it on the origin. In other words, the vertices should be on a circle evenly distributed. – Sigur Jul 28 '23 at 16:49
  • Thanks for the quick reply, my pentagon doesn't have vertices at 108 degrees, and the sides are not all the same I would like a regular pentagon in which I can mark the angles as I've done above, and two dashed lines on the sides showing that they are the same. There are lots of pentagons on this site, but none of them meet the requirement – Jon Jul 28 '23 at 17:28
  • 2
    You can draw a regular pentagon using \draw[blue] (0,0) --++(2,0) --++(72:2)--++(144:2)--++(216:2) --cycle; The interior angles are 180 - 72 = 108 degrees. – John Kormylo Jul 28 '23 at 21:21
  • Thank you John for your answer, and I've now found out how to put coordinates in your code as in this example \drawscale=3, thick coordinate (a)--+(2,0) coordinate (b)--+(90:1) coordinate (c) --cycle; so I can use the code to color the angles \draw pic[draw,fill=green!30,angle radius=0.4cm,"$ $" shift={(0mm,-5mm)}] {angle= c--b--a}; – Jon Jul 29 '23 at 05:26

1 Answers1

6

There are plenty of ways to find the corners of a regular pentagon.

Here I'm just using absolute polar coordinates, the first one and the last one gets aliases that make it easier to reference them later in a loop.

The mark with dashes = <num> pic draws <num> slanted lines which we will place along the sides.

Code

\documentclass[tikz]{standalone}
\usetikzlibrary{angles, quotes}
\tikzset{
  mark with dashes/.style={
    every to/.append style={edge node={pic{mark with dashes={#1}}}}},
  pics/mark with dashes/.style={
    /tikz/sloped, /tikz/allow upside down, /tikz/line width=+.4pt,% thin
    code={
      \foreach \i in {1, ..., #1}
        \draw[line cap=round, shift=(left:{\i pt-(#1+1)/2}), pic actions]
          (-1pt, -2pt) -- (1pt, 2pt);}}}
\begin{document}
\begin{tikzpicture}[angle eccentricity=1.5]
\foreach[count=\j from 0, count=\i] \p in {below, below, right, above, left}
  \coordinate["$\i$" \p] (c\i) at (90+72*2+\j*72:2);
\node also[alias=c0] (c5) node also[alias=c6] (c1);
\foreach[count=\j from 2, count=\k from 0] \i in {1, ..., 5}
  \pic[draw, "$\alpha_\i$"] {angle=c\j--c\i--c\k};
\draw[mark with dashes=2, thick] (c1) to (c2) to (c3) to (c4) to (c5) to cycle;
\end{tikzpicture}
\end{document}

Output

enter image description here

Qrrbrbirlbel
  • 119,821
  • I'm not quite sure how the angles should be labeled and styled. – Qrrbrbirlbel Jul 29 '23 at 02:41
  • Just beautiful, beautiful, can I ask you to put in one line of code or more if necessary to color the angles, then I will mark as answered. I will need at least a week to work on your code to understand it – Jon Jul 29 '23 at 05:23
  • Just added fill=green!30 to \pic[draw, fill=green!30, "$ x ^ \circ $"] {angle=c\j--c\i--c\k}; – Jon Jul 29 '23 at 12:41