1

Why I am only getting one point of intersection read by the program? Solution is to breaking to two parts with tangent lines drawn at different lengths.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,intersections}
\usetikzlibrary{decorations.markings}
\begin{document}
\pgfkeys{tikz/.cd,
 tangent length/.store in=\TangentLength,
 tangent length=3.14cm,
 normal length/.store in=\NormalLength,
 normal length=7mm}
 \newcounter{tangent}
 \newcounter{normal}
 \tikzset{tangent/.style={red,thin},normal/.style={blue,thin},
 tangent at/.style={postaction={decorate,decoration={markings,
 mark=at position #1 with {\stepcounter{tangent}
 \draw[tangent,name path=tangent-\thetangent] (-\TangentLength,0) -- 
 (9cm,0);
 \fill[tangent] (0,0) circle (2pt);}}}},
  normal at/.style={postaction={decorate,decoration={markings,
   mark=at position #1 with {\stepcounter{normal}
 \draw[normal,name path=normal-\thenormal] (0,-\NormalLength) -- 
 (0,\NormalLength);
 \fill[normal] (0,0) circle (2pt);}}}}, 
 }
 \begin{tikzpicture}
 % Axes
 \draw [-latex] (-1,0) -- (11,0) node [right] {$x$};
 \draw [-latex] (0,-1) -- (0,6) node [above] {$y$};
 % Origin
 \node at (0,0) [below left] {$0$};
 % Points
 \coordinate (start) at (1,-0.8);
 \coordinate (c1) at (3,3);
 \coordinate (c2) at (5.5,1.5);
 \coordinate (c3) at (8,4);
 \coordinate (end) at (10.5,-0.8);
 % show the points
 % \foreach \n in {start,c1,c2,c3,end} \fill [black] (\n)
 %     circle (2pt) node [below] {}; 
 %  join the coordinates
\draw [name path=curve,thick,tangent at/.list={0.3,0.3},
  normal at/.list={}] (start) to[out=70,in=180] (c1) to[out=0,in=180]
  (c2) to[out=0,in=180] (c3) to[out=0,in=150] (end);
 \fill[name intersections={of=curve and tangent-2,total=\t},cyan]
 (intersection-\t) circle (2pt);
  \fill[name intersections={of=curve and tangent-1,total=\t},cyan]
  (intersection-\t) circle (2pt);
 \end{tikzpcicture}
 \end{document}

This outputs:

enter image description here

  • Please replace ` \end{tikzpcicture}` by ` \end{tikzpicture}`. – user121799 Nov 25 '18 at 0:04
1

The style tangent at=<pos> attaches a tangent at position pos. So tangent at/.list={0.3,0.3} will just create two identical tangents. However, this has nothing to do with the intersections. Rather, you want to mark the last two intersections of the tangent with the curve. (TikZ finds more intersections since a tangent of course runs very close to the curve, so some of the additional intersections are not true intersections but result from numerical inaccuracies.)

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,intersections}
\usetikzlibrary{decorations.markings}
\begin{document}
\pgfkeys{tikz/.cd,
 tangent length/.store in=\TangentLength,
 tangent length=3.14cm,
 normal length/.store in=\NormalLength,
 normal length=7mm}
 \newcounter{tangent}
 \newcounter{normal}
 \tikzset{tangent/.style={red,thin},normal/.style={blue,thin},
 tangent at/.style={postaction={decorate,decoration={markings,
 mark=at position #1 with {\stepcounter{tangent}
 \draw[tangent,name path=tangent-\thetangent] (-\TangentLength,0) -- 
 (9cm,0);
 \fill[tangent] (0,0) circle (2pt);}}}},
  normal at/.style={postaction={decorate,decoration={markings,
   mark=at position #1 with {\stepcounter{normal}
 \draw[normal,name path=normal-\thenormal] (0,-\NormalLength) -- 
 (0,\NormalLength);
 \fill[normal] (0,0) circle (2pt);}}}}, 
 }
 \begin{tikzpicture}
 % Axes
 \draw [-latex] (-1,0) -- (11,0) node [right] {$x$};
 \draw [-latex] (0,-1) -- (0,6) node [above] {$y$};
 % Origin
 \node at (0,0) [below left] {$0$};
 % Points
 \coordinate (start) at (1,-0.8);
 \coordinate (c1) at (3,3);
 \coordinate (c2) at (5.5,1.5);
 \coordinate (c3) at (8,4);
 \coordinate (end) at (10.5,-0.8);
 % show the points
 % \foreach \n in {start,c1,c2,c3,end} \fill [black] (\n)
 %     circle (2pt) node [below] {}; 
 %  join the coordinates
\draw [name path=curve,thick,tangent at=0.3] (start) to[out=70,in=180] (c1) to[out=0,in=180]
  (c2) to[out=0,in=180] (c3) to[out=0,in=150] (end);
 \fill[name intersections={of=curve and tangent-1,total=\t},cyan]
 \pgfextra{\pgfmathtruncatemacro{\prevt}{\t-1}}
 foreach \i in {\prevt,\t} {(intersection-\i) circle (2pt)};
\end{tikzpicture}
\end{document}

enter image description here

  • @Thank Marmot. You are a tremendous help to me! – MathScholar Nov 25 '18 at 0:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.