请帮我用 LaTex 画这个。即使只有几个节点,我也会尽力完成它。我只是不知道该使用什么语法。谢谢。
这是我得到的,但是边缘值的输出不太清晰。我该如何避免这种情况?
[third corner of triangle={A=A,B=B,a=2.1,b=2.4}]
coordinate[bullet={below left:$I$}] (I)
[third corner of triangle={A=I,B=B,a=2.6,b=3.6}]
coordinate[bullet={above:$C$}] (C)
[third corner of triangle={A=I,B=C,a=3.3,b=2.8}]
coordinate[bullet={above leftf:$J$}] (J)
[third corner of triangle={A=A,B=I,a=1.8,b=3.4}]
coordinate[bullet={below :$H$}] (H)
[third corner of triangle={A=H,B=J,a=3.2,b=1.7}]
coordinate[bullet={below:$G$}] (G)
[third corner of triangle={A=G,B=C,a=2.9,b=5.3}]
coordinate[bullet={above:$D$}] (D)
[third corner of triangle={A=D,B=C,a=4.2,b=2.2}]
coordinate[bullet={right:$E$}] (E)
[third corner of triangle={A=J,B=E,a=4.4,b=2.5}]
coordinate[bullet={below:$F$}] (F)
(B) edge["2.6"] (C)
(A) edge["3.4"] (H)
edge["2.4"] (I)
(I) edge["1.8"] (H)
edge["2.1"] (B)
edge["2.8"] (J)
(C) edge["3.3"] (J)
edge["3.6"] (I)
(D) edge["2.9"] (C)
edge["5.3"] (G)
(E) edge["4.2"] (C)
edge["2.2"] (D)
edge["4.4"] (F)
(F) edge["2.1"] (D)
edge["2.5"] (J)
(G) edge["1.7"] (H)
edge["3.2"] (J)
edge["5.3"] (D);
答案1
欢迎!三角形完全由两个角和其他边的长度固定。可以为此定义一种样式。该样式可以用作
[third corner of triangle={A=<name of first corner>,
B=<name of second corner>,
a=<length of side opposite to first corner>,
b=<length of side opposite to second corner>}]
这允许您绘制图表。下面是开始。
\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{calc,quotes}
\begin{document}
\begin{tikzpicture}[bullet/.style={circle,draw,fill,inner sep=1.5pt,label=#1},
auto,shortcut/.code={\def\pv##1{\pgfkeysvalueof{/tikz/#1/##1}}},
third corner of triangle/.style={shortcut=triangle pars,
triangle pars/.cd,#1,
/tikz/insert path={
let \p1=($(\pv{A})-(\pv{B})$),\n1={sqrt(pow(\x1/1cm,2)+pow(\y1/1cm,2))},
\n2={atan2(\y1,\x1)} in
(intersection cs:first line={(\pv{A})--($(\pv{A})+({\n2-cosinelaw(\n1,\pv{b},\pv{a})}:1)$)},
second line={(\pv{B})--($(\pv{B})+({\n2+cosinelaw(\n1,\pv{a},\pv{b})}:1)$)})
}},
declare function={cosinelaw(\a,\b,\c)=acos((\a*\a+\b*\b-\c*\c)/(2*\a*\b));},
triangle pars/.cd,
A/.initial=A,B/.initial=B,a/.initial=2,b/.initial=2]
\draw (0,0) coordinate[bullet={left:$A$}] (A)
to["2.7"] ++ (50:2.7) coordinate[bullet={above:$B$}] (B)
[third corner of triangle={A=A,B=B,a=2.1,b=2.4}]
coordinate[bullet={below:$I$}] (I)
[third corner of triangle={A=I,B=B,a=2.6,b=3.6}]
coordinate[bullet={above:$C$}] (C)
[third corner of triangle={A=I,B=C,a=3.3,b=2.8}]
coordinate[bullet={above:$J$}] (J)
[third corner of triangle={A=A,B=I,a=1.8,b=3.4}]
coordinate[bullet={left:$H$}] (H)
(B) edge["2.6"] (C)
(A) edge["3.4"] (H)
edge["2.4"] (I)
(I) edge["1.8"] (H)
edge["2.1"] (B)
edge["2.8"] (J)
(C) edge["3.3"] (J)
edge["3.6"] (I);
\end{tikzpicture}
\end{document}