
Ein neuer Tag, ein neues Problem! Dieses Mal kann ich nicht verstehen, warum Tikz nach dem Ausfüllen einen weißen Raum wie diesen hinterlässt
\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}[scale=0.7]
\coordinate (O) at (0,0);
\coordinate (I) at (12,0);
\coordinate (C1) at (4,0);
\coordinate (C2) at (7,0);
\draw ($ (O)+(-1,0) $) -- ($ (I)+(1,0) $);%asse ottico
\draw [very thick] (C1)++(75:-3) node (A1) {A1} arc (75:-75:-3) node (B1)
{B1};
\draw [very thick] (C2)++(75:3) node (A2) {A2} arc (75:-75:3) node (B2) {B2};
\begin{scope}
\clip (C1)++(75:-3) arc (75:-75:-3) -- (A2) -- (C2)++(75:3) arc (75:-75:3) --
(A1);
\filldraw [color=lightgray, opacity=0.6] (-10,-10) rectangle (20,10);
\end{scope}
\end{tikzpicture}
\end{document}
Antwort1
Sie brauchen das hier nicht einmal clip
. Das Problem ist, dass Sie das Inkrement ++
im Pfad verwenden. Sie können das für die erste Koordinate tun, aber wenn Sie dies für die anderen tun, hat der Pfad "Sprünge". Während Sie jedoch laden calc
, könnten Sie einfach
\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}[scale=0.7]
\coordinate (O) at (0,0);
\coordinate (I) at (12,0);
\coordinate (C1) at (4,0);
\coordinate (C2) at (7,0);
\draw ($ (O)+(-1,0) $) -- ($ (I)+(1,0) $);%asse ottico
\draw [very thick] (C1)++(75:-3) node (A1) {A1} arc (75:-75:-3) node (B1)
{B1};
\draw [very thick] (C2)++(75:3) node (A2) {A2} arc (75:-75:3) node (B2) {B2};
\fill[color=lightgray, opacity=0.6](C1)++(75:-3) arc (75:-75:-3)
-- ($(C2)+(75:3)$) arc (75:-75:3) -- cycle ;
\end{tikzpicture}
\end{document}
Da Sie jedoch bereits benannte Knoten haben, können Sie dies vereinfachen zu
\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{calc,backgrounds}
\begin{document}
\begin{tikzpicture}[scale=0.7]
\coordinate (O) at (0,0);
\coordinate (I) at (12,0);
\coordinate (C1) at (4,0);
\coordinate (C2) at (7,0);
\draw ($ (O)+(-1,0) $) -- ($ (I)+(1,0) $);%asse ottico
\draw [very thick] (C1)++(75:-3) node (A1) {A1} arc (75:-75:-3) node (B1)
{B1};
\draw [very thick] (C2)++(75:3) node (A2) {A2} arc (75:-75:3) node (B2) {B2};
\begin{scope}[on background layer]
\fill[color=lightgray, opacity=0.6](A1.center) arc (75:-75:-3) --
(A2.center) arc (75:-75:3) -- cycle ;
\end{scope}
\end{tikzpicture}
\end{document}
Auch hier habe ich die Füllung auf das aufgetragen background layer
.