要在笛卡尔平面上画一个等腰三角形。等长的两条边应位于第一和第二象限。(我手头的代码给出的两条边相对于正 x 轴的角度分别为 41 度和 122 度。)两条边应标记为“1”,第三条边应标记为“c”——我猜是在边缘下方,以免干扰圆。
在以下代码中,以原点为端点的两条边的长度为 1。我如何让 TikZ 进行必要的计算以保持 41 度和 122 度的角度?原点标记为“O”,但它与 y 轴相干扰。我想覆盖它或将其移动到第三象限。(我尝试了命令\node[mydot,label={below,left:$O$}] at (O) {};
。)
\documentclass[10pt]{amsart}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{mathtools,array}
\newlength{\widestright}
\newenvironment{horriblesystem}[1]
{\settowidth{\widestright}{${}=#1$}%
\left\{\,
\begin{array}{@{}r@{}>{\raggedright\arraybackslash${}}p{\widestright}<{$}@{}}}
{\end{array}\right.}
\usepackage{tikz}
\tikzset{
mydot/.style={
fill,
circle,
inner sep=1.5pt
}
}
\begin{document}
\begin{tikzpicture}[>=latex]
% the coordinates of the vertices
\coordinate (O) at (0,0);
\coordinate (A) at (2,1);
\coordinate (B) at (-3,5);
% the axis
\draw[help lines,->] (-3.5,0) -- (2.5,0);
\draw[help lines,->] (0,-0.5) -- (0,5.5);
% the edges of the triangle
\draw (O) -- (A) -- (B) -- cycle;
% labelling the vertices
\node[mydot,label={right:$A$}] at (A) {};
\node[mydot,label={left:$B$}] at (B) {};
\node[mydot,label={below:$O$}] at (O) {};
% the arcs for the angles
\begin{scope}[gray]
\draw[->]
(1,0) +(0:0.5cm) arc [radius=1cm,start angle=0,end angle=41] node[midway,right] {$\alpha$};
\draw[->]
(0.5,0) +(0:0.25cm) arc [radius=0.75cm,start angle=0,end angle=122] node[midway,above] {$\beta$};
\end{scope}
\end{tikzpicture}
\end{document}
答案1
一种使用极坐标的选项(见下文备注):
代码:
\documentclass[10pt]{amsart}
\usepackage{tikz}
\usetikzlibrary{angles,quotes}
\tikzset{
mydot/.style={
fill,
circle,
inner sep=1.5pt
}
}
\def\Side{6cm}
\begin{document}
\begin{tikzpicture}[>=latex]
% the coordinates of the vertices
\coordinate (O) at (0,0);
\path ++(122:\Side) coordinate (A) ++(-40:\Side)
coordinate (B);
% auxiliary coordinates to draw the marks for the angles
\coordinate (aux) at (3,0);
% the axis
\draw[help lines,->] (-3.5,0) -- (2.5,0);
\draw[help lines,->] (0,-0.5) -- (0,5.5);
% the edges of the triangle
\draw
(O) --
node[auto] {$l$}
(A) --
node[auto] {$l$}
(B) --
node[auto] {$c$}
cycle;
% labelling the vertices
\node[mydot,label={above:$A$}] at (A) {};
\node[mydot,label={right:$B$}] at (B) {};
\node[mydot,label={below left:$O$}] at (O) {};
% the arcs for the angles
\begin{scope}[gray,angle eccentricity=1.2,->]
\path
pic[draw,angle radius=1.5cm,"$\alpha$"] {angle = aux--O--B}
pic[draw,->,angle radius=0.75cm,"$\beta$"] {angle = aux--O--A}
;
\end{scope}
\end{tikzpicture}
\end{document}
评论
可以使用极坐标获得顶点:
% the coordinates of the vertices \coordinate (O) at (0,0); \path ++(122:\Side) coordinate (A) ++(-40:\Side) coordinate (B);
可以使用节点生成侧面的标签:
% the edges of the triangle \draw (O) -- node[auto] {$l$} (A) -- node[auto] {$l$} (B) -- node[auto] {$c$} cycle;
使用
angles
和quotes
库来生成角度标记更加容易:\path pic[draw,angle radius=1.5cm,"$\alpha$"] {angle = aux--O--B} pic[draw,->,angle radius=0.75cm,"$\beta$"] {angle = aux--O--A} ;
使用
\Side
您可以轻松改变长度。
答案2
这个使用intersections
库,你必须知道两边的长度。其余的,我采用了 Gonzalo 的代码。
\documentclass[10pt]{amsart}
\usepackage{tikz}
\usetikzlibrary{angles,quotes,intersections}
\tikzset{
mydot/.style={
fill,
circle,
inner sep=1.5pt
}
}
%% two sides
\def\Side{6cm}
\def\side{2cm}
\begin{document}
\begin{tikzpicture}[>=latex]
% the coordinates of the two vertices
\coordinate (O) at (0,0);
\coordinate (A) at (122:\Side);
\begin{pgfinterruptboundingbox}
\path[name path global=circle] (A) circle (\Side);
\path[name path global=line] (O)circle (\side);
\end{pgfinterruptboundingbox}
\path[name intersections={of=line and circle}];
\coordinate (B) at (intersection-1); %% third vertex
\draw (O) -- (B) -- (A) -- cycle;
% auxiliary coordinates to draw the marks for the angles
\coordinate (aux) at (3,0);
% the axis
\draw[help lines,->] (-3.5,0) -- (2.5,0);
\draw[help lines,->] (0,-0.5) -- (0,5.5);
% the edges of the triangle
\draw
(O) --
node[auto] {$l$}
(A) --
node[auto] {$l$}
(B) --
node[auto] {$c$}
cycle;
% labelling the vertices
\node[mydot,label={above:$A$}] at (A) {};
\node[mydot,label={right:$B$}] at (B) {};
\node[mydot,label={below left:$O$}] at (O) {};
% the arcs for the angles
\begin{scope}[gray,angle eccentricity=1.2,->]
\path
pic[draw,angle radius=1.5cm,"$\alpha$"] {angle = aux--O--B}
pic[draw,->,angle radius=0.75cm,"$\beta$"] {angle = aux--O--A}
;
\end{scope}
\end{tikzpicture}
\end{document}
插图
\path[draw,red,name path global=circle] (A) circle (\Side);
\path[draw,red,name path global=line] (O)circle (\side);
给出
答案3
嗯,从其他答案来看,也许我不明白 OP 的要求,因为我认为这是所需的图像:
我还使用了和库pic
的语法,因此这需要最新版本:angles
quotes
PGF
\documentclass[tikz,border=5]{standalone}
\usetikzlibrary{angles,quotes}
\tikzset{mydot/.style={ fill, circle, inner sep=1.5pt }}
\begin{document}
\begin{tikzpicture}[>=latex]
% the coordinates of the vertices
\coordinate (O) at (0:0);
\coordinate (A) at (41:5);
\coordinate (B) at (122:5);
% the axis
\draw[help lines,->] (-3,0) -- (4,0) coordinate (X);
\draw[help lines,->] (0,-0.5) -- (0,5);
% the edges of the triangle
\draw (O)
-- (A) node [midway, below right] {$l$}
-- (B) node [midway, above] {$c$}
-- cycle node [midway, below left] {$l$};
% labelling the vertices
\node[mydot,label={right:$A$}] at (A) {};
\node[mydot,label={left:$B$}] at (B) {};
\node[mydot,label={below left:$O$}] at (O) {};
% the arcs for the angles
\begin{scope}[gray]
\path pic ["$\alpha$", draw, ->, angle eccentricity=1.10, angle radius=1.5cm]
{angle=X--O--A};
\path pic ["$\beta$", draw, ->, angle eccentricity=1.25, angle radius=1.0cm]
{angle=X--O--B};
\end{scope}
\end{tikzpicture}
\end{document}
答案4
使用 tkz-euclide v2.42b (beta)这里 但也许罐装版本就还不错。
\documentclass{standalone}
\usepackage{tkz-euclide}
\def\side{6}
\begin{document}
\begin{tikzpicture}[>=latex,scale=2]
\tkzInit[xmin=-4,xmax=2,ymax=5]
\tkzDrawXY[noticks]
\tkzDefPoint(0,0){O}
\tkzDefPoint(1,0){i}
\tkzDefPoint(122:\side){A}
\tkzDefShiftPoint[A](-40:\side){B}
\tkzDrawPolygon(O,A,B)
\tkzDrawPoints(O,A,B)
\tkzLabelPoints(O,B)
\tkzLabelPoints[above left](A)
\tkzLabelSegment(A,B){$l$}
\tkzLabelSegments[below](A,O){$l$}
\tkzLabelSegments[below](O,B){$c$}
\tkzMarkAngle[mark=none, size=0.75,->](i,O,A)
\tkzLabelAngle[pos=.85](i,O,A){$\beta$}
\tkzMarkAngle[mark=none, size=1.5,->](i,O,B)
\tkzLabelAngle[pos=1.60](i,O,B){$\alpha$}
\end{tikzpicture}
\end{document}