I've got the following code:
\documentclass[a4paper]{article} \usepackage{tikz} \usetikzlibrary{intersections, calc, spath3} \begin{document} \begin{tikzpicture} \coordinate (P) at (110:1.5); \draw[spath/save=g, thick] (200:3) -- (20:3) node[below] {$g$}; \draw[thick] plot[mark=x, mark size=3pt] coordinates {(P)} node[above right] {$P$}; \path[spath/save=CircleP] (P) circle (2); \path[name intersections={of=g and CircleP, name=g}]; \path[spath/save=CA] (g-1) circle (4mm); \draw[blue] plot[mark=x, mark size=3pt] coordinates {(g-1)} node[below left] {$A$}; \path[spath/save=CB] (g-2) circle (4mm); \draw[blue] plot[mark=x, mark size=3pt] coordinates {(g-2)} node[below right] {$B$}; \tikzset{ spath/split at intersections={CircleP}{CA}, spath/split at intersections={CircleP}{CB}, CircleP component 2/.style={blue, draw}, CircleP component 4/.style={blue, draw}, spath/render components=CircleP, } \path[spath/save=CircleA] (g-1) circle (2.3); \path[spath/save=CircleB] (g-2) circle (2.3); \path[name intersections={of=CircleA and CircleB, name=m}]; \path[spath/save=CM1] (m-1) circle (4mm); \path[spath/save=CM2] (m-2) circle (4mm); \tikzset{ spath/split at intersections={CircleA}{CM1}, spath/split at intersections={CircleA}{CM2}, CircleA component 2/.style={blue, draw}, CircleA component 4/.style={blue, draw}, spath/render components=CircleA, spath/split at intersections={CircleB}{CM1}, spath/split at intersections={CircleB}{CM2}, CircleB component 2/.style={blue, draw}, CircleB component 4/.style={blue, draw}, spath/render components=CircleB, } \draw[thick, blue] ($(m-1)!1.1!(m-2)$) -- ($(m-2)!1.1!(m-1)$); \end{tikzpicture} \end{document} Since I use the same construction to draw the sections of a circle around the intersection point of that circle with another path, which I want to use in other tikzpictures as well, I wanted to make that part into a new TikZ-element to which I can pass the path name of the circle, the path name of the other path and the name by which the intersections schould be named.
Sure, I can always make a newcommand achieving this, but I was hoping to find another way using tikzset or something along those lines which allows for a syntax that blends in with the construction of the other elements. Also I hope that such a way would allow for an easy change of aspects like the line thickness and color.
If possible I'd like to be able to write something like \draw circleintersect[circle=CircleA, path=g, name=g, radius=4mm]; to achive this.
I think I understood most of what was done in the answer to this question: TikZ: Easy drawing of cuboids. Sadly I wasn't able to get some code running for what I have in mind. My biggest problem is how to implement the keyval part I think. I tried to read the pgf/tikz manual on this but haven't gotten far.
Any help or hints are very much appreciated.
\draw circleintersect[circle=CircleA, path=g, name=g, radius=4mm];would be much trickier to implement than, say,\draw pic [circleintersect={circle=CircleA, path=g, name=g, radius=4mm}];. that's not quite right as I've forgotten the syntax, but the point is that havingpicin the path is expected - and then you can do what you want, more-or-less, whereas getting the parser to pic up an entirely new element involves more heavy lifting.\path[name intersections={of=CircleP and g, name=g}]; \path[spath/save=CA] (g-1) circle (4mm); \path[spath/save=CB] (g-2) circle (4mm); \tikzset{ spath/split at intersections={CircleP}{CA}, spath/split at intersections={CircleP}{CB}, CircleP component 2/.style={blue, draw}, CircleP component 4/.style={blue, draw}, spath/render components=CircleP, }So for a given circle and path the intersections are calculated and then only the part of the circle within the specified radius is drawn.