1

Using LaTeX how can I draw a generic smooth closed curve (in 2D) and one other generic smooth curve joining two points on the first curve? I also need to write labels for the curves and each of the domains in which they divide the space.


The most I can do with LaTeX (with respect to drawings) is plotting cirlces, ellipses and circle arcs as follows

\usepackage{tikz}
\draw (2,2) circle (3cm);
\draw (2,2) ellipse (3cm and 1cm);
\draw (3,0) arc (0:75:3cm);
\begin{tikzpicture}
\end{tikzpicture}

Example of closed curve:

Example of Jordan curve (closed) - from Mathworld:

  • Welcome to TeX.SX! This seems a bit too generic. Can you improve your question? – egreg Jan 25 at 14:15
  • @egreg Thank you for your comment. What do you have in mind? For example, I've added a picture of closed curve that I'd like to draw. – user180244 Jan 25 at 14:19
  • TikZ has the option \draw polt[smooth cycle] coordinates {....}; and the hobby library adds many more such options. – marmot Jan 25 at 14:25
5

There is a dedicated library for that, hobby. However, something similar to your curves can be drawn with plain TikZ. Note that I didn't attempt to reproduce them very precisely since you seem to want generic curves.

\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{decorations.markings}
\begin{document}
\begin{tikzpicture}[set mark/.style args={#1 at #2}{postaction={decorate,
decoration={markings,mark=at position #2 with #1}}}]
 \begin{scope}[local bounding box=Jordan]
  \draw plot[smooth cycle] coordinates {(-2.5,0.5) (-1.5,0.5) (-1.5,-0.5)
  (-2,-0.5) (-2,0)};
  \draw plot[smooth cycle,tension=1.1] coordinates {(60:1) (-70:1) (-120:1) (110:1)};
 \end{scope}
 \node[anchor=north] at (Jordan.south) {Jordan curves};
 %
 \begin{scope}[local bounding box=nonJordan,xshift=5cm]
  \draw (-1.5,1) to[out=-110,in=180] (-1.2,-1) to[out=0,in=-70] (-0.9,1);
  \draw (-0.3,1) to[out=-110,in=0] (0,-1) to[out=180,in=-70] (0.3,1);
  \draw (1.3,-1) to[out=90,in=-90] (2.1,1) to[out=90,in=90,looseness=1.5] (1.5,1)
  to[out=-90,in=90] (1.9,-1) to[out=-90,in=-90,looseness=1.5] cycle;
 \end{scope}
 \node[anchor=north] at (nonJordan.south) {Non--Jordan curves};
 %
 \begin{scope}[xshift=10cm]
   \draw[set mark={{\node at (0,0.3) {1};}} at 0,set mark={\coordinate (1);} at 0.25,
  set mark={{\node at (0,0.3) {2};}} at 0.5,set mark={\coordinate (2);} at 0.75] plot[smooth cycle,tension=1.1] coordinates {(60:1) (-70:1) (-120:1) (110:1)};
  \draw (1) to[out=30,in=150] node[midway,below right] {3} (2);
 \end{scope}
\end{tikzpicture}
\end{document}

enter image description here

On the very right you see how one may connect two points on the curve by another curve, and how they can be labeled.

  • That's great. How do I add another smooth curve joining two points on the first one and labels in all the parts in which they divide the space? – user180244 Jan 25 at 14:48
  • @Zyl I added an example how one could do that (hoping I interpreted it correctly). – marmot Jan 25 at 14:59
  • That's great. One other thing: how can we make the picture slightly bigger? And what parameters should I change to modify the shape of that last curve a bit? For example, make it more irregular or change its shape (into something similar to the first curve)? – user180244 Jan 25 at 19:00
  • @Zyl You can make it bigger by either choosing different coordinates or saying e.g. \begin{scope}[local bounding box=Jordan,scale=1.5], i.e. add scale=.... where ... is larger than 1. So try e.g. \begin{scope}[xshift=14cm,scale=2] \draw[set mark={{\node at (0,0.3) {1};}} at 0,set mark={\coordinate (1);} at 0.25, set mark={{\node at (0,0.3) {2};}} at 0.5,set mark={\coordinate (2);} at 0.75] plot[smooth cycle] coordinates {(-2.5,0.5) (-1.5,0.5) (-1.5,-0.5) (-2,-0.5) (-2,0)}; \draw (1) to[out=150,in=-30] node[midway,above] {3} (2); \end{scope}. – marmot Jan 25 at 19:04
  • Perfect. Thanks. Can we also put a color in the various regions of the space divided by the curve? – user180244 Jan 25 at 19:26

Your Answer

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