我正在制作工作表来帮助学生记住单位圆和/或特殊三角形。
我想要蓝色箭头表示终端臂和 x 轴之间的参考角度。
我怎么做?
\documentclass{article}
\usepackage{tikz}
\newcommand{\MyScale}{1.75}
\newcommand{\OneFifty}
{%
Sketch \(\theta=150^\circ\) in standard position, labeling all sides, the angle, and the reference angle. Then, state all its trigonometric ratios.
\begin{tikzpicture}[scale=\MyScale]
\draw[thick,<->] (-2,0)--(1,0); % x-axis
\draw[thick,<->] (0,-1)--(0,1.5); % y-axis
\draw (0,0)--(-1.732,1); % terminal arm
\draw (-1.732,1)--(-1.732,0); % vertical drop
\draw (-1.532,0)--(-1.532,0.2)--(-1.732,0.2); %right-angle mark
\node[anchor=center] at (-0.866,-0.2) {A \(=-\sqrt{3}\)};
\node[anchor=center] at (-2.1,0.5) {OP \(=1\)};
\node[anchor=center] at (-0.8, 0.8) {H \(=2\)};
%Angle in standard position.
\node[red, anchor=center] at (1.4,0.3) {\(\theta=150^\circ\)};
\draw[red,->] (0.866,0) arc (0:150:0.866); % Angle in SP
\node[blue, anchor=center] at (-0.3,0.2) {\(\theta_{r} =30^{\circ}\)}; % Reference Angle label
\draw[blue,<->] (0.35,0) arc (150:180:0.35); % Reference Angle
\end{tikzpicture}%
\(\sin{150^\circ}=\frac{1}{2}\)
\(\cos{150^\circ}=\frac{-\sqrt{3}}{2}=-\frac{\sqrt{3}}{2}\)
\(\tan{150^\circ}=\frac{1}{-\sqrt{3}}=-\frac{\sqrt{3}}{3}\)
\(\csc{150^\circ}=\frac{2}{1}=2\)
\(\sec{150^\circ}=\frac{2}{-\sqrt{3}}=-\frac{2\sqrt{3}}{3}\)
\(\cot{150^\circ}=\frac{-\sqrt{3}}{1}=-\sqrt{3}\)
}
\begin{document}
\OneFifty
\end{document}
答案1
angles
可以使用@TorbjørnT 建议的库优雅地实现这一点。您还需要quotes
库来标记角度。我\( .. \)
把所有都改成了$ .. $
;括号没有问题,但它伤害了我的眼睛,我更喜欢更明显的符号$
。最后,我认为 a\newcommand
在这里没有什么用,因为这个数字不太可能重复多次。您可以考虑删除newcommand
并直接插入图形和文本。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{angles,quotes} % <<----
\newcommand{\MyScale}{1.75}
\newcommand{\OneFifty}
{%
Sketch $\theta=150^\circ$ in standard position, labeling all sides, the angle, and the reference angle. Then, state all its trigonometric ratios.
\begin{tikzpicture}[scale=\MyScale]
\draw[thick,<->] (-2,0)coordinate(B)--(1,0)coordinate(C); % x-axis <<----
\draw[thick,<->] (0,-1)--(0,1.5); % y-axis
\draw (0,0)coordinate(O)--(-1.732,1)coordinate(A); % terminal arm <<----
\draw (-1.732,1)--(-1.732,0); % vertical drop
\draw (-1.532,0)--(-1.532,0.2)--(-1.732,0.2); %right-angle mark
\node[anchor=center] at (-0.866,-0.2) {A \(=-\sqrt{3}\)};
\node[anchor=center] at (-2.1,0.5) {OP \(=1\)};
\node[anchor=center] at (-0.8, 0.8) {H \(=2\)};
% Angle in standard position.
\pic [draw,<->, blue, angle radius=8mm, "$\theta_{r} =30^\circ$", angle eccentricity=2] {angle=A--O--B};
\pic [draw,<->, red, angle radius=8mm, "$\theta=150^\circ$", angle eccentricity=1.4] {angle=C--O--A};
\end{tikzpicture}%
$\sin{150^\circ}=\frac{1}{2}$
$\cos{150^\circ}=\frac{-\sqrt{3}}{2}=-\frac{\sqrt{3}}{2}$
$\tan{150^\circ}=\frac{1}{-\sqrt{3}}=-\frac{\sqrt{3}}{3}$
$\csc{150^\circ}=\frac{2}{1}=2$
$\sec{150^\circ}=\frac{2}{-\sqrt{3}}=-\frac{2\sqrt{3}}{3}$
$\cot{150^\circ}=\frac{-\sqrt{3}}{1}=-\sqrt{3}$
}
\begin{document}
\OneFifty
\end{document}
答案2
@AboAmmar 的答案我觉得很好,满足了问题的要求,尽管看你的代码我可以看到有很多坐标计算用手什么时候蒂克兹提供了强大的工具来计算坐标和节点定位。例如在\draw (0,0)--(-1.732,1); % terminal arm
其中-1.732
假设等于-\sqrt{3}
,在这种情况下以极坐标形式表示该坐标更合适,即(150:2)
角度为150
,半径为2
。
另一种常见的做法是命名坐标,以便以后计算时参考。此外,还可以使用标签定位自动的方式。
出于上述考虑,我决定使用以下方法重写代码我的“自己的风格”可以这么说(不是为了解决问题,而是为了玩一会儿)蒂克兹来实现大部分的计算。
以下是我的想法的总结:
- 首先命名几个坐标,实际上只有轴的端点
(W)
(E)
(S)
(N)
和原点(O)
。 自动定位每个路径内的标签。例如
\draw (p) -- node[left] {OP${}=1$} (p|-E) coordinate (pE); % vertical drop with its node 'OP=1'
(p|-E)
(p)
被计算为在轴上的投影x-
并命名为(pE)
。使用
angle
库来标记和标注角度,如@AboAmmar 的答案中所述。我定义了一个
pic
(灵感来自pic {angle}
)来标记直角,\pic at (pE) {right angle}; % right-angle mark
这不是真的必要,但我正在学习使用
pics
,我喜欢它可以通过选项和参数来丰富,例如使用\pic [fill,orange,transform shape] at (pE) {right angle}; % right-angle mark
用
fill
颜色,transform shape
使图片 可扩展与scale=<factor>
图片的 一致。如果您想要不同大小的标记,可以使用right angle=<dimension>
等,例如\pic at (pE) {right angle=6mm}; % right-angle mark
最后,我喜欢等号对齐,因此我使用了
alignedat
包的环境amsmath
\ang{...}
以及包中定义的宏siunitx
它自动解析数字和测量单位。
完整代码
\documentclass{article}
\usepackage{amsmath} % For 'alignedat' environment
\usepackage{tikz}
\usetikzlibrary{angles,quotes,calc}
\tikzset{% Define a ´pic´ to mark a right angle (square)
pics/right angle/.style={%
background code = {
\path [pic actions] (0,0) -- ++(#1,0) -- ++(0,#1) -- ++(-#1,0) -- cycle;
},
foreground code = {
\draw [pic actions] (0,0) ++(#1,0) -- ++(0,#1) -- ++(-#1,0);
},
},
pics/right angle/.default=2mm
}
\usepackage{siunitx}
\newcommand{\MyScale}{1.75}
\begin{document}
Sketch $\theta=\ang{150}$ in standard position, labeling all sides, the angle, and the reference angle. Then, state all its trigonometric ratios.
\begin{tikzpicture}[scale=\MyScale]
\coordinate (W) at (-2,0); % West tip of 'x'
\coordinate (E) at (1,0); % East tip of 'x'
\coordinate (N) at (0,1.5); % North tip of 'y'
\coordinate (S) at (0,-1); % South tip of 'y'
\coordinate (O) at (0,0); % Origin
\begin{scope}[thick,<->]
\draw (W) -- (E); % x-axis
\draw (S) -- (N); % y-axis
\end{scope}
\draw (O) -- node[above,sloped,pos=0.6] {H${}=2$} (150:2) coordinate (p); % terminal arm with its node 'H=2'
\draw (p) -- node[left] {OP${}=1$} (p|-E) coordinate (pE); % vertical drop with its node 'OP=1'
\pic [orange,transform shape] at (pE) {right angle}; % right-angle mark (scaled by \MyScale)
\path (O) -- node[below] {A${}=-\sqrt{3}$} (pE); % node 'A=...' (adjacent)
%%Angles
\begin{scope}[angle radius=8mm, pic text options={font=\footnotesize}]
\pic [angle radius=13mm,draw,->, red, "$\theta=\ang{150}$", angle eccentricity=1.2] {angle=E--O--p}; % Angle in SP with its label
\pic [draw,<-, blue, anchor=east, "$\theta_{r}=\ang{30}$", angle eccentricity=1] {angle=p--O--W}; % Reference Angle with its label
\end{scope}
\end{tikzpicture}%
$\begin{alignedat}{2}
&\sin\ang{150}& &=\tfrac{1}{2}\\
&\cos\ang{150}& &=\tfrac{-\sqrt{3}}{2}=-\tfrac{\sqrt{3}}{2}\\
&\tan\ang{150}& &=\tfrac{1}{-\sqrt{3}}=-\tfrac{\sqrt{3}}{3}\\
&\csc\ang{150}& &=\tfrac{2}{1}=2\\
&\sec\ang{150}& &=\tfrac{2}{-\sqrt{3}}=-\tfrac{2\sqrt{3}}{3}\\
&\cot\ang{150}& &=\tfrac{-\sqrt{3}}{1}=-\sqrt{3}
\end{alignedat}$
\end{document}