I have a set of three regular polygons with six sides which I create using regular polygon from the shapes tikz package. However this always creates the polygon with the flat side on the bottom. How do I get one of the corners on the bottom with minimal changes to my code:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes}
\begin{document}
\begin{tikzpicture}
\def\x{0}
\def\y{0}
\def\r{1.5}
\pgfmathsetmacro\dx{\r*(1+cos(60))}
\pgfmathsetmacro\dy{\r*sin(60)}
\pgfmathsetmacro\dAx{\r*cos(60)}
\pgfmathsetmacro\dAy{\r*sin(60)}
\pgfmathsetmacro\dBx{\r*cos(120)}
\pgfmathsetmacro\dBy{\r*sin(120)}
\pgfmathsetmacro\d{2*\r}
\def\xc{\x} %mittelpunkt des aktuellen hexagons
\def\yc{\y}
\node[draw, regular polygon, regular polygon sides=6,minimum size=\d cm]
at (\x,\y) {};
\node[circle, radius=0.15cm, label=A, fill=black] (A) at (\xc+\dAx,
\yc+\dAy) {};
\node[circle, radius=0.15cm, label=below:A, fill=black] (AA) at
(\xc+\dAx,\yc-\dAy) {};
\node[circle, radius=0.15cm, label=A, fill=black] at (\xc-\r,\yc) {};
\node[circle, radius=0.15cm, label=B, fill=gray] at (\xc+\dBx,\yc+\dBy) {};
\node[circle, radius=0.15cm, label=below:B, fill=gray] at (\xc+\dBx, \yc-\dBy) {};
\def\xc{\x+\dx}
\def\yc{\y+\dy}
\node[draw, regular polygon, regular polygon sides=6,minimum size=\d cm]
at (\x+\dx,\y+\dy) {};
\node[circle, radius=0.15cm, label=A, fill=black] (AAA) at (\xc+\dAx,\yc+\dAy) {};
\node[circle, radius=0.15cm, label=right:A, fill=black] (AAAA) at (\xc+\dAx,\yc-\dAy) {};
\node[circle, radius=0.15cm, label=right:B, fill=gray] (BB) at (\xc+\r,\yc) {};
\node[circle, radius=0.15cm, label=B, fill=gray] at (\xc+\dBx,\yc+\dBy) {};
\def\xc{\x+\dx}
\def\yc{\y-\dy}
\node[draw, regular polygon, regular polygon sides=6,minimum size=\d cm]
at (\x+\dx,\y-\dy) {};
\node[circle, radius=0.15cm, label=below:A, fill=black] at (\xc+\dAx,\yc-\dAy) {};
\node[circle, radius=0.15cm, label=right:B, fill=gray] (BBB)at (\xc+\r,\yc) {};
\node[circle, radius=0.15cm, label=B, fill=gray] (B) at (\xc+\dBx,\yc+\dBy) {};
\node[circle, radius=0.15cm, label=below:B, fill=gray] (BBBB)at (\xc+\dBx,\yc-\dBy) {};
\end{tikzpicture}
\end{document}
Best Answer
shape border rotate
is the parameter that you can use to rotate ashape
node. But in this case, you also need to change where labels are placed.Unfortunately this answer will change all your code. It uses hexagon corners as reference points and also as
anchors
to place them one over the other. Hope it helps.First example is not
rotated
and second one has a 30 degree rotation.