If we add the following code to the angles
library, we can draw right angles in the same way we draw "rounded" ones, like this pic{right angle = A--B--C}
\tikzset{ pics/right angle/.style = { setup code = \tikz@lib@angle@parse#1\pgf@stop, background code = \tikz@lib@rightangle@background#1\pgf@stop, foreground code = \tikz@lib@rightangle@foreground#1\pgf@stop, }, pics/right angle/.default=A--B--C } \def\tikz@lib@rightangle@background#1--#2--#3\pgf@stop{% \path [name prefix ..] [pic actions, draw=none] (#2.center) -- ++(\tikz@start@angle@temp:\tikz@lib@angle@rad pt) -- ++(\tikz@end@angle@temp:\tikz@lib@angle@rad pt) -- ++(\tikz@start@angle@temp:-\tikz@lib@angle@rad pt) -- cycle; } \def\tikz@lib@rightangle@foreground#1--#2--#3\pgf@stop{% \path [name prefix ..] [pic actions, fill=none, shade=none] ([shift={(\tikz@start@angle@temp:\tikz@lib@angle@rad pt)}]#2.center) -- ++(\tikz@end@angle@temp:\tikz@lib@angle@rad pt) -- ++(\tikz@start@angle@temp:-\tikz@lib@angle@rad pt); \ifx\tikzpictext\relax\else% \def\pgf@temp{\node()[name prefix ..,at={([shift={({.5*\tikz@start@angle@temp+.5*\tikz@end@angle@temp}:\pgfkeysvalueof{/tikz/angle eccentricity}*\tikz@lib@angle@rad pt)}]#2.center)}]} \expandafter\pgf@temp\expandafter[\tikzpictextoptions]{\tikzpictext};% \fi }
I have created temporary rightangles
library available at GitHub.
The node position shold be corrected by factor of
sqrt(1/2)
in a way to have forangle eccentricity = 1
a coordinate on the angle vertex.Many thanks for providing the extention of the
angles
library! As you may have noticed I have merged your code but did forget to close this "bug". I am not sure what you mean with your comment. Is there something to fix in your code (or the round angles code) so that it makes sense to not close this "bug"?Last edit: Stefan Pinnow 2018-12-22
I thnik that you can close this "bug". My comment about
sqrt(1/2)
is already integrated in the code.One remark, if you want to speed it up a little bit you can replace
sqrt(1/2)
by0.7071067811865476
, or something shorter ;)Thanks for considering my contribution !