1

Rectangles when rotated do not rotate anchors. In my code example,

\documentclass[border=2mm]{standalone}
\usepackage    {tikz}
\usepackage    {siunitx} % SI units, \SI and \ang commands    
\usetikzlibrary{babel}   % There are issues with some babel packages
\usetikzlibrary{calc}    % Computing some coordinates 
%
\usetikzlibrary{fadings,decorations.pathreplacing, arrows}
\usetikzlibrary{decorations.markings}
\tikzset{fieldout/.pic={
  \fill circle(0.1);
  \draw [thick] circle(0.25);
  }
}

%----

% To make \rectangle to behave as a \node \usetikzlibrary{fit} \makeatletter \tikzset{ fitting node/.style={ inner sep=0pt, fill=none, draw=none, reset transform, fit={(\pgf@pathminx,\pgf@pathminy) (\pgf@pathmaxx,\pgf@pathmaxy)} }, reset transform/.code={\pgftransformreset} } \makeatother %---

\begin{document} \begin{tikzpicture}[scale=1, every node/.style={font=\Large, } ] % some dimensions \def\hhub{4} % height of I2C hub \def\whub{2} % width of I2C hub \def\nconn{4} % num connections in hub \def\wbeagle{5.5} % width Beagle \def\hbeagle{9} % height Beagle \def\lpin{0.14} % side of GPIO square pin \def\hacc{2} % height of accelerometer detail \def\wacc{4} % width of accelerometer detail

% % THE 3 CIRCLE SECTIONS \begin{scope}[x={(1.5cm,0cm)},y={(0cm,1.5cm)},shift={(0,0)}, thick] \foreach[count=\xk] \k in {6.5, 0, -6.5} {% \draw[dashed, thin,-latex] (-3,\k) -- (4,\k); \begin{scope}[shift={(0,\k)}] \draw[] (0,0) circle (3); \foreach[count=\xi, evaluate={\kk={ifthenelse(\k>-1, \i, \i+60)}}, ]\i in {60,180,300} {% \begin{scope}[rotate=\kk] \draw[gray,dotted] (0,0) -- (3,0); \draw[red, opacity=0.85, fill=white,fill opacity=1,] (1.3,-0.27) rectangle (2.3,0.27) node [fitting node] (acc\xk\xi) {}; \draw[black,semithick] (1.4,-0.23) rectangle (1.6,0.23) ; \draw[black,, yshift=1.1cm] (1.4,-0.24) rectangle (1.6,0.24) node[fitting node,] (I\xk\xi) {}; \foreach[evaluate={\jj={0.46*\j/(\nconn+1) }}] \j in {1, 2,3, 4} { \draw[black,fill=black, ] (1.5, -0.23+\jj) circle (0.01); \draw[black, yshift=1.1cm, semithick] (1.5, -0.23+\jj) circle (0.03); } \draw[thin,blue!50, fill=blue!50] (1.8,-0.1) rectangle (2,-0.22) node[fitting node] (G\xk\xi) {}; \end{scope}
}% \end{scope} }% \draw[black,<->,shift={(0,0)},semithick] (-180:0.5) arc (-180:-60:0.5) node [midway,below, xshift=-0.4cm] {\ang{120}}; % ARC 120º \end{scope}

% The 4 x I2C HUBs \foreach[count=\cx, ] \tx/\ty in {1/-6.8,1/0, 1/6.8, 1.75/0} {% \begin{scope}[x={(1cm,0cm)},y={(0cm,1cm)},shift={(-10\tx,\ty)}, thick] \draw[black] (-\whub/2,-\hhub/2) rectangle (\whub/2,\hhub/2); % \draw[black] (-1cm,-2cm) rectangle (1cm,2cm); \foreach[count=\xi, evaluate={\kk={\hhub\i/(\nconn+1) }}, evaluate={\sx={ifthenelse(\i<2,0cm, 2cm ) }}, evaluate={\sy={ifthenelse(\i<2,-1.25cm, 0cm ) }}] \i in {1,2,3,4} {% % into I2C hub with connections \draw[black] (-0.75,-\hhub/2+\kk-0.3) rectangle (0.75,-\hhub/2+\kk+0.3) ; \foreach[evaluate={\j={1.5\i/(\nconn+1) }}] \i in {1,2,3,4} % (1.5 = 0.75-(-0.75)) %los punticos {% \draw[black,fill=black, ] (-0.75+\j,-\hhub/2+\kk) circle (0.05); }% % out I2C hub with connections \begin{scope}[xshift=\sx , yshift=\sy] \draw[black,] (-0.75,-\hhub/2+\kk-0.225) rectangle (0.75,-\hhub/2+\kk+0.225) node[fitting node] (II\cx\xi) {}; \foreach[evaluate={\j={1.5\i/(\nconn+1) }}] \i in {1,2,3,4} % (1.5 = 0.75-(-0.75)) %los agujericos {% \draw[black,semithick, ] (-0.75+\j,-\hhub/2+\kk) circle (0.075); }% \end{scope} }% \end{scope} }% % Dimensions of the I2C Hub and text \begin{scope}[xshift=-17.5cm] \draw[black,dashed,] (-\whub/2-0.75, -\hhub/2) --++ (0.75,0); \draw[black,dashed,] (-\whub/2-0.75, \hhub/2) --++ (0.75,0); \draw[black,<->,] (-\whub/2-0.5, -\hhub/2) --++ (0, \hhub) node [midway,above,rotate=90] {\SI{4}{cm}}; % vertical dim line \draw[black,dashed,] (-\whub/2, \hhub/2) --++ (0,0.75); \draw[black,dashed,] (\whub/2, \hhub/2) --++ (0,0.75); \draw[black,<->,] (-\whub/2, \hhub/2+0.5) --++ (\whub,0) node [midway,above] {\SI{2}{cm}}; \draw[black,latex-,] (-90:-\hhub/2-1.3) -- (0, 5.5) node (T) [above, align=left] {Grove I2C Hub\ACC53133P}; \draw[black,latex-,] (50:8) -- (T); \end{scope}

%% -- CONNECTIONS -- \begin{scope}[black,very thick] % CONNECTIONS BETWEEN I2C HUBS, AND BEAGLE \draw[] (II42.south) --++(0,-9.9) -| (II11.south); \draw[] (II43.south) --++(0,-0.175) --++(2,0) --++(0,-3.5) -| (II21.south); \draw[] (II44.north) --++(0,2) -| (II31.south);

% CONNECTIONS BETWEEN I2C HUBS AND ACCELEROMETERS 
% To the TOP Circle
\draw[] (II34.north) |- (I12.west);
\draw[] (II33.north) --++(0,0.15) --++(5.5,0) --++(30:2) -- (I11.south);
\draw[] (II32.north) --++(0,0.15) --++(5.5,0) --++(30:4.7) -- (I13.north);

% To the MIDDLE Circle
% \draw[] (II24.north) --++(0,0.5) -++(5,0) to[out=0,in=-120] (I21.south);
\draw[] (II24.north) --++(0,0.5) -++(7.8,0) -- (I21.south);
\draw[] (II23.north) --++(0,0.15) --++(9,0) -- (I23.north);
\draw[] (II22.south) |- (I22.west);

% To the SOUTH Circle
\draw[] (II14.north) --++(0,0.5) --++(6.75,0) --++(-60:4.37) |- (I33.west);
\draw[] (II13.north) --++(0,0.15) --++(4.5,0) -- (I31.north);
\draw[] (II12.south) --++(0,-0.5)  --++(4.5,0) --++ (-45:5) -- (I32.north);

\end{scope}

%% -- GPIO BLUE LINE CONNECTIONS

\begin{scope}[blue,very thick] % Upper Circle section \draw[] (G11) --++ (-60:6) node[right] {\sf{P8_42}}; \draw[] (G12) --++ (0,0.5) --++(4.7,0) --++(-60:5.5) node[right] {\sf{P8_46}}; \draw[] (G13.east) --++ (30:1.5) --++ (-60:4) node[right] {\sf{P8_43}}; % Middle Circle section \draw[] (G21.east) --++ (-30:0.5) --++(-60:5) node[right] {\sf{P8_43}}; \draw[] (G22.north) --++ (0,0.25) --++(5.1,0) --++(-60:5) node[right] {\sf{P8_35}}; \draw[] (G23.east) --++ (30:1.6) --++(-60:4) node[right] {\sf{P8_39}}; % Bottom Circle Section \draw[] (G31.east) --++ (30:0.5) --++ (-60:10.7) node[right] {\sf{P8_34}}; \draw[] (G32.east) --++ (-30:2) --++ (2,0) --++(-60:5) node[right] {\sf{P8_31}}; \draw[] (G33.south) --++ (0,-1.5) --++(-60:3.8) node[right] {\sf{P8_30}}; \end{scope}

\end{tikzpicture} \end{document}

enter image description here

The lines that connect the I2C hubs with the rectangles into the circular sections do not join with the middle of the base of those rectangles when they are rotated. I am using the solution in a precedent post How to establish node-anchor-like points on a (tikz) rectangle path....

To have anchors in the rectangles as they were nodes.

The problem of the connection misfit is also in the 'blue' lines that have labels P8_XX at the right.

pablo
  • 451
  • Probably a good question, but your code is way too long. You only need to show one (or two different) instance(s) of your problem, and not your full diagram. See https://tex.meta.stackexchange.com/questions/228/ive-just-been-asked-to-write-a-minimal-working-example-mwe-what-is-that – hpekristiansen Jun 02 '21 at 22:30

1 Answers1

1

I can not see what the fitting node is doing for you. You setup complicated \foreach loops to draw nodes with indexed names and then later manually draw lines. I do not think it is worth it. Here I illustrate how you can use \pic to draw repeated elements in your diagram. -obviously you will want to use your own correct polar coordinates.

\documentclass[tikz, border=2mm]{standalone}
\begin{document}
\tikzset{
    myHub/.pic = {
    \draw[fill=white] (-1.25,-0.4) rectangle (1.25,0.4);
    \draw (-0.75,0) circle[radius=0.1] (-0.25,0) circle[radius=0.1] (0.25,0) circle[radius=0.1] (0.75,0) circle[radius=0.1];
    }}
\begin{tikzpicture}[ultra thick]
\draw (0,0) circle[radius=10];
\draw (-20,-5) pic[scale=1.5]{myHub} |- (-4,-3) pic[rotate=90]{myHub};
\draw (-20,-7) pic[scale=1.5]{myHub} |- (-5,-6) -- (-1,-3) -- (0,5) pic[rotate=-30]{myHub};
\draw (-20,-9) pic[scale=1.5]{myHub}  |- (-5,-8) -- (3,-2) -- (5,-3) pic[rotate=30]{myHub};
\end{tikzpicture}
\end{document}

Part of original diagram