4

I want to put small round markings at fixed distances on a six-pointed star.

There are two problems though: pos=0.0 is not at the expected location, but slightly shifted possibly due to the rounded corners style. I want to have small dots on all the corners, how can I fix this?

Furthermore, there is an additional problem: when using a step size of 0.013888, the MWE does not compile. However, with a step size of 0.05 is used, it does compile. The error is: Dimension too large (on line 20).

MWE:

\documentclass[tikz]{standalone}

\usetikzlibrary{decorations.markings}


\begin{document}

\begin{tikzpicture}[
  every node/.style={inner sep=0pt,outer sep=0pt,minimum width=0pt},
  decoration={
  markings,
  mark=between positions 0 and 1.0 step 0.013888 with %
    {\node[draw, circle, minimum width=1pt,anchor=center]{};}}] 
  \foreach \x in {0,1,...,5} {
    \path (12,-3) ++(30+60*\x:3) coordinate (s\x);
    \path (12,-3) ++(60*\x:1.7320508076) coordinate (si\x);
  }
  \draw[postaction={decorate},thick,rounded corners] (si0) -- (s0) -- %
    (si1) -- (s1) -- (si2) -- (s2) -- (si3) -- (s3) -- (si4) -- (s4) -- %
    (si5) -- (s5) -- cycle;      

\end{tikzpicture}

\end{document}

figure

1

I am just a newbie when it comes to working with tikz but I gather that the algorithm to calculate rounded corners is such that they cannot go exactly through the nodes (indicated by red circles below). I have drawn two paths to show this, a black one with the rounded corner, and a red one without rounded corners but showing the decorations (small circles) at each node.

\documentclass[tikz]{standalone}

\usetikzlibrary{decorations.markings}


\begin{document}

\begin{tikzpicture}[
  every node/.style={inner sep=0pt,outer sep=0pt,minimum width=0pt},
  decoration={
  markings,
  mark=between positions 0.0 and 1.0 step 0.08333 with %
         %% 0.08333 \approx 1/12
    {\node[draw, circle, minimum width=3pt,anchor=center]{};}}] 
  \foreach \x in {0,1,...,5} {
    \path (12,-3) ++(30+60*\x:3) coordinate (s\x);
    \path (12,-3) ++(60*\x:1.7320508076) coordinate (si\x);
  }
  \draw[thick,rounded corners] (si0) -- (s0) -- %
    (si1) -- (s1) -- (si2) -- (s2) -- (si3) -- (s3) -- (si4) -- (s4) -- %
    (si5) -- (s5) -- cycle;      
  \draw[postaction={decorate}, color=red] (si0) -- (s0) -- %
    (si1) -- (s1) -- (si2) -- (s2) -- (si3) -- (s3) -- (si4) -- (s4) -- %
    (si5) -- (s5) -- cycle;  

\end{tikzpicture}

\end{document}

star with circles

1

Without use of the decorations.markings, for fun :-)

\documentclass[tikz, margin=3mm]{standalone}

\begin{document}
    \begin{tikzpicture}[
  dot/.style = {circle, draw, semithick,  
                inner sep=0pt, minimum size=3pt,
                node contents={}},
                        ]
\foreach \x in {0,1,...,5} 
{
\path (30+60*\x:3) coordinate (s\x)  ++ (30+60*\x:-2pt) node [dot];
\path (60*\x:1.73) coordinate (si\x) ++ (60*\x:+1pt) node [dot];
  }
\draw[semithick,rounded corners=4pt] 
    (si0) -- (s0) -- (si1) -- (s1) -- (si2) -- (s2) -- (si3)
          -- (s3) -- (si4) -- (s4) -- (si5) -- (s5) -- cycle;
    \end{tikzpicture}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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