TikZ: conecta un rectángulo con una línea horizontal y marca la intersección con un punto

TikZ: conecta un rectángulo con una línea horizontal y marca la intersección con un punto

Estoy luchando con el problema de cómo conectar un nodo rectangular y una línea vertical sin usar coordenadas absolutas. La intersección de las dos líneas debe marcarse con un punto. Tengo la fuerte sensación de que debe haber una manera más elegante de lograrlo.

gracias marcel

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,arrows.meta,positioning,decorations.pathreplacing}
\usetikzlibrary{intersections}

\begin{document}

\begin{figure}
\begin{tikzpicture}
\draw[thick] (-4,10) node (dpdata) [above]  {Data} -- (-4,0);

\node[  draw,
        align=center,
        left=of dpdata,
        yshift=-4cm,
        minimum width=2cm,
        minimum height=3cm,
        ] (ram) {Transient \\ Memory \\ (RAM)};

\node[  draw,
        align=center,
        above=of ram,
        minimum width=1.5cm,
        minimum height=1cm
        ] (mar) {MAR};

\node[  draw,
        align=center,
        below=of ram,
        minimum width=1.5cm,
        minimum height=1cm
        ] (mdr) {MDR};


\draw[color=blue,thick] (mar.east) -- (-4,9.25);
\fill (-4,9.25) circle [radius=2pt];

\draw[color=blue,thick] (mdr.east) -- (-4,3.25);
\fill (-4,3.25) circle [radius=2pt];

\draw[color=blue,thick] (mdr.north) -- (ram.south);
\draw[color=blue,thick] (mar.south) -- (ram.north);


\end{tikzpicture}
\end{figure}

\end{document}

ingrese la descripción de la imagen aquí

Respuesta1

Siempre que todos tus puntos y conexiones estén en una cuadrícula rectangular, puedes usar esta sintaxis simple y elegante para extraer coordenadas (doy un ejemplo simple):

\begin{tikzpicture}

\path
(0,0) node[draw] (joe) {Joe}
(2,2) node[draw] (blow) {Blow};
;

\draw[blue] (joe -| blow) circle (2pt);

\end{tikzpicture}

el -|operador extraerá la coordenada x del primer punto (joe) y la coordenada y del segundo (golpe).

Respuesta2

¿Como esto?

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{arrows.meta, calc, chains, intersections, positioning}

\begin{document}
    \begin{tikzpicture}[
node distance = 3mm and 9mm,
  start chain = going below,
   box/.style = {rectangle, draw,
                 text width=22mm, align=center, inner sep=2mm,
                 on chain}
                        ]
\node (mar) [box]  {MAR};  
\node (ram) [box]  {Transient Memory (RAM)};
\node (mdr) [box]  {MDR};
%
\coordinate[above right=of mar] (data);
\draw[thick, name path=A] (data) node[above]  {Data} -- + (0,-4);
\path[overlay,name path=B] (mar) -- ++ (3,0);  
\path[overlay,name path=C] (mdr) -- ++ (3,0);
%
\draw[color=blue,thick,fill,
      name intersections={of=A and B, by={a}}]   
      (mar) -- (a) circle (2pt);
\draw[color=blue,thick,fill,
      name intersections={of=A and C, by={b}}]
      (mdr) -- (b) circle (2pt);
\draw[color=blue,thick] (mar) -- (ram)  (ram) -- (mdr);
    \end{tikzpicture}
\end{document}

Apéndice: Oferta de solución más sencillaMichael Palmerrespuesta. Si lo adopta al MWE anterior, puede simplemente escribir:

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{arrows.meta, calc, chains, intersections, positioning}

\begin{document}
    \begin{tikzpicture}[
node distance = 3mm and 9mm,
  start chain = going below,
   box/.style = {rectangle, draw,
                 text width=22mm, align=center, inner sep=2mm,
                 on chain}
                        ]
\node (mar) [box]  {MAR};  
\node (ram) [box]  {Transient Memory (RAM)};
\node (mdr) [box]  {MDR};
%
\coordinate[above right=of mar] (data);
\draw[thick] (data) node[above]  {Data} -- + (0,-4);% changed
\draw[color=blue,thick,fill]
      (mar) -- (mar -| data) circle (2pt)% changed
      (mdr) -- (mdr -| data) circle (2pt)% changed
      (mar) -- (ram)
      (ram) -- (mdr);
    \end{tikzpicture}
\end{document}

El resultado es el mismo que antes.

ingrese la descripción de la imagen aquí

información relacionada