
Quiero dibujar un oscilador en anillo, es decir, un número impar de inversores lógicos en un anillo. Tengo algunos problemas reales para colocar el anillo en correspondencia con los inversores, consulte el código adjunto. ¿Hay alguna sugerencia sobre cómo lograr esto?
\begin{center}\begin{circuitikz}
\draw
(0,3) node[not port,rotate=-360] (mynot1) {}
(2.2,1.4) node[not port,rotate=-72] (mynot2) {}
(2,-1.4) node[not port,rotate=-144] (mynot3) {}
(-2,-2) node[not port,rotate=-206] (mynot4) {}
(-2.2,1.4) node[not port,rotate=-288] (mynot5) {}
(mynot1.out) to[bend left] (mynot2.in)
(mynot2.out) to[bend left] (mynot3.in)
(mynot3.out) to[bend left] (mynot4.in)
(mynot4.out) to[bend left] (mynot5.in)
(mynot5.out) to[bend left] (mynot1.in);
\end{circuitikz} \end{center}
Respuesta1
Usar coordenadas polares sería una forma de hacerlo:
\documentclass[margin=5pt]{standalone}
\usepackage{circuitikz}
\begin{document}
\begin{circuitikz}
\draw ( -0:3) node[not port,rotate= -90] (mynot1) {}
( -72:3) node[not port,rotate=-162] (mynot2) {}
(-144:3) node[not port,rotate=-234] (mynot3) {}
(-216:3) node[not port,rotate=-306] (mynot4) {}
(-288:3) node[not port,rotate=-378] (mynot5) {}
(mynot1.out) to[bend left] (mynot2.in)
(mynot2.out) to[bend left] (mynot3.in)
(mynot3.out) to[bend left] (mynot4.in)
(mynot4.out) to[bend left] (mynot5.in)
(mynot5.out) to[bend left] (mynot1.in);
\end{circuitikz}
\end{document}
Al usar la \foreach
macro de bucle, podemos evitar el código repetido:
\ clase de documento
\documentclass[margin=5pt][margin=5pt]{standalone}
\usepackage{circuitikz}
\begin{document}
\begin{circuitikz}
\foreach \i in {0,...,4} {
\draw (-\i * 72:3) node[not port,rotate=-90 - \i * 72] (mynot\i) {};
}
\foreach[remember=\i as \j (initially 4)] \i in {0,...,4} {
\draw (mynot\j.out) to[bend left] (mynot\i.in);
}
\end{circuitikz}
\end{document}
Conseguir un círculo perfecto es más difícil. Un problema es que el circutikz
nodo not gate ya incluye segmentos de línea recta de los que no podemos deshacernos fácilmente.
Si no está configurado para usar esta puerta y está dispuesto a cambiarla por la puerta not de pgf
la circuits.logic.US
biblioteca, las cosas son un poco más fáciles. El único problema es que center
el ancla de este nodo en realidad no se encuentra en el medio de sus anclas input
y output
, lo que requiere más trucos para asegurarse de que todas las entradas y salidas realmente se encuentren en el mismo ciclo.
Por esta razón, primero dibujo un nodo falso que puedo medir y luego calculo la coordenada correcta para cada nodo. Luego puedo usar algunos cálculos para calcular el ángulo y el radio correctos de cada arco que conecta las puertas.
\documentclass[margin=5pt]{standalone}
\usepackage{circuitikz}
\usetikzlibrary{circuits.logic.US}
\begin{document}
\begin{circuitikz}[not/.style={circuit logic US,not gate}]
\newcommand\radius{2}
\newcommand\ngates{5}
% draw a hidden not gate so we can measure the distance between its input and output
\begin{pgfinterruptboundingbox}
\node[not,anchor=input,transform canvas={scale=0}] at (0, \radius) (dummynot) {};
\end{pgfinterruptboundingbox}
\foreach \i in {1,...,\ngates} {
\draw let \p0 = (dummynot.output) in % \x0 is now the "length" of the node, \y0 is the radius
(-\i * 360 / \ngates:\y0) % this is the position on the circle
++(-90 - \i * 360 / \ngates:-\x0 / 2) % this is the offset that makes the input and output lie at the same distance from the center
node[not,anchor=input,rotate=-90 - \i * 360 / \ngates] (mynot\i) {};
}
\foreach \i in {1,...,\ngates} {
\draw let \p0 = (mynot\i.output),
\p1 = (mynot\i.input),
\p2 = (dummynot.output) in
(\p0) arc[start angle={atan2(\y0, \x0)},delta angle={2 * atan2(\x2 / 2, \y2) - 360 / \ngates},radius={veclen(\p0)}];
}
\end{circuitikz}
\end{document}