![如何在三角形的一边添加刻度?](https://linux22.com/image/420976/%E5%A6%82%E4%BD%95%E5%9C%A8%E4%B8%89%E8%A7%92%E5%BD%A2%E7%9A%84%E4%B8%80%E8%BE%B9%E6%B7%BB%E5%8A%A0%E5%88%BB%E5%BA%A6%EF%BC%9F.png)
我想要绘制下面的图:
但我不知道如何将它与两条虚线对齐。
\documentclass[margin=10pt]{standalone}
\usepackage{tkz-euclide}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\pgfmathsetmacro{\a}{39/7} % AC
\pgfmathsetmacro{\b}{41/7} % AB
\pgfmathsetmacro{\c}{50/7} % BC
\tkzDefPoints{0/0/B,\c/0/C}
\tkzInterCC[R](B,\b cm)(C,\a cm) \tkzGetFirstPoint{A}
\tkzDefPointWith[orthogonal normed](B,A) \tkzGetPoint{B1}
\draw[thin,blue,densely dashed](B) -- (B1);
\tkzDefPointWith[orthogonal normed,K=-1](A,B) \tkzGetPoint{A1}
\draw[thin,blue,densely dashed](A) -- (A1);
\draw[thin,Stealth-Stealth]($(A)+(0,1)$) -- node[above,sloped]{$41$}($(B)+(0,1)$);
\fill[yellow!70] (B) -- (A) -- (C);
\tkzDrawPolygon[thick](A,B,C)
\end{tikzpicture}
\end{document}
答案1
您tkz-euclide
可以使用重心坐标,该坐标可用于将点放置在其他点之间。如果您希望将点放置在两点(例如 A 和 B)之间 7/10 的位置,则可以使用\tkzDefBarycentricPoint(A=3,B=7)
。
\documentclass[margin=10pt]{standalone}
\usepackage{tkz-euclide}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\pgfmathsetmacro{\a}{39/7} % AC
\pgfmathsetmacro{\b}{41/7} % AB
\pgfmathsetmacro{\c}{50/7} % BC
\tkzDefPoints{0/0/B,\c/0/C}
\tkzInterCC[R](B,\b cm)(C,\a cm) \tkzGetFirstPoint{A}
\tkzDefPointWith[orthogonal normed](B,A) \tkzGetPoint{B1}
\draw[thin,blue,densely dashed](B) -- (B1);
\tkzDefPointWith[orthogonal normed,K=-1](A,B) \tkzGetPoint{A1}
\draw[thin,blue,densely dashed](A) -- (A1);
\tkzDefBarycentricPoint(A=3,A1=7)\tkzGetPoint{x}
\tkzDefBarycentricPoint(B=3,B1=7)\tkzGetPoint{y}
\draw[thin,Stealth-Stealth](x) -- node[above,sloped]{$41$}(y);
\fill[yellow!70] (B) -- (A) -- (C);
\tkzDrawPolygon[thick](A,B,C)
\end{tikzpicture}
\end{document}
答案2
\documentclass[margin=10pt]{standalone}
\usepackage{tkz-euclide}
\begin{document}
\begin{tikzpicture}
\pgfmathsetmacro{\a}{39/7} % AC
\pgfmathsetmacro{\b}{41/7} % AB
\pgfmathsetmacro{\c}{50/7} % BC
\tkzDefPoints{0/0/B,\c/0/C}
\tkzInterCC[R](B,\b cm)(C,\a cm) \tkzGetFirstPoint{A}
\tkzDefPointWith[orthogonal normed](B,A) \tkzGetPoint{B1}
\tkzDefPointWith[orthogonal normed,K=-1](A,B) \tkzGetPoint{A1}
\tkzDrawPolygon[thick,fill=yellow](A,B,C)
\tkzDrawPoints(A,B,C)
\tkzLabelPoints(B,C)
\tkzLabelPoints[above,right](A)
\tkzDrawSegment[dim={$41$,-15pt,above=4pt,font=\scriptsize,rotate=45}](A,B)
\end{tikzpicture}
\end{document}