I have a certain number of points, using which I want to draw a spline/bezier curve "through" the points. When the curve is drawn, I want to automagically put along the curve p equally spaced points. (So: If my original number of points defining the curve is n, there is no relation between n and p (n can be larger than, equal to, or less than p)
Asked
Active
Viewed 295 times
1
-
2Welcome to TeX.SX! It would be great if you could show us what you have tried. Posting a minimal working example that indicates what you are trying to do makes it easier for people to understand what you want. It also makes it easier for people to help you, since they have some code to start from, and hence much more likely that some one will try to help you. – Oct 20 '18 at 21:37
1 Answers
5
You can almost literally copy the second example from p. 585 of the pgfmanual in order to get the equally spaced circles. The reason why I chose 0.9999/#1 instead of 1/# is that the last circle may disappear otherwise. The style equally spaced dots=p produces p equally spaced dots. In order to draw a smooth curve to some points I use the hobby library.
\documentclass[tikz, border=3.14mm]{standalone}
\usetikzlibrary{hobby}
\usetikzlibrary{decorations.markings}
\tikzset{equally spaced dots/.style={postaction={decorate,
decoration={markings,% switch on markings
mark=% actually add a mark
between positions 0 and 1 step 0.9999/#1
with
{
\fill circle (1pt);
}
}}}}
\begin{document}
\begin{tikzpicture}
\draw[equally spaced dots=5] (0,0) (0,0) to[curve through={(6,4) .. (4,9) .. (1,7)}]
(3 ,5);
\end{tikzpicture}
\end{document}
-
Great example! How do you remove the curve between the points? – QuantumMechanic Oct 16 '19 at 12:05
