如何倒置三角形(使底边成为顶边,使顶边成为底边)

如何倒置三角形(使底边成为顶边,使顶边成为底边)

这是我想要反转的三角形:

\newcommand{\arrowL}{
    \tikz \draw[latex-] (0,0) -- (0.1,0);
}
\newcommand{\arrowR}{
    \tikz \draw[-latex] (0,0) -- (0.1,0);
}

\begin{tikzpicture}
\draw (0,0)--(2,0) node[sloped,pos=0.5]{\arrowL};
\draw (2,0)--(2,2) node[sloped,pos=0.5]{\arrowL};
\draw (0,0)--(2,2) node[sloped,pos=0.5]{\arrowL};
\node[left] at (0,0) {$v_2$};
 \node[above] at (2,2) {$v_1$};
 \node[below] at (2,0) {$v_3$};
\node[above] at (1,1) {$a$};
 \node[above] at (2.2,1) {$b$};
\end{tikzpicture}

我正在使用文档类书籍,有人可以帮我反转这个三角形吗?

答案1

可以更改点或线段的标签。您可以旋转您想要的...

 \documentclass{standalone}
\usepackage{tkz-euclide}

\tkzSetUpLine[line width=.4pt,color=teal]
\tikzset{arrow/.style={
         decoration={markings,
         mark= at position .5 with {\arrow[scale=2]{>}}}}}  
\begin{document}
   
 \begin{tikzpicture}[scale=4]
 \begin{scope}[rotate=-135]
   \tkzDefPoint(0,0){v_1}
   \tkzDefPoint(2,0){v_2}
   \tkzDefTriangle[isosceles right](v_1,v_2) \tkzGetPoint{v_3}
 \end{scope}
 \tkzDrawSegments[arrow,postaction={decorate}](v_3,v_2 v_1,v_3 v_1,v_2)
 \tkzLabelPoints(v_1,v_2,v_3)
 \tkzLabelSegment(v_1,v_3){$b$}
 \tkzLabelSegment(v_2,v_1){$a$}
 \end{tikzpicture}
 
 \begin{tikzpicture}[scale=4]
 \begin{scope}[rotate=135]
   \tkzDefPoint(0,0){v_1}
   \tkzDefPoint(2,0){v_2}
   \tkzDefTriangle[isosceles right](v_2,v_1) \tkzGetPoint{v_3}
 \end{scope}
 \tkzDrawSegments[arrow,postaction={decorate}](v_3,v_2 v_1,v_3 v_1,v_2)
 \tkzLabelPoints(v_1,v_2,v_3)
 \tkzLabelSegment[swap](v_1,v_3){$b$}
 \tkzLabelSegment[swap](v_2,v_1){$a$}
 \end{tikzpicture}
 
 \end{document}

在此处输入图片描述

答案2

在我看来,这是从头开始绘制图像的最简单方法。只需确定所需的坐标并在它们之间画线即可。在此我将使用您的命令使用decorations.markings库并定义连接线的样式,如下面 MWE 中所做的那样:

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
                decorations.markings,
                quotes}


\begin{document}
    \begin{tikzpicture}[
->-/.style = {decoration={markings,
              mark=at position 0.5 with {\arrow{Triangle[angle=60:2pt 3]}}},
              postaction={decorate},
              line cap=round},
every edge quotes/.append style = {font=\small, inner sep=2pt}
                        ]
\draw[->-]  
    (0, 0) node[above] {$v_1$} to["$a$"] (2, 0) node[above] {$v_2$};
\draw[->-]
    (2, 0) to["$b$"] (2,-2) node[below] {$v_3$};
\draw[->-]
    (2,-2) to["$c$"] (0, 0);
    \end{tikzpicture}
\end{document}

在此处输入图片描述

如果箭头的方向不符合您的要求,则相应地交换其坐标。

相关内容