I would like to save coordinates along the path to further morph them and produce several more paths. Currently, I have a solution based on decorations.markings
which seems to be almost working, yet so far only the coordinate counter is being incremented instead.
Here is the current picture produced:
The path along which I attempt to save coordinates starts at the top of the upper circle inside the circle representing and ends on the circle representing (the image of the corresponding function).
The full source code will be provided in the end of the question.
There on lines 11 through 30 you can find the declaration and initialization of the coordinate counter and the tikzset
s with style
s and code
s that are desired to save the coordinates. For convenience, I will duplicate them here:
\newcounter{coordinateindex}
\setcounter{coordinateindex}{0}
\tikzset{
stepcounter/.code={
\stepcounter{coordinateindex}
}
}
\tikzset{
save coordinates/.style={
decoration={markings,
mark=at position 0 with { \coordinate (coordinate\thecoordinateindex); },
mark=between positions 0 and 1 step 0.1 with {
\coordinate[preaction=stepcounter] (coordinate\thecoordinateindex);
}
},
postaction={decorate}
}
}
You can ignore the fact that the first coordinate is saved twice.
On line 159 the save coordinates
style
is applied to the path:
\draw[L1,very thick,save coordinates] (FarEndX1) arc[start angle=180,end angle=160,x radius=100, y radius = 10] coordinate(Img1);
Once again, how do I save a chosen number of coordinates along the path in Tikz? I did not find an answer in the Tikz&PGF manual for Version 3.1.9.a.
\documentclass[12pt]{article}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}
\usetikzlibrary{intersections}
\usetikzlibrary{calc}
\usetikzlibrary {decorations.markings}
\begin{document}
\begin{tikzpicture}
\newcounter{coordinateindex}
\setcounter{coordinateindex}{0}
\tikzset{
stepcounter/.code={
\stepcounter{coordinateindex}
}
}
\tikzset{
save coordinates/.style={
decoration={markings,
mark=at position 0 with { \coordinate (coordinate\thecoordinateindex); },
mark=between positions 0 and 1 step 0.1 with {
\coordinate[preaction=stepcounter] (coordinate\thecoordinateindex);
}
},
postaction={decorate}
}
}
\definecolor{L1}{HTML}{ECD9ED}
\definecolor{L2}{HTML}{C7DAC4}
\definecolor{L3}{HTML}{E4B1AD}
\definecolor{L1L2}{HTML}{EF3A43}
\definecolor{L1L3}{HTML}{B7CA54}
\definecolor{L2L3}{HTML}{4C4B6B}
\definecolor{L1L2L3}{HTML}{FBC405}
\newlength{\smallradius}
\setlength{\smallradius}{1cm}
\coordinate (X1) at (0.5,0.75);
\newcommand{\uppercircle}{(X1) circle(\smallradius)};
\path [name path=upper circle] \uppercircle;
\coordinate(X2) at (0,0);
\newcommand{\leftlowercircle}{(X2) circle(\smallradius)};
\path [name path=left lower circle] \leftlowercircle;
\coordinate(X3) at (1,0);
\newcommand{\rightlowercircle}{(X3) circle(\smallradius)};
\path [name path=right lower circle] \rightlowercircle;
% Point of median (X1--Mx1) in the triangle (X1--X2--X3) on the side (X2--X3)
\coordinate (Mx1) at ($(X2)!.5!(X3)$);
\path [name path= median x1] (X1)--(Mx1);
% Point of median (X2--Mx2) in the triangle (X1--X2--X3) on the side (X1--X3)
\coordinate (Mx2) at ($(X1)!.5!(X3)$);
\path [name path= median x2] (X2)--(Mx2);
% Point of median (X3--Mx3) in the triangle (X1--X2--X3) on the side (X1--X2)
\coordinate (Mx3) at ($(X1)!.5!(X2)$);
\path [name path= median x3] (X3)--(Mx3);
% Centroid of the triangle (X1--X2--X3) and, more importantly, the center of the circumscribed circle of the circles (X1,1), (X2,1), and (X3,1)
\path [name intersections={of=median x1 and median x2,by=X1X2X3}];
\newlength{\bigradius}
\newlength{\bigdiameter}
\setlength{\bigradius}{2cm}
\setlength{\bigdiameter}{2\bigradius}
% Line width options: "line width=<dimension>", and abbreviations "ultra thin" for 0.1pt, "very thin" for 0.2pt, "thin" for 0.4pt (the default width), "semithick" for 0.6pt, "thick" for 0.8pt, "very thick" for 1.2pt, "ultra thick" for 1.6pt.
\newlength{\contourthickness}
\setlength{\contourthickness}{1.2pt}
\newcommand{\boundingbox}{($(X1X2X3) - (\bigradius,\bigradius)$) rectangle ($(X1X2X3) + (\bigradius,\bigradius)$)}
\path [name intersections={of=upper circle and left lower circle,by={FarEndX1X2,LowerRightEndX1X2X3}}];
\path [name intersections={of=upper circle and right lower circle,by={FarEndX1X3,LowerLeftEndX1X2X3}}];
\path [name intersections={of=left lower circle and right lower circle,by={UpperEndX1X2X3,FarEndX2X3}}];
\coordinate(FarEndX1) at ($(X1)-(Mx1)+(Mx1)!\smallradius!(X1X2X3)$);
\coordinate(FarEndX1LeftContourStart) at ($(FarEndX1)-(X1X2X3)+(X1X2X3)!\contourthickness!90:(FarEndX1)$);
\coordinate(FarEndX1RightContourStart) at ($(FarEndX1)-(X1X2X3)+(X1X2X3)!\contourthickness!270:(FarEndX1)$);
\coordinate(FarEndX2) at ($(X2)-(Mx2)+(Mx2)!\smallradius!(X1X2X3)$);
\coordinate(FarEndX3) at ($(X3)-(Mx3)+(Mx3)!\smallradius!(X1X2X3)$);
% Upper greater petal
\scope
\clip \boundingbox
\leftlowercircle
\rightlowercircle;
\fill[color=L1] \uppercircle;
\endscope
% Left greater petal
\scope
\clip \boundingbox
\uppercircle
\rightlowercircle;
\fill[color=L2] \leftlowercircle;
\endscope
% Right greater petal
\scope
\clip \boundingbox
\uppercircle
\leftlowercircle;
\fill[color=L3] \rightlowercircle;
\endscope
% Left smaller petal
\scope
\clip \boundingbox
\rightlowercircle;
\clip \leftlowercircle;
\fill[color=L1L2] \uppercircle;
\endscope
% Right smaller petal
\scope
\clip \boundingbox
\leftlowercircle;
\clip \uppercircle;
\fill[color=L1L3] \rightlowercircle;
\endscope
% Lower smaller petal
\scope
\clip \boundingbox
\uppercircle;
\clip \leftlowercircle;
\fill[color=L2L3] \rightlowercircle;
\endscope
% Center
\scope
\clip \uppercircle;
\clip \leftlowercircle;
\clip \rightlowercircle;
\fill[color=L1L2L3] \boundingbox;
\endscope
% outline
\draw \uppercircle
\leftlowercircle
\rightlowercircle;
\node[draw, circle, minimum size= \bigdiameter, label=below:$X_1 \times X_2 \times X_3$] at (X1X2X3) {};
% Solutions from upper greater petal
% TODO: consider using loop since FarEndX1LeftContourStart and FarEndX1RightContourStart are intersections of circles (X1,1) and (FarEndX1, delta)
\draw[black,very thin] (FarEndX1LeftContourStart) arc[start angle=180,end angle=160,x radius=100, y radius = 10];
\draw[black,very thin] (FarEndX1RightContourStart) arc[start angle=180,end angle=160,x radius=100, y radius = 10];
\draw[L1,very thick,save coordinates] (FarEndX1) arc[start angle=180,end angle=160,x radius=100, y radius = 10] coordinate(Img1);
% Image (as in set theory) of the first function
\fill[color=white] (Img1) circle (1);
\node[draw, circle, color=black, minimum size=2cm, label=below:{$[(x_1,x_2,x_3) \mapsto x_1-2x_2-x_3]^{\rightarrow}$} ] at (Img1) {};
\draw[fill] (FarEndX2) circle[radius=2pt];
\draw[fill] (FarEndX3) circle[radius=2pt];
\draw[fill] (UpperEndX1X2X3) circle[radius=2pt];
\draw[fill] (LowerLeftEndX1X2X3) circle[radius=2pt];
%\foreach \i in {1,2,...,\thecoordinateindex}
% \draw[fill] (coordinate\i) circle[radius=2pt];
\end{tikzpicture}
\end{document}
\coordinate[preaction=stepcounter] ...
, try\coordinate[stepcounter] ...
.