如何为图中直角三角形添加阴影?
这是我的代码:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usepackage{tkz-euclide}
\usetikzlibrary{intersections}
\usepackage{amsmath}
\usepackage{siunitx}
\sisetup{output-decimal-marker={,}}
\begin{document}
\begin{tikzpicture}[scale=2]
\coordinate [label=left:$\textcolor{white}A$] (A) at (1cm,-3cm);
\coordinate [label=below:$\textcolor{white}B$] (B) at (1cm,1cm);
\coordinate [label=below:$\textcolor{white}C$] (C) at (-4cm,1cm);
\node at (-3.4cm, .85cm) {$\textcolor{blue}{38^\circ}$};
\tkzMarkAngle[size=0.4cm,color=black,mark=](A,C,B)
\tkzMarkRightAngle[draw=red,size=.2](C,B,A);
\draw [thick=black] (A) -- node[right] {$\textrm{\textcolor{blue}{11}}$} (B) -- node[sloped,above] {$\textrm{\textcolor{blue}{x}}$} (C) -- node[sloped, above] {$\textrm{\textcolor{white}{hypotenuse = 82}}$} (A);
\end{tikzpicture}
\end{document}
别介意文字是白色的;我在需要时就会使用它。
答案1
另一种选择。仅限 Ti钾Z 及其图书馆angles
。
那么数字就出了问题,所以我让 Ti钾Z 帮我算一下。
这是代码:
\documentclass[border=6mm]{standalone}
\usepackage {siunitx}
\usepackage {tikz}
\usetikzlibrary{angles}
\sisetup {output-decimal-marker={,}}
\begin{document}
\begin{tikzpicture}[scale=0.5,line join=round]
\def\yb{11}
\def\ac{38} % angle C
\pgfmathsetmacro\x{\yb/tan(\ac)}
\pgfmathsetmacro\h{\yb/sin(\ac)} % hypothenuse
\coordinate (A) at (0,0);
\coordinate (B) at (0,-\yb);
\coordinate (C) at (-\x,0);
\draw[thick,fill=blue!20] (A) -- node[right] {\color{blue}$\yb$}
(B) -- node[sloped,above] {\color{white}hypotenuse = \num{\h}}
(C) -- node[sloped,above] {\color{blue}$x$} cycle;
% angles, with angles library
\draw[thick] pic [draw] {angle=B--C--A} node [below,xshift=1cm] at (C) {\ang{\ac}};
\draw[thick] pic [draw,angle radius=3mm] {right angle=B--A--C};
\end{tikzpicture}
\end{document}
答案2
像这样?我假设你知道如何添加角度值。
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usepackage{tkz-euclide}
\usetikzlibrary{intersections}
\usepackage{amsmath}
\usepackage{siunitx}
\sisetup{output-decimal-marker={,}}
\begin{document}
\begin{tikzpicture}[scale=2]
\coordinate [label=left:$\textcolor{white}A$] (A) at (1cm,-3cm);
\coordinate [label=below:$\textcolor{white}B$] (B) at (1cm,1cm);
\coordinate [label=below:$\textcolor{white}C$] (C) at (-4cm,1cm);
\node at (-3.4cm, .85cm) {$\textcolor{blue}{38^\circ}$};
\tkzMarkAngle[size=0.4cm,color=black,mark=](A,C,B)
\tkzMarkRightAngle[draw=red,size=.2](C,B,A);
\draw [thick=black, fill=white!80!blue] (A) -- node[right] {$\textrm{\textcolor{blue}{11}}$} (B) -- node[sloped,above] {$\textrm{\textcolor{blue}{x}}$} (C) -- node[sloped, above] {$\textrm{\textcolor{white}{hypotenuse = 82}}$} (A);
\end{tikzpicture}
\end{document}
答案3
我的解决方案是自动打印数字。
\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[line join=round,scale=.5,
declare function={c=11;ACB=38;a=c/tan(ACB);b=c/sin(ACB);}]
\path
(0,-c) coordinate (A) node[right]{$A$}
(0,0) coordinate (B) node[right]{$B$}
(-a,0) coordinate (C) node[left]{$C$}
;
\fill[blue!10] (A)--(B)--(C)--cycle;
\draw[magenta] (B) rectangle +(-135:1);
\begin{scope}
\clip (A)--(C)--(B);
\draw[magenta] (C) circle(1.2) +(-ACB/2:2) node{$\pgfmathparse{ACB}\pgfmathprintnumber{\pgfmathresult}^{\circ}$};
\end{scope}
\draw[thick,nodes={magenta}] (A)
--node[right]{\pgfmathparse{c}\pgfmathprintnumber{\pgfmathresult}} (B)
--node[above,blue]{$a\approx$ \pgfmathparse{a}\pgfmathprintnumber[precision=3]{\pgfmathresult}} (C)
--node[sloped,above,blue]{hypothenus $b \approx $ \pgfmathparse{b}\pgfmathprintnumber[precision=3]{\pgfmathresult}} cycle;
\end{tikzpicture}
\end{document}