1) 我在乳胶中绘制三角形,但我希望顶点 A 和 B 是水平的。在下面的代码中,顶点 A 和 C 是水平的。我在更改代码时遇到了问题。
2) 我想在线段 AB 上从 C 到 D 点添加一条虚线,表示三角形的高度。请帮忙。这是我的代码:
\documentclass[margin=10pt]{standalone}
\usepackage{amsmath,tkz-euclide}
\usepackage{tikz}
\usetkzobj{all}
\usetikzlibrary{calc,angles,positioning,intersections,quotes,decorations.markings,shapes}
\tikzset{
myangle/.style={fill=green!20!white, draw=green!50!black,size=.3,opacity=.3},
intnode/.style={circle,fill=black,inner sep=1pt,outer sep=0pt}
}
\begin{document}
\begin{tikzpicture}
% Drawing the triangle and the coordinates
\draw coordinate[label=left:A] (a) --++(60:6) coordinate[label=above:B] (b);
\path[name path=ac] (a)--++(0:8.5);
\path[name path=bc] (b)--++(-45:8);
\path[name intersections={of = ac and bc, by=c}];
\node[anchor=west] at (c) {C};
\draw[use as bounding box] (a)--(b)--(c)--cycle;
% Drawing the coordinates S and T
%\coordinate (s) at ($(a)!0.75!(b)$);
%\path[name path=incls] (s) --++ (-10:5);
\path[name path=altbc] (b) -- (c);
%\path[name intersections={of = incls and altbc, by=t}];
%\draw[dashed] (s) -- (t) node[intnode,label={right:{\color{black}\scriptsize $T$}}] (t) {};
% Angles
\tkzFindAngle(a,b,c)
\tkzGetAngle{angleABC};
\FPround\angleABC\angleABC{0}
\tkzFindAngle(c,a,b)
\tkzGetAngle{angleCAB};
\FPround\angleCAB\angleCAB{0}
\tkzFindAngle(b,c,a)
\tkzGetAngle{angleBCA};
\FPround\angleBCA\angleBCA{0}
%\tkzFindAngle(a,s,t)
%\tkzGetAngle{angleAST};
%\FPround\angleAST\angleAST{0}
\tkzMarkAngle[myangle](a,b,c)
\tkzLabelAngle[pos=.4](a,b,c){\tiny $\angleABC^\circ$}
\tkzMarkAngle[myangle](c,a,b)
\tkzLabelAngle[pos=0.5](c,a,b){\tiny $\angleCAB^\circ$}
\tkzMarkAngle[myangle](b,c,a)
\tkzLabelAngle[pos=0.45](b,c,a){\tiny $\angleBCA^\circ$}
%\tkzMarkAngle[myangle](a,s,t)
%\tkzLabelAngle[pos=0.4](a,s,t){\tiny $\angleAST^\circ$}
%\node[intnode,label={left:\scriptsize $S$}] at (s) {};
\end{tikzpicture}
\end{document}
答案1
在评论中你实际上提出了新的问题...如果我理解正确的话,你会问这样的问题:
如果我是对的,那么请提出新的问题,我将能够提供上面图片的代码,首先网站上的其他成员有可能帮助您。
让我说一下,对于你最初的问题,你会收到两个答案,现在是时候选择其中一个来接受。对于后续问题,请在你的评论中提出新问题。
代码现已可用这里。
答案2
仅供比较,以下是元帖子包含在内luamplib
,因此您需要用它进行编译lualatex
或研究如何使其适应普通 MP,或者良好生产规范+ pdflatex
。
\RequirePackage{luatex85}
\documentclass[border=5mm]{standalone}
\usepackage{luamplib}
\begin{document}
\mplibtextextlabel{enable}
\begin{mplibcode}
vardef mark_angle(expr a, b, c, s, tint) =
save arc; path arc;
arc = fullcircle scaled 2s rotated angle (c-b) shifted b cutafter (b--a);
fill b--arc--cycle withcolor 7/8[tint,white];
draw arc;
label("$" & decimal floor(0.5 + (angle (a-b) - angle (c-b)) mod 360) & "^\circ$",
b shifted ((s+9) * unitvector(point arctime 1/2 arclength arc of arc of arc - b)));
enddef;
beginfig(1);
pair A, B, C, D;
A = origin;
B = 300 right; % rotated 15; % <- try this just to test generality
C-A = whatever * (A-B) rotated 60;
C-B = whatever * (A-B) rotated -45;
C-D = whatever * (A-B) rotated 90;
D = whatever[A,B];
mark_angle(A,B,C,16,blue);
mark_angle(B,C,A,16,red);
mark_angle(C,A,B,16,blue);
draw A--B--C--cycle;
draw C--D dashed evenly withcolor 1/2 white;
label.rt(decimal (abs(C-D)/abs(A-B)) , 1/2[C,D]);
dotlabel.llft("A", A);
dotlabel.lrt ("B", B);
dotlabel.top ("C", C);
dotlabel.bot ("D", D);
endfig;
\end{mplibcode}
\end{document}
答案3
纯tikz
溶液:
\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{angles, intersections, positioning, quotes}
\usepackage{siunitx}
\begin{document}
\begin{tikzpicture}[
myangle/.style={angle radius=5mm, angle eccentricity=1.6,
draw=green!50!black, fill=green!20!white}
]
% Drawing the triangle and the coordinates
\coordinate[label=left:A] (a);
\coordinate[label=right:B,right=8.5 of a] (b);
\path[name path=ac] (a) -- ++ ( 60:6.5);
\path[name path=bc] (b) -- ++ (135:8);
\path[name intersections={of = ac and bc, by=c}] node[label=C] at (c) {};;
\draw (a)--(c)--(b)--cycle;
% Angles
\pic [myangle, "\ang{60}"] {angle = b--a--c};
\pic [myangle, "\ang{45}"] {angle = c--b--a};
\pic [myangle, "\ang{75}"] {angle = a--c--b};
\draw[dashed] (c) -- (c |- a) coordinate[label=below:D] (d);
\end{tikzpicture}
\end{document}
答案4
你的意思是像这样吗?
代码:
\documentclass[margin=10pt]{standalone}
\usepackage{amsmath,tkz-euclide}
\usepackage{tikz}
\usetkzobj{all}
\usetikzlibrary{calc,angles,positioning,intersections,quotes,decorations.markings,shapes}
\tikzset{
myangle/.style={fill=green!20!white, draw=green!50!black,size=.3,opacity=.3},
intnode/.style={circle,fill=black,inner sep=1pt,outer sep=0pt}
}
\begin{document}
\begin{tikzpicture}
% Drawing the triangle and the coordinates
\draw coordinate[label=left:A] (a) --++(60:6) coordinate[label=above:C] (c);
\path[name path=ac] (a)--++(0:8.5);
\path[name path=bc] (c)--++(-45:8);
\path[name intersections={of = ac and bc, by=b}];
\node[anchor=west] at (b) {B};
\draw[use as bounding box] (a)--(c)--(b)--cycle;
\draw[dashed] (c) |- (b);%%%% DASHED LINE
% Drawing the coordinates S and T
%\coordinate (s) at ($(a)!0.75!(c)$);
%\path[name path=incls] (s) --++ (-10:5);
\path[name path=altbc] (c) -- (b);
%\path[name intersections={of = incls and altbc, by=t}];
%\draw[dashed] (s) -- (t) node[intnode,label={right:{\color{black}\scriptsize $T$}}] (t) {};
% Angles
\tkzFindAngle(a,c,b)
\tkzGetAngle{angleABC};
\FPround\angleABC\angleABC{0}
\tkzFindAngle(b,a,c)
\tkzGetAngle{angleCAB};
\FPround\angleCAB\angleCAB{0}
\tkzFindAngle(c,b,a)
\tkzGetAngle{angleBCA};
\FPround\angleBCA\angleBCA{0}
%\tkzFindAngle(a,s,t)
%\tkzGetAngle{angleAST};
%\FPround\angleAST\angleAST{0}
\tkzMarkAngle[myangle](a,c,b)
\tkzLabelAngle[pos=.4](a,c,b){\tiny $\angleABC^\circ$}
\tkzMarkAngle[myangle](b,a,c)
\tkzLabelAngle[pos=0.5](b,a,c){\tiny $\angleCAB^\circ$}
\tkzMarkAngle[myangle](c,b,a)
\tkzLabelAngle[pos=0.45](c,b,a){\tiny $\angleBCA^\circ$}
%\tkzMarkAngle[myangle](a,s,t)
%\tkzLabelAngle[pos=0.4](a,s,t){\tiny $\angleAST^\circ$}
%\node[intnode,label={left:\scriptsize $S$}] at (s) {};
\end{tikzpicture}
\end{document}
我只是将所有出现的B
byC
和C
by交换B
,使该段成为AB
水平的。
为了绘制垂直虚线,我使用了一对垂直线,它们从 开始C
,向下延伸到 相同的y
坐标,B
然后向右延伸到B
,如下所示:\draw[dashed] (c) |- (b);
。由于该段AB
是连续的,因此虚线的水平部分会消失。