6

I'd like to draw a set of curves, each tangent to a different point on a given line. The requirement is that the curves are convex and downward sloping.

In the following MWE, I use the to[out=<x>,in=<y>] operation to manually adjust the slope of the curves so that they appear to be tangent at the desired point. This requires a lot of trial-and-errors and the result is not ideal. Is there a better way to draw such curves?

MWE

\documentclass[border=2pt,tikz]{standalone}
\begin{document}
\begin{tikzpicture}
  \foreach \i in {1,2,3,4}{
    \draw[thick](0,4.5)--(7,0)coordinate[pos=\i/5](\i);
    \fill(\i)circle[radius=2pt]node[below left]{pt \i};
    \draw[red](\i)to[out=140,in=-80]++(-1,1.5) (\i)to[out=-25,in=170]++(1.25,-.4);
  }
  \draw[<->](0,5)node[left]{$y$}--(0,0)--(8,0)node[below]{$x$};
\end{tikzpicture}
\end{document}

enter image description here

2 Answers 2

10

You could use decorations.marking, which transforms you automatically in tangent space. Then you just need to draw a curve which has slope 0 at (0,0).

\documentclass[border=2pt,tikz]{standalone}
\usetikzlibrary{decorations.markings}
\begin{document}
\begin{tikzpicture}[touching curve at/.style={postaction=decorate,
decoration={markings,mark=at position #1 with 
{\draw[touching] (-1,0.5) to[out=-45,in=180] (0,0) to[out=0,in=-135] (1,0.5);}}},
touching/.style={red}]
  \draw[thick,touching curve at/.list={1/5,2/5,3/5,4/5}](0,4.5)--(7,0);
  \draw[<->](0,5)node[left]{$y$}--(0,0)--(8,0)node[below]{$x$};
\end{tikzpicture}
\end{document}

enter image description here

0
2

Using the tzplot package:

enter image description here

\documentclass[tikz]{standalone}
    
\usepackage{tzplot}

\begin{document}

\begin{tikzpicture}
\tzhelplines(8,5)
\tzaxes(8,5){$x$}[b]{$y$}[l]
\tzcoors(0,4.5)(A)(7,0)(B);
\tzline[thick]"line"(A)(B)
\foreach \i in {1,2,3,4}
{
  \tzvXpointat*{line}{\i*7/5}(P\i){pt \i}[bl]
  % still need a few trial-and-errors
  \tzcoors($(P\i)!1.25cm!-15:(A)$)(PL\i)
          ($(P\i)!1.25cm! 15:(B)$)(PR\i);
  \begin{pgfonlayer}{background}
  \tzplotcurve[red](PL\i)(P\i)(PR\i);
  \end{pgfonlayer}
}
\end{tikzpicture}

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .