So richten Sie Koordinaten in TikZ vertikal und horizontal aus

So richten Sie Koordinaten in TikZ vertikal und horizontal aus

Ich habe Punkte mit irrationalen Koordinaten, weil ich Polar- und kartesische Koordinaten mische. Ich möchte eine Koordinate als x-Wert einer Sache und als y-Wert einer anderen Sache angeben.

In diesem speziellen Beispiel möchte ich, dass die beiden Linien auf der linken Seite die gleichen linken Endpunkte haben.

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}

  \begin{tikzpicture}
    \coordinate (left) at (155:2);
    \coordinate (top) at (65:2);
    \coordinate (bottom) at (245:2);
    \coordinate (right) at (335:2);

    \coordinate (leftEdge) at ($ (left) + (-2,0) $);
    \coordinate (bottomEdge) at ($ (bottom) + (0,-2) $);

    \path[draw=black] (left) -- (top) -- (right) -- (bottom) -- cycle;
    \path[draw=blue] (left) -- (leftEdge);
    \path[draw=black] (bottom) -- (bottomEdge);
    \path[draw=red] (bottom) -- ++(-2,0);
  \end{tikzpicture}

\end{document}

Ich glaube, es gibt eine Möglichkeit, dies mit etwas wie zu tun (leftEdge.x,bottom.y), aber es ist mir nicht gelungen, es zum Laufen zu bringen.

Bildbeschreibung hier eingeben

Wie kann ich die rote Kante so weit nach links bringen wie die blaue Kante?

Antwort1

In Ihrem Beispiel müssen Sie lediglich sagen \path[draw=red] (bottom) -- (bottom-|leftEdge);:Diese tolle Antwortbietet Ihnen eine sehr schöne Erörterung dieser Syntax.

\documentclass[tikz]{standalone}
\usetikzlibrary{calc}

\begin{document}

  \begin{tikzpicture}
    \coordinate (left) at (155:2);
    \coordinate (top) at (65:2);
    \coordinate (bottom) at (245:2);
    \coordinate (right) at (335:2);

    \coordinate (leftEdge) at ($ (left) + (-2,0) $);
    \coordinate (bottomEdge) at ($ (bottom) + (0,-2) $);

    \path[draw=black] (left) -- (top) -- (right) -- (bottom) -- cycle;
    \path[draw=blue] (left) -- (leftEdge);
    \path[draw=black] (bottom) -- (bottomEdge);
    \path[draw=red] (bottom) -- (bottom-|leftEdge);
  \end{tikzpicture}

\end{document}

Bildbeschreibung hier eingeben

verwandte Informationen