This question is only about TikZ (/PGF) implementation. This is a MWE of what I want to ask for:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}[scale=2]
\coordinate (p1) at (1,.5);
\coordinate (p2) at (1,1);
\coordinate (p3) at (0,1);
\coordinate (p4) at (0,0);
\coordinate (p5) at (1,0);
\coordinate (p6) at (1,-1);
\coordinate (p7) at (0,-1);
\coordinate (p8) at (0,-.5);
\draw[line width=1pt,blue] (p1) \foreach \p in {p2,p3,p4,p5,p6,p7,p8} {
-- (\p)};
%% For odd points the rule is $n_{2i-1} = .5*p_{i} + .5*p_{i+1}$
%% For even points the rule is $n_{2i} = .125*p_{i-1} + .75*p_{i} + .125*p_{i+1}$
\coordinate (n1) at ($.5*(p1) + .5*(p2)$);
\coordinate (n2) at ($.125*(p1) + .75*(p2) + .125*(p3)$);
\coordinate (n3) at ($.5*(p2) + .5*(p3)$);
\coordinate (n4) at ($.125*(p2) + .75*(p3) + .125*(p4)$);
\coordinate (n5) at ($.5*(p3) + .5*(p4)$);
\coordinate (n6) at ($.125*(p3) + .75*(p4) + .125*(p5)$);
\coordinate (n7) at ($.5*(p4) + .5*(p5)$);
\coordinate (n8) at ($.125*(p4) + .75*(p5) + .125*(p6)$);
\coordinate (n9) at ($.5*(p5) + .5*(p6)$);
\coordinate (n10) at ($.125*(p5) + .75*(p6) + .125*(p7)$);
\coordinate (n11) at ($.5*(p6) + .5*(p7)$);
\coordinate (n12) at ($.125*(p6) + .75*(p7) + .125*(p8)$);
\coordinate (n13) at ($.5*(p7) + .5*(p8)$);
\draw[line width=3pt] (n1) \foreach \n in {n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13} {
-- (\n)};
\end{tikzpicture}
\end{document}
The point is that I want to compute all the n1,...,n13 coordinates found by the cubic B-spline curve refinement considering the initial points p1,...,p8 with a \foreach
instructions and NOT by hand as was shown, but I don't know how to use many points in the \foreach
list at the same iteration. If you could also generate the new points as a list or array will be nice.
Please do that in the more general way, considering as many as possible initial points (not just 8) and the possibility of many points used in the same iteration. Think that for me this question is the tip of the iceberg!