Continuing over this beautiful answer, is it possible to have the following additional angle marks? ((1) The angle with the dot in the center; (2) the violet angles with decorations, if possible, with the able to customize it (segment numbers, length, distance, color, etc.); (3) angles with multiple arcs.
Asked
Active
Viewed 665 times
1 Answers
5
Here is a proposal. As kindly explained by Kpym in the comments, there are two paths for the angle construction: the arc and the fill. One has to prevent TikZ from drawing the decoration twice. This answer comes with a style insert angle lines, which takes two arguments, the number of lines and the vertex they should connect to. An example is
\pic [draw=red,angle radius=1cm,insert angle lines={3}{A}]
{angle = C--A--B};
There is a second style for the dot
\pic [draw=blue,angle radius=1cm,insert angle dot={B}] {angle = A--B--C};
If you wan to change the style of these marks, adjust every angle mark. Here is the MWE.
\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{decorations.markings,angles}
\newcounter{trstep}
\begin{document}
\tikzset{insert |/.style={decoration={markings,
mark=at position #1 with {%
\draw[line cap=round,mark segment]
(0,-\pgfkeysvalueof{/tikz/mark
segment length}/2) -- (0,\pgfkeysvalueof{/tikz/mark
segment length}/2);}
}},
| mark/.style={postaction=decorate,insert |=#1},
insert ||/.style={decoration={markings,
mark=at position #1 with {%
\draw[line cap=round,mark segment]
(-\pgfkeysvalueof{/tikz/mark segment distance}/2,-\pgfkeysvalueof{/tikz/mark
segment length}/2) -- (-\pgfkeysvalueof{/tikz/mark segment distance}/2,\pgfkeysvalueof{/tikz/mark
segment length}/2);
\draw[line cap=round,mark segment] (\pgfkeysvalueof{/tikz/mark segment distance}/2,-\pgfkeysvalueof{/tikz/mark
segment length}/2) -- (\pgfkeysvalueof{/tikz/mark segment distance}/2,\pgfkeysvalueof{/tikz/mark
segment length}/2);}
}},
|| mark/.style={postaction=decorate,insert ||=#1},
insert |||/.style={decoration={markings,
mark=at position #1 with {%
\draw[line cap=round,mark segment]
(-\pgfkeysvalueof{/tikz/mark segment distance},-\pgfkeysvalueof{/tikz/mark
segment length}/2) -- (-\pgfkeysvalueof{/tikz/mark segment distance},\pgfkeysvalueof{/tikz/mark
segment length}/2);
\draw[line cap=round,mark segment]
(0,-\pgfkeysvalueof{/tikz/mark
segment length}/2) -- (0,\pgfkeysvalueof{/tikz/mark
segment length}/2);
\draw[line cap=round,mark segment]
(\pgfkeysvalueof{/tikz/mark segment distance},-\pgfkeysvalueof{/tikz/mark
segment length}/2) -- (\pgfkeysvalueof{/tikz/mark segment distance},\pgfkeysvalueof{/tikz/mark
segment length}/2);}
}},
||| mark/.style={postaction=decorate,insert |||=#1},
mark segment/.style={thick},
mark segment options/.code=\tikzset{mark segment/.style={#1}},
mark segment distance/.initial=2pt,
mark segment length/.initial=4pt,
angle deco |/.style={insert |=0.5,
pic actions/.append code=\tikzset{postaction=decorate}},
angle deco ||/.style={insert ||=0.5,
pic actions/.append code=\tikzset{postaction=decorate}},
angle deco |||/.style={insert |||=0.5,
pic actions/.append code=\tikzset{postaction=decorate}},
insert angle lines/.style n args={2}{
/utils/exec={\pgfmathsetmacro{\mystep}{1/(#1+1)}
\setcounter{trstep}{0}},
decoration={markings,mark=between positions {\mystep} and {1-\mystep} step {\mystep}
with {\stepcounter{trstep}
\ifnum\number\value{trstep}>#1
\else
\draw[shorten <=-1pt,every angle mark] (0,0)-- (#2);
\fi}},
pic actions/.append code=\tikzset{postaction={decorate}}
},
every angle mark/.style={line cap=round,semithick},
double arc/.style={double,double distance=2pt},
triple arc/.style={double distance=4pt,
pic actions/.append code=\tikzset{postaction={draw}}},
insert angle dot/.style={
/utils/exec={\setcounter{trstep}{0}},
decoration={markings,mark=at position 0.5 with {\stepcounter{trstep}
\ifnum\number\value{trstep}=1
\fill[\pgfkeysvalueof{/tikz/angle dot color}] (#1) -- (0,0) coordinate[pos=\pgfkeysvalueof{/tikz/angle dot pos}] (aux) (aux)
circle[radius=\pgfkeysvalueof{/tikz/angle dot radius}];
\fi}},
pic actions/.append code=\tikzset{postaction={decorate}}},
angle dot radius/.initial=1pt,
angle dot pos/.initial=0.6,
angle dot color/.initial=black}
\begin{tikzpicture}[]
\coordinate (A) at (0,0);
\coordinate (B) at (2,4);
\coordinate (C) at (4,0);
\draw(A)--(B)--(C)--cycle;
\path[| mark=0.5] (A) -- (B);
\path[mark segment options={thick,yscale=2},|| mark=0.5] (B) -- (C);
\path[mark segment options={blue,line width=1pt,scale=2},||| mark=0.5] (C) -- (A);
\pic [draw=blue,angle radius=1cm,insert angle dot={B}]
{angle = A--B--C};
\pic [draw=red,angle radius=1cm,insert angle lines={3}{A}]
{angle = C--A--B};
\pic [draw=purple,angle radius=1cm,triple arc,
insert angle lines={3}{C}]
{angle = B--C--A};
\end{tikzpicture}
\end{document}
-
@blackened You want three parallel angle arcs? And what do you mean by
add a point in the center option? – Mar 14 '19 at 04:46 -
1The decoration is run twice because two paths are used : one for draw (only the arc) with
[pic actions, fill=none, shade=none]and one for fill (for the sector) with[pic actions, draw=none]. – Kpym Mar 14 '19 at 07:43 -
-
1
-
@marmot (1) Sorry. I thought I had accepted your answer, just realized it was not. (2) For the sake of completeness for the newcomers, would you agree that it is a good idea to include the double arc style, from your other answer? – blackened Mar 15 '19 at 13:04
-
@blackened I added this style. Whether or not this is better is probably a matter of taste. On the one hand, I see your point that it might make sense to lump related styles together. On the other hand, if someone is only interested in one of the features but not all of them, the user may hesitate to copy a lot of styles that they do not need. Depending on their familiarity with TikZ they may not know how to only copy the relevant style. – Mar 15 '19 at 13:34
-
@marmot Sorry for being nitpicking. When I draw multiple arcs as angle on a colored background, the background color of the space between the arcs is white; how do I customize that? – blackened Mar 21 '19 at 06:59
-
1@blackened AFAIK this is a sort of unsolved problem for double lines, see e.g. https://tex.stackexchange.com/q/159333/121799. The only clean way to avoid this seems to be to draw several lines rather than a single double or triple line. If you have a uniformly colored background, you can use
double=backgroundto fix it, but this won't work if the background is non-uniform. – Mar 21 '19 at 15:10


with dot/.style={pic text=$\cdot$,angle eccentricity=.5,pic text options={#1}}, and then use it as simple as[with dot]or with options like[with dot={blue,scale=2}]. – Kpym Mar 14 '19 at 07:39$\cdot$(which is not well centerd) by simple dot.. – Kpym Mar 14 '19 at 17:48