我正在為一篇群論文章繪製插圖。我想繪製一個三角形穿過從其一個頂點發出的光線的反射過程。
到目前為止我有以下內容:
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric,decorations.markings,arrows,positioning}
\tikzset{
buffer/.style={
draw,
regular polygon,
regular polygon sides=3,
node distance=3cm,
minimum height=6em
}
}
\begin{document}
\begin{tikzpicture}
\node[buffer] (T) {};
\coordinate [label=left:B] (B) at (-0.9cm, -0.6);
\coordinate [label=above:A] (A) at (0,1.04cm);
\node at (3.3em, -0.5) {C};
\draw (A) -- (B-|A) -- (-90:1.5cm) node[above right]{$l_1$};
\node[right = 1cm of T] (Arr) {$\Longrightarrow$};
\node[buffer, right = 0.5cm of Arr] (T1) {};
\end{tikzpicture}
\end{document}
如何獲得三角形頂點的座標?現在我手動計算它們,這看起來不太好。
如何定位左右三角形,使它們與箭頭等距,而不需要設定手動填充?
是否可以將箭頭 a 向上移動,使其位於三角形的垂直中心?
答案1
1-) 您可以使用該corners
選項並將角點作為 的節點regular polygon
。
scope
2-)用繪製第二個三角形xshift=Xcm
。然後使用x
箭頭的座標作為(X/2,0)
。
3-) 可以手動調整給出適當的y
值。
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric,decorations.markings,arrows,positioning}
\tikzset{
buffer/.style={
draw,
regular polygon,
regular polygon sides=3,
node distance=3cm,
minimum height=6em
}
}
\begin{document}
\begin{tikzpicture}
\node[buffer] (T) {};
\begin{scope}[xshift=4cm];
\node[buffer] (T1) {};
\end{scope}
\node at (2,0.25) (Arr) {$\Longrightarrow$};
\node at (T.corner 1)(A)[above]{A};
\node at (T.corner 2)(B)[left]{B};
\node at (T.corner 3)(C)[right]{C};
\draw (A) -- (B-|A) -- (-90:1.5cm) node[above right]{$l_1$};
\end{tikzpicture}
\end{document}
答案2
為了好玩,使用 pstricks 編寫一個簡單的程式碼,更具體地說,使用pst-eucl
.我畫了兩對點,相對於原點對稱,並要求從這些線段構建兩個等邊三角形,然後通過 $A$ 繪製第一個三角形的高度,最後將含義符號放在三角形之間。
\documentclass[border=6pt]{standalone}
\usepackage{pst-eucl}%
\begin{document}
\begin{pspicture}(-4.5,-1)(4,3)%
\psset{PointSymbol=none, PtNameMath=false, linejoin=1}
\pstGeonode[PosAngle={180,0}](-4,0){B}(-1,0){C} \pstETriangleAB[PosAngle=90]{B}{C}{A}
\rput(0.1,1.3 ){$\Longrightarrow$}
\psset{PointName=none}
\pstGeonode[PointName=none](1,0){E}(4,0){F}\pstETriangleAB[PointName=none] {E}{F}{D}
\pstProjection{B}{C}{A}[H]
\pstLineAB[nodesepB=-1, linewidth=0.6pt]{A}{H}\naput[npos=0.9, labelsep=2pt]{$l_1 $}
\end{pspicture}
\end{document}