Skip to content

The flower snarks

March 10, 2011
tags: ,

I’m using the new rotation option for cycles to define a macro that draws a flower snark. The macro has as optional arguments the radius RA, RB, and RC of the three types of vertices, and a mandatory argument which must be an odd natural number.

\newcommand{\grFlowerSnark}[2][]{%
  \begingroup
  \setkeys[GR]{cl}{#1}%
  \edef\tkzb@rtemp{\cmdGR@cl@RA}
  \edef\tkzb@rtempx{\cmdGR@cl@RB}
  \edef\tkzb@ptemp{\cmdGR@cl@RC}
  \pgfmathsetcounter{tkz@gr@a}{(#2-1)/2}
  \pgfmathsetcounter{tkz@gr@b}{(#2+1)/2}
  \grCycle[RA=\tkzb@ptemp,prefix=b,rotation=90]{#2}
  \grEmptyCycle[RA=\tkzb@rtempx,prefix=a,rotation=90]{#2}
  \pgfmathsetmacro{\smallshift}{360/(5*#2)}
  \grEmptyCycle[RA=\tkzb@rtemp,prefix=c,rotation=90+\smallshift]{#2}
  \grEmptyCycle[RA=\tkzb@rtemp,prefix=d,rotation=90-\smallshift]{#2}
  \EdgeIdentity{a}{b}{#2}
  \EdgeIdentity{a}{c}{#2}
  \EdgeIdentity{a}{d}{#2}
  \Edge(c\thetkz@gr@a)(d\thetkz@gr@b)
  \pgfmathsetcounter{tkz@gr@c}{\thetkz@gr@a-1}
  \pgfmathsetcounter{tkz@gr@d}{\thetkz@gr@b+1}
  {\tikzset{EdgeStyle/.append style = {bend right=90}}
    \EdgeDoubleMod{c}{#2}{0}{1}{c}{#2}{1}{1}{\thetkz@gr@c}
    \EdgeDoubleMod{c}{#2}{\thetkz@gr@b}{1}{c}{#2}{\thetkz@gr@d}{1}{\thetkz@gr@c}
    \EdgeDoubleMod{d}{#2}{0}{1}{d}{#2}{1}{1}{\thetkz@gr@c}
    \EdgeDoubleMod{d}{#2}{\thetkz@gr@b}{1}{d}{#2}{\thetkz@gr@d}{1}{\thetkz@gr@c}
  }
  \Edge[style={bend right=90}](d\thetkz@gr@a)(c\thetkz@gr@b)
  \endgroup
}

So that, for example:

\begin{tikzpicture}
  \SetVertexNormal[MinSize=10pt]
  \grFlowerSnark[RA=4,RB=2.5,RC=1]{5}
\end{tikzpicture}

gives:

Flower snark

Advertisements
No comments yet

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: