放一个直角尺来表示90度角

放一个直角尺来表示90度角

在此处输入图片描述

我应该如何放置一个正方形来表示 90 度角?我的代码是;

\documentclass{article}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}[scale=1.3]
\draw [->, ultra thick, grey](0,-6)--(0,6) node[right,font=\fontsize {30}
{30}\selectfont]{$x$};
\draw [->,ultra thick, grey](-6,0)--(6,0) node[above,font=\fontsize {30}
{30}\selectfont]{$y$};
\draw (6,-2)--(-6,6);
\draw (-4,-4)--(2,5);
\draw[font=\fontsize{15}{15}\selectfont,black]
 --(3,1) node {$\tan\theta_2$};
 \fill[yellow] (3,0)-- ++(4mm,0mm)
 arc[start angle=0, end angle=143.130102, radius=4mm]--cycle;
 \fill[yellow] (-1.333333333,0)-- ++(4mm,0mm)
 arc[start angle=0, end angle=56.3099, radius=4mm]--cycle;
 \draw[font=\fontsize{10}{10}\selectfont, black]
 --(-.5,.4) node {$\tan\theta_1$};

\end{tikzpicture}

\end{document}

答案1

在这种情况下,手动操作可能是最简单的方法。(我还用灰色替换了灰色。)

\documentclass{article}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}[scale=1.3]
\draw [->, ultra thick, gray](0,-6)--(0,6) node[right,font=\fontsize {30}
{30}\selectfont]{$x$};
\draw [->,ultra thick, gray](-6,0)--(6,0) node[above,font=\fontsize {30}
{30}\selectfont]{$y$};
\draw (6,-2)--(-6,6);
\draw (-4,-4)--(2,5);
\draw (0.3,{2-0.2}) -- ++(-0.2,-0.3)--++(-0.3,0.2);
\draw[font=\fontsize{15}{15}\selectfont,black]
 --(3,1) node {$\tan\theta_2$};
 \fill[yellow] (3,0)-- ++(4mm,0mm)
 arc[start angle=0, end angle=143.130102, radius=4mm]--cycle;
 \fill[yellow] (-1.333333333,0)-- ++(4mm,0mm)
 arc[start angle=0, end angle=56.3099, radius=4mm]--cycle;
 \draw[font=\fontsize{10}{10}\selectfont, black]
 --(-.5,.4) node {$\tan\theta_1$};

\end{tikzpicture}

\end{document}

在此处输入图片描述

编辑:这里有一个可能更简单的替代方案,并附有解释。

\documentclass{article}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}[scale=1.3]
\draw [->, ultra thick, gray](0,-6)--(0,6) node[right,font=\fontsize {30}
{30}\selectfont]{$x$};
\draw [->,ultra thick, gray](-6,0)--(6,0) node[above,font=\fontsize {30}
{30}\selectfont]{$y$};
\draw (6,-2)--(-6,6);
\draw (-4,-4)--(2,5);
% the slope of the first line is -12/8, so this defines the rotation angle
\draw[rotate around={atan2(8,-12):(0,2)}] (0,2) rectangle ++(-0.3,0.3);
%\draw (0.3,{2-0.2}) -- ++(-0.2,-0.3)--++(-0.3,0.2);
\draw[font=\fontsize{15}{15}\selectfont,black]
 --(3,1) node {$\tan\theta_2$};
 \fill[yellow] (3,0)-- ++(4mm,0mm)
 arc[start angle=0, end angle=143.130102, radius=4mm]--cycle;
 \fill[yellow] (-1.333333333,0)-- ++(4mm,0mm)
 arc[start angle=0, end angle=56.3099, radius=4mm]--cycle;
 \draw[font=\fontsize{10}{10}\selectfont, black]
 --(-.5,.4) node {$\tan\theta_1$};

\end{tikzpicture}

\end{document}

答案2

我会重新绘制你的图像如下:

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{angles,
                backgrounds,
                intersections,
                quotes}

\begin{document}
    \begin{tikzpicture}[%[scale=1.3]
     al/.style = {font=\Huge},% axis label
myangle/.style = {angle radius=7mm, angle eccentricity=1.6, fill=yellow, font=\scriptsize},
                    ]
\draw[->, ultra thick, gray] (0,-6)--(0,6) node[al,right]{$x$};
\draw[name path=A,->, ultra thick, gray] (-6,0)--(6,0) node[al,above]{$y$};
\draw[name path=B] (-6,6) -- node[draw, minimum size=5mm, outer sep=0pt, sloped, % <--
                                  below right] {} (6,-2);
\draw[name path=C] (-4,-4)--(2,5);
%
\path[name intersections={of=A and B, by=a}];
\path[name intersections={of=A and C, by=b}];
\path[name intersections={of=B and C, by=c}];
%
    \begin{scope}[on background layer]
\pic[myangle, "$\tan\theta_1$"] {angle = a--b--c};
\pic[myangle, "$\tan\theta_2$"] {angle = c--a--b};
    \end{scope}
    \end{tikzpicture}
\end{document}

这使:

在此处输入图片描述

答案3

甚至在 3D 模式下也能工作!

在此处输入图片描述

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,intersections}

\pgfkeys{/tikz/.cd,
  AngleDt length/.store in=\AngleDtLgth,
  AngleDt length=5pt}

\tikzset{% Angle droit
    AngleDt/.style={very thin},
    pics/.cd,
    AngleDt/.style args={#1-#2-#3}{%
        code = {%
        \draw[AngleDt] ($(#2)!\AngleDtLgth!(#1)$)
        --($(#2)!2!($($(#2)!\AngleDtLgth!(#1)$)!.5!($(#2)!\AngleDtLgth!(#3)$)$) $)
        --($(#2)!\AngleDtLgth!(#3)$) ; ;
        }
    }}

\begin{document}

\begin{tikzpicture}[scale=1.3]
\draw [->, ultra thick](0,-6)--(0,6) node[right,font=\fontsize {30}
{30}\selectfont]{$x$};
\draw [->,ultra thick](-6,0)--(6,0) node[above,font=\fontsize {30}
{30}\selectfont]{$y$};
\draw[name path=P1] (6,-2) coordinate (A) --(-6,6);
\draw[name path=P2] (-4,-4)--(2,5) coordinate (C);
\draw[font=\fontsize{15}{15}\selectfont,black]
 --(3,1) node {$\tan\theta_2$};
 \fill[yellow] (3,0)-- ++(4mm,0mm)
 arc[start angle=0, end angle=143.130102, radius=4mm]--cycle;
 \fill[yellow] (-1.333333333,0)-- ++(4mm,0mm)
 arc[start angle=0, end angle=56.3099, radius=4mm]--cycle;
 \draw[font=\fontsize{10}{10}\selectfont, black]
 --(-.5,.4) node {$\tan\theta_1$};


\path[name intersections={of= P1 and P2,by=B}] ;
\path pic[AngleDt length=7mm,red] {AngleDt={A-B-C}} ;

\end{tikzpicture}

\begin{tikzpicture}[line join=round,
    x={(40:2.6cm)},
    y={(180:4cm)},
    z={(0cm,4cm)}]

\coordinate (C) at (1,0,0) ;
\coordinate (B) at (0,0,0) ;
\coordinate (A) at (0,1,0) ;
\coordinate (D) at (1,1,0) ;

\coordinate (H) at (.5,.5,.707) ;
\coordinate (h) at (.5,.5,0) ;

\fill[blue!15] (A)--(B)--(H)--cycle ;
\fill[blue!30] (B)--(C)--(H)--cycle ;

\draw (A)--(B)--(C)--(H)--cycle ;
\draw (B)--(H) ;

\draw[dashed] (A)--(D)--(C) ;
\draw[dashed] (H)--(D) ;

\draw[dotted] (A)--(C) ;
\draw[dotted] (B)--(D) ;
\draw[dotted] (H)--(h) node[midway,anchor=east] {$h$};

\path pic {AngleDt={H-h-A}} ;
\path pic {AngleDt={B-h-H}} ;

\foreach \Coor/\Text/\Pos in 
    {A/$A$/215,
    B/$B$/-45,
    C/$C$/0,
    D/$D$/-92,
    H/$H$/90%
    } {%
    \node[shift=(\Pos:8pt),anchor=center] at (\Coor) {\small\Text} ;
    }

\end{tikzpicture}
\end{document}

答案4

right angle这就是我使用Ti重新绘制图像的方法3.1:

\documentclass[tikz,border=7pt]{standalone}
\usetikzlibrary{angles}
\begin{document}
  \tikz[nodes={scale=.7}]
    \path
      % axes
      (4,0) edge[latex-] (-2,0) coordinate (X) node[above]{$x$}
      (0,3) edge[latex-] (0,-1) coordinate (Y) node[right]{$y$}
      % points
      foreach \x/\y/\n in {0/0/O,-1.3/0/A,3/0/B,0/2/C}{
        (\x,\y) coordinate(\n)
      }
      % sloped lines
      (A) edge[gray,shorten <=-7mm,shorten >=-7mm] (C)
      (B) edge[gray,shorten <=-7mm,shorten >=-7mm] (C)
      % angles
      pic[fill=yellow,angle eccentricity=2.1,pic text=$\tan\theta_1$]{angle=X--A--C}
      pic[fill=yellow,angle eccentricity=1.5,pic text=$\tan\theta_2$]{angle=X--B--C}
      pic[fill=red,angle radius=4mm]{right angle=A--C--B}
    ;
\end{document}

在此处输入图片描述

相关内容