[Tex/LaTex] Drawing a curve with TikZ

tikz-pgf

I want to draw something like this using TikZ:

curve example

I can probably make the curve using controls but that wouldn't allow me to draw the points on it.

Best Answer

You could use the intersections library. Here is a modified version of one of the examples from the pgfmanual (TikZ 2.0). It's reasonable close to your figure and you should be able to modify it.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{intersections}
\begin{document}
\begin{tikzpicture}
\clip (-2,-2) rectangle (2,2);
\draw [name path=curve] (-2,1) .. controls (8,1) and (-8,-1) .. (2,-1);
\path[name path=line 1] (0,-2) -- (0,2)  (-1,-2) -- (-1,2) (1,-2) -- (1,2);
\draw [name intersections={of=curve and line 1, name=i}] 
  (i-6) -- (i-7) (i-5) -- (i-8);
\draw [name intersections={of=curve and line 1, name=i},name path=line 2]
  (i-5) --(i-3) -- (i-7) (i-6) -- (i-2) -- (i-8); 

\fill [name intersections={of=curve and line 1, name=i}][blue, opacity=0.5]
\foreach \s in {1,2,3,5,6,7,8}{(i-\s) circle (2pt)};

\fill [name intersections={of=curve and line 2, name=i}][blue, opacity=0.5]
\foreach \s in {5,7}{(i-\s) circle (2pt) node {\footnotesize\s}};
\end{tikzpicture}
\end{document}

This might be better?

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{intersections}

\begin{document}
\begin{tikzpicture}

\path[name path=circle] 
  (0,0) circle (2cm);

\path[name path=cross] 
  (-2,-2) -- (2,2) 
  (-2,2) -- (2,-2) 
  (0,2) -- (0,-2);

\draw [% 
  name intersections={of=circle and cross, name=i},
  name path=line
] 
  (i-1) -- (i-5) -- (i-3) 
  (i-4) -- (i-2) -- (i-6) 
  (i-1) -- (i-4) 
  (i-3) -- (i-6);

\fill [% 
  name intersections={of=line and line, name=i}
] [blue, opacity=0.5]
  \foreach \s in {1,2,3,6,8,10,11,21,25}{(i-\s) circle (2pt)};

\draw [%
  name intersections={of=line and line, name=i}
]
  (i-8) ++(-0.5,0) -- (i-8) 
    to[out=45,in=180]  (i-10) 
    to[out=0,in=135]   (i-3)
        to[out=-45,in=0]   (i-2)
    to (i-21) to (i-6) 
    to[out=180,in=135] (i-11)
    to[out=-45,in=180] (i-1)
    to[out=0,in=225]   (i-25) 
    --++(0.5,0);

\end{tikzpicture}
\end{document}
Related Question