How can I create a curve by providing the coordinates of points 1-4.
Asked
Active
Viewed 1,522 times
0
-
2Have you seen https://tex.stackexchange.com/q/490374/117050? – Skillmon Mar 16 '20 at 11:16
-
Thx thats exactly what I was searching for! – Iskandar The Pupsi Mar 16 '20 at 11:29
2 Answers
2
Does this work for you?
\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw [gray] (0,0) -- (1,1) -- (2,0.75) -- (3,2);
\draw [red] plot [smooth, tension=0.6] coordinates { (0,0) (1,1) (2,0.75) (3,2)};
\end{tikzpicture}
\end{document}
The tension parameter lets you specify how much curvature you want in your smoothed spline. The output of the above code should provide you with something like this:

pbaer
- 370
2
Your curve seems to be defined by the slopes at some critical points. The hobby library is a great tool to draw such curves, see e.g. here for a survey of options. You can then specify the in angle, out angle and slope via tangent.
\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{hobby}
\begin{document}
\begin{tikzpicture}[tangent/.style={%
in angle={(180+#1)},Hobby finish,
designated Hobby path=next,out angle=#1},
pics/vert/.style={code={\draw (0,-0.1) -- (0,0.1) node[above]{#1};}}]
\draw [thick,use Hobby shortcut]
([out angle=45]0,0) pic{vert=1} .. ([tangent=0]1.5,1) pic{vert=2}
.. ([tangent=0]3,-0.25) pic{vert=3} .. ([in angle=225]4.5,1) pic{vert=4};
\end{tikzpicture}
\end{document}

