Graphics, Figures & TablestikZ | Place Node at Intersection between Arc and Line

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
drgz
Posts: 44
Joined: Sat Apr 18, 2009 8:40 pm

tikZ | Place Node at Intersection between Arc and Line

Post by drgz »

Hello,

I posted the same question at {TeX} SE, but I'll ask here as well.

I'm trying to figure out how to place a shape/node at the intersection point between an arc and some horizontal lines in TikZ, preferably by using the \foreach command that TikZ provides as there are multiple horizontal lines that intersects the arc (see code below).

I'd assume it could be done using intersection command in TikZ (p. 110 in manual), but I can't make it work as I can't figure out what to write for the arc in the intersection command (the horizontal lines I can provide by making nodes at two the start and end of the lines), i.e.

Code: Select all

\draw[semithick,dashed] (5.1,9.6) arc(0:-60:5.15);
\foreach \y in {5.25,5.75,...,9.25}
{
    \node (x1y1\y) at (2.25,\y) {};
    \node (x2y1\y) at (5.5,\y) {};
    \coordinate  (c\y)  at (intersection of XXX and x1y1\y--x2y1\y);
    \draw (c\y) \pulse; % \pulse is defined in the code below
}
but what to write for XXX, which should represent the arc?

Any help/hint is appreciated!

Best regards,
drgz

Code: Select all

\tikzstyle{branch} = [circle, inner sep = 0pt, minimum size = 0.5mm, fill = black, draw = black]

   \pgfdeclarelayer{background}
   \pgfdeclarelayer{foreground}
   \pgfsetlayers{background,main,foreground}

   \begin{tikzpicture}[semithick,>=latex']
	\def\pulse{+(0.1,0) -- +(0.2,0.1) -- +(0.3,-0.1) -- +(0.4,0)}

	\node[branch] (fp) at (-2,10) {};
	\node[above] at (fp.north) {\scriptsize Focal point};
	
	% draw rectangle in array
	\draw[semithick] (2,9.5) -- (2.25,9.5) -- (2.25,5) -- (2,5) -- cycle;
	
	% draw horizontal lines inside array
	\foreach \y in {5,5.5,...,9}
		\draw[semithick] (2,\y) -- (2.25,\y);
	\node[above] at (2.125,9.5) {\scriptsize Array};
	
	\foreach \y in {5.25,5.75,...,9.25}
	{
		% draw lines from focal point to array
		\draw[semithick,->] (fp.center) -- (2,\y);
		
		% draw VGA amplifiers
		\draw[semithick,fill=white] (5.5,\y) -- ($(5.5,\y)+(0,0.2)$) -- (6,\y) -- ($(5.5,\y)+(0,-0.2)$) -- cycle;
		% draw arrows thru VGA amplifiers
		\begin{pgfonlayer}{background}
			\draw[semithick,->] ($(5.6,\y)+(0,-0.25)$) -- ($(5.95,\y)+(0,0.2)$);
		\end{pgfonlayer}
		
		% draw ADC
		\draw[semithick] (6.2,\y) -- ($(6.4,\y)+(0,0.2)$) -- ($(7.2,\y)+(0,0.2)$) -- ($(7.2,\y)+(0,-0.2)$) -- ($(6.4,\y)+(0,-0.2)$) -- cycle;
		\node[] at (6.7,\y) {\scriptsize ADC};
		
		% draw FIFO block
		\draw[semithick] (7.6,\y) -- ($(7.6,\y)+(0,0.2)$) -- ($(8.4,\y)+(0,0.2)$) -- ($(8.4,\y)+(0,-0.2)$) -- ($(7.6,\y)+(0,-0.2)$) -- cycle;
		\node[] at (8,\y) {\scriptsize FIFO};
		
		% draw lines in between the blocks already drawn
		\draw[semithick,->] (2.25,\y) -- (5.5,\y);
		\draw[semithick,->] (6,\y) -- (6.2,\y);
		\draw[semithick,->] (7.2,\y) -- (7.6,\y);
		\draw[semithick,->] (8.4,\y) -- (9,\y) -- ($(9,\y)+(0,0.2)$) -- ($(9.2,\y)+(0,0.2)$) -- (9.2,\y) -- (10,\y);
	}
	
	% draw arc before array
	\draw[semithick,dashed] (2,9.6) arc(0:-60:5.15);
	% draw arc after array
	\draw[semithick,dashed] (5.1,9.6) arc(0:-60:5.15);
	
	% draw rectangle for digital adder
	\draw[semithick] (10,9.5) -- (10.5,9.5) -- (10.5,5) -- (10,5) -- cycle;
	\node[rotate=90] at (10.25,7.25) {\scriptsize Digital adder};
	
	% draw output signal
	\draw[semithick,] (10.5,7.25) -- (11,7.25) -- (11,7.75) -- (11.25,7.75) -- (11.25,7.25) -- (11.5,7.25);
	\node[above] at (11.125,7.75) {\scriptsize$\begin{matrix}\text{Output}\\\text{signal}\end{matrix}$};
	
	% draw arrow for sampling clock
	\draw[semithick,->] (6.7,4.5) -- (6.7,5.05);
	\node[below] at (6.7,4.5) {\scriptsize Sampling clock};
	
	% draw line in between every ADC
	\foreach \y in {5.25,5.75,...,8.75}
		\draw[semithick] ($(6.7,\y)+(0,0.2)$) -- ($(6.7,\y)+(0,0.3)$);
		
    \end{tikzpicture}
Last edited by drgz on Mon Aug 01, 2011 11:35 am, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

drgz
Posts: 44
Joined: Sat Apr 18, 2009 8:40 pm

tikZ | Place Node at Intersection between Arc and Line

Post by drgz »

Minor progress; figured out what to write instead of XXX in the intersection command, so now it will looke like

Code: Select all

\draw[name path=myArc,semithick,dashed] (5.1,9.6) arc(0:-60:5.15);
\foreach \y in {5.25,5.75,...,9.25}
{
    \node (x1\y) at (2.25,\y) {};
    \node (x2\y) at (5.5,\y) {};
    \coordinate  (c\y)  at (intersection of myArc and x1\y--x2\y);
    \draw (c\y) \pulse; % \pulse is defined in the code below
}
But it still doesn't work.
drgz
Posts: 44
Joined: Sat Apr 18, 2009 8:40 pm

tikZ | Place Node at Intersection between Arc and Line

Post by drgz »

Got an answer on tex.stackexchange. Just posting the answer here.

***********************************************************************************
You can use the intersections library for this. To use it, give the paths you want to intersect a name using name path, then name the intersections using intersections={of=<path 1> and <path 2>}. The intersections will then be available as intersection-1, intersection-2, etc.

Code: Select all

\documentclass[12pt]{article}

\usepackage{tikz}
\usetikzlibrary{intersections}

\begin{document}


\begin{tikzpicture}
\def\pulse{+(0.1,0) -- +(0.2,0.1) -- +(0.3,-0.1) -- +(0.4,0)}


\draw[semithick,dashed,name path=arcafter] (5.1,9.6) arc(0:-60:5.15);

\foreach \y in {5.25,5.75,...,9.25}
{
    \draw[semithick,->,name path=arrow] (2.25,\y) -- (5.5,\y);
    \draw[name intersections={of=arcafter and arrow}] (intersection-1) ++(-0.2,0) \pulse;
}

\end{tikzpicture}

\end{document}
Post Reply