
Gegeben seien zwei Linien. Ich möchte beide so verbinden, dass die Verbindungslinie glatt ist. Betrachten Sie beispielsweise das folgende Bild:
\documentclass{article}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{arrows}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}
\coordinate (v1) at (0,0);
\coordinate (v2) at (2,0);
\coordinate (v3) at (4,2);
\coordinate (v4) at (4,4);
\draw[fill, black] (v1) circle[radius=1pt];
\draw[fill, black] (v2) circle[radius=1pt];
\draw[fill, black] (v3) circle[radius=1pt];
\draw[fill, black] (v4) circle[radius=1pt];
\draw (v1)--(v2);
\draw (v3)--(v4);
\draw (2,2) circle(2);
\end{tikzpicture}
\end{document}
Mich interessiert eigentlich nur das Viertel des Kreises, das die beiden Linien verbindet. Aber ich habe Probleme
- Entfernen der anderen 75 % des Kreises und, was noch wichtiger ist
- So berechnen Sie eine solche Linie für nicht senkrechte Linien.
Ich habe versucht, zu verwenden \draw[bend left]
, aber das führt nicht immer zu einer reibungslosen Verbindung. Kennt jemand einen besseren Ansatz?
Antwort1
Und genau das controls
macht der Befehl: Er verbindet sich reibungslos durchBézierkurven, unabhängig davon, ob diese Segmente senkrecht sind oder nicht. Sie können auch den Skalarfaktor .5
, .8
, 1.5
, usw. ändern, um die Schusskräfte zu steuern.
(A).. controls +(P) and +(Q) .. (B)
das ist gleichbedeutend mit
(A).. controls (A)+(P) and (B)+(Q) .. (B)
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\path
(0,0) coordinate (v1) node[below]{$v_1$}
(1,2) coordinate (v2) node[left]{$v_2$}
(4,2) coordinate (v3) node[right]{$v_3$}
(3,4) coordinate (v4) node[above]{$v_4$}
;
\draw (v1)--(v2) (v3)--(v4);
\draw[red] (v2).. controls +($.5*(v2)-.5*(v1)$) and +($.8*(v3)-.8*(v4)$) .. (v3);
\foreach \p in {v1,v2,v3,v4}
\fill (\p) circle(2pt);
\end{tikzpicture}
\begin{tikzpicture}
\path
(0,0) coordinate (v1) node[below]{$v_1$}
(2,0) coordinate (v2) node[below]{$v_2$}
(4,2) coordinate (v3) node[right]{$v_3$}
(4,4) coordinate (v4) node[above]{$v_4$}
;
\draw (v1)--(v2) (v3)--(v4);
\draw[blue] (v2).. controls +($.5*(v2)-.5*(v1)$) and +($.8*(v3)-.8*(v4)$) .. (v3);
\foreach \p in {v1,v2,v3,v4}
\fill (\p) circle(2pt);
\end{tikzpicture}
\end{document}
Antwort2
Sie können die Tasten out
und verwenden in
. Sie nehmen ein Argument (einen Winkel) und funktionieren im Wesentlichen wie bend left
, aber Sie können den Winkel wählen, der an beiden Enden am besten funktioniert.
\documentclass[11pt,a4paper]{amsart}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{arrows}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}
\coordinate (v1) at (0,0);
\coordinate (v2) at (2,0);
\coordinate (v3) at (4,2);
\coordinate (v4) at (4,4);
\draw[fill, black] (v1) circle[radius=1pt];
\draw[fill, black] (v2) circle[radius=1pt];
\draw[fill, black] (v3) circle[radius=1pt];
\draw[fill, black] (v4) circle[radius=1pt];
\draw (v1)--(v2);
\draw (v3)--(v4);
\draw (2,0) to [out=0, in=270] (4,2);
\end{tikzpicture}
\end{document}
In diesem speziellen Fall können Sie, wie Sie bemerkt haben, auch nur einen Kreisbogen einfügen. Beispielsweise ist die Ausgabe des obigen Beispiels dieselbe, wenn die letzte Zeile des TikZ-Bildes ersetzt wird durch
\draw (2,0) arc [start angle=-90, end angle=0, radius=2];