Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/generic/pgf/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Resolve missing `gnuplot` plots in manual #1238
- Treat varargs for `min` and `max` in `luamath` pgf-tikz/pgfplots#492 #1359
- Fixed support for the `\tikz` command in the `dvisvgm4ht` driver for TeX4ht
- Support of `name prefix`/`name suffix` for pics `angle` and `right angle` (allows nesting it in other pics),
side-effect: any coordinates are now possiblenot just coordinates/nodes #1363

### Changed

Expand Down
4 changes: 0 additions & 4 deletions doc/generic/pgf/pgfmanual-en-library-angles.tex
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ \section{Angle Library}
\end{codeexample}
\end{key}

The three points \meta{A}, \meta{B}, and \meta{C} \emph{must} be the names
of nodes or coordinates; you cannot use direct coordinates like ``|(1,1)|''
here.

Comment on lines -36 to -39
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of removing, how about rewrite it to

    The three points \meta{A}, \meta{B}, and \meta{C} can be either the names
    of nodes or coordinates, or direct coordinates like ``|(1,1)|''.

to document the extended syntax.

Copy link
Contributor Author

@Qrrbrbirlbel Qrrbrbirlbel Jan 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, but it needs to be ``|1,1|'' then because the () are inserted by the pic's setup code. So pic […] {angle = {A--1,1--B.south west}} or pic […] {angle = A--{1,1}--B.south west} would be valid syntax.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right.

Then this syntax seems a bit more strange. Is a key-value interface needed here as well?

Copy link
Contributor Author

@Qrrbrbirlbel Qrrbrbirlbel Jan 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't mind one. I always put the coordinates in the wrong order anyway. :D
But is it so strange? Sure, in most cases, the () are used to indicate something is a coordinate (and baseline et al uses it to decide between a value and a coordinate).
But there are also many that don't use the ():

  • the technically deprecated (intersection of A--B and C--D) syntax where additional parentheses are missing (it even has the --)
  • (A |- B) (and not ((A) |- (B)) = ({(A)} |- {(B)})) as well as
  • below = of A.

They would all also allow 1, 1, the latter only with {}, of course.


We can check for -- – twice even – and use the old syntax (both for backwards compatibility and for the simple syntax), otherwise use start direction = (A), center = {(1, 1)}, end direction = (B.south west). I'd would even be as fancy as allowing start direction = (A), center = {(1, 1)}, delta angle=60. (But that can give weird results with xyz coordinate systems whose axes don't align with the canvas coordinate system. The arc/circle path operators solve this by choosing one or the other by looking whether the radii have a unit.)

The advantage of a key-value interface would be that it allows to set, say, a center coordinate for multiple angles.

You can leave out the three points, in this case the text |A--B--C| is
used; so in the above examples we could just have written |{angle}| in the
first pic.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,27 @@
}%

\def\tikz@lib@angle@background#1--#2--#3\pgf@stop{%
\path [name prefix ..] [pic actions, draw=none] (#2.center)
\path [name prefix ..] [pic actions, draw=none] (#2)
-- ++(\tikz@start@angle@temp:\tikz@lib@angle@rad pt)
arc [start angle=\tikz@start@angle@temp, end
angle=\tikz@end@angle@temp, radius=\tikz@lib@angle@rad pt] -- cycle;
}%

\def\tikz@lib@angle@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)
([shift={(\tikz@start@angle@temp:\tikz@lib@angle@rad pt)}]#2)
arc [start angle=\tikz@start@angle@temp, end
angle=\tikz@end@angle@temp, radius=\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)}]}
eccentricity}*\tikz@lib@angle@rad pt)}]#2)}]}
\expandafter\pgf@temp\expandafter[\tikzpictextoptions]{\tikzpictext};%
\fi
}%

\def\tikz@lib@rightangle@background#1--#2--#3\pgf@stop{%
\path [name prefix ..] [pic actions, draw=none] (#2.center)
\path [name prefix ..] [pic actions, draw=none] (#2)
-- ++(\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)
Expand All @@ -59,41 +59,44 @@

\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)
([shift={(\tikz@start@angle@temp:\tikz@lib@angle@rad pt)}]#2)
-- ++(\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}*1.4142136*\tikz@lib@angle@rad pt)}]#2.center)}]}
eccentricity}*1.4142136*\tikz@lib@angle@rad pt)}]#2)}]}
\expandafter\pgf@temp\expandafter[\tikzpictextoptions]{\tikzpictext};%
\fi
}%

\def\tikz@lib@angle@parse#1--#2--#3\pgf@stop{%
% Compute radius:
\pgfmathsetmacro\tikz@lib@angle@rad{\pgfkeysvalueof{/tikz/angle radius}}
\ifdim\tikz@lib@angle@rad pt>0pt\else\def\tikz@lib@angle@rad{12}\fi%
\pgfmathsetmacro\tikz@lib@angle@rad{\pgfkeysvalueof{/tikz/angle radius}}%
\ifdim\tikz@lib@angle@rad pt>0pt\else\def\tikz@lib@angle@rad{12}\fi
% Compute first coordinate:
\pgf@process{\pgfpointanchor{#2}{center}}%
\pgf@xa=\pgf@x%
\pgf@ya=\pgf@y%
\pgf@process{\pgfpointanchor{#1}{center}}%
\pgf@xb=\pgf@x%
\pgf@yb=\pgf@y%
\pgf@process{\pgfpointanchor{#3}{center}}%
\pgf@xc=\pgf@x%
\pgf@yc=\pgf@y%
\advance\pgf@xb by-\pgf@xa%
\advance\pgf@yb by-\pgf@ya%
\advance\pgf@xc by-\pgf@xa%
\advance\pgf@yc by-\pgf@ya%
\pgfmathsetmacro{\tikz@start@angle@temp}{atan2(\the\pgf@yb,\the\pgf@xb)}
\pgfmathsetmacro{\tikz@end@angle@temp}{atan2(\the\pgf@yc,\the\pgf@xc)}
\ifdim\tikz@end@angle@temp pt<\tikz@start@angle@temp pt%
\pgfmathsetmacro{\tikz@start@angle@temp}{\tikz@start@angle@temp-360}%
\fi%
}%
\tikz@scan@@absolute\pgf@process(#2)%
\pgf@xa=\pgf@x
\pgf@ya=\pgf@y
\tikz@scan@@absolute\pgf@process(#1)%
\pgf@xb=\pgf@x
\pgf@yb=\pgf@y
\tikz@scan@@absolute\pgf@process(#3)%
\pgf@xc=\pgf@x
\pgf@yc=\pgf@y
\advance\pgf@xb by-\pgf@xa
\advance\pgf@yb by-\pgf@ya
\advance\pgf@xc by-\pgf@xa
\advance\pgf@yc by-\pgf@ya
\pgfmathatantwo@{\pgf@sys@tonumber\pgf@yb}{\pgf@sys@tonumber\pgf@xb}%
\let\tikz@start@angle@temp\pgfmathresult
\pgfmathatantwo@{\pgf@sys@tonumber\pgf@yc}{\pgf@sys@tonumber\pgf@xc}%
\let\tikz@end@angle@temp\pgfmathresult
\ifdim\tikz@end@angle@temp pt<\tikz@start@angle@temp pt
\pgfmathsubtract@{\tikz@start@angle@temp}{360}%
\let\tikz@start@angle@temp\pgfmathresult
\fi
}



Expand Down