Seite 1 von 1
Linie in TikZ kürzen
Verfasst: Mi 16. Okt 2019, 09:28
von ThoRie
Hallo
Ich möchte gern die zweite Grafik aus folgendem Code produzieren:
\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
\draw (0,0) -- (1,0);
\draw (1,0) circle (2pt);
\end{tikzpicture}
\begin{tikzpicture}
\draw (0,0) -- (0.925,0);
\draw (1,0) circle (2pt);
\end{tikzpicture}
\end{document}
Allerdings sollte das auch sinnvoll umgesetzt sein, denn die Variante, die das jetzt bei mir macht, ist das Ergebnis von 10 Minuten herum probieren.
Kann man also die Linie so anpassen, dass sie immer, abhängig von seiner Größe, bis an den Rand des Kreises geht?
Verfasst: Mi 16. Okt 2019, 10:03
von esdd
Da gibt es viele verschiedene Möglichkeiten, u.a.
\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
\draw (0,0) -- (1,0);
\draw[fill=white] (1,0) circle [radius=2pt];
\end{tikzpicture}
\begin{tikzpicture}
\draw[shorten > = 2pt] (0,0) -- (1,0);
\draw (1,0) circle [radius=2pt];
\end{tikzpicture}
\begin{tikzpicture}
\draw
(0,0) -- ({1cm-2pt},0)
(1,0) circle [radius=2pt]
;
\end{tikzpicture}
\begin{tikzpicture}
\path
(1,0)
node [draw,circle,inner sep=0pt,minimum size=4pt](c){}
edge (0,0)
;
\end{tikzpicture}
\begin{tikzpicture}
\path
(0,0) coordinate (O)
(1,0)
node [draw,circle,inner sep=0pt,minimum size=4pt](c){}
edge (O)
;
\end{tikzpicture}
\end{document}
Was man nimmt, hängt vom Kontext ab.
Verfasst: Do 17. Okt 2019, 06:40
von Bartman
@ThoRie
Die Variante im letzten Beispiel dürfte Dir schon aus einem älteren Thema bekannt sein.
\documentclass[tikz]{standalone}
\usetikzlibrary{intersections, through}
\begin{document}
\begin{tikzpicture}
\draw
node [draw, circle, inner sep=0pt, minimum size=4pt] (c) {}
(c) -- +(-1,0)
;
\end{tikzpicture}
\begin{tikzpicture}
\draw
node [draw, circle, inner sep=0pt, minimum size=4pt] (c) {}
(c) -- +(180:1)
;
\end{tikzpicture}
\begin{tikzpicture}
\pgfmathsetlengthmacro{\radius}{2pt}
\draw
(0,0) -- (1cm-\radius,0)
arc [start angle=180, end angle=-180, radius=\radius]
;
\end{tikzpicture}
\begin{tikzpicture}
\draw (0,0) -- (1cm-2pt,0) coordinate (line end);
\node [draw, circle through=(line end)] at (1,0) {};
\end{tikzpicture}
\begin{tikzpicture}
\path [name path=line] (0,0) coordinate (O) -- (1,0) coordinate (c);
\draw [name path=circle] (c) circle [radius=2pt];
\draw [name intersections={of=line and circle}] (O) -- (intersection-1);
\end{tikzpicture}
\end{document}