使用 tikz 包绘制三角圆

使用 tikz 包绘制三角圆

我想画下面的三角圆 在此处输入图片描述

我找到了网站https://texample.net/tikz/examples/unit-circle/ 包含代码。

请帮忙修改代码以获取此图像。提前谢谢您!

\documentclass[landscape]{article}
    \usepackage{tikz}
    \usepackage[active,tightpage]{preview}
    \PreviewEnvironment{tikzpicture}
    \setlength\PreviewBorder{5pt}%
    \usepackage[top=1in,bottom=1in,right=1in,left=1in]{geometry}
    \begin{document}
        \begin{tikzpicture}[scale=5.3,cap=round,>=latex]
            % draw the coordinates
            \draw[->] (-1.5cm,0cm) -- (1.5cm,0cm) node[right,fill=white] {$x$};
            \draw[->] (0cm,-1.5cm) -- (0cm,1.5cm) node[above,fill=white] {$y$};
    
            % draw the unit circle
            \draw[thick] (0cm,0cm) circle(1cm);
    
            \foreach \x in {0,30,...,360} {
                    % lines from center to point
                    \draw[gray] (0cm,0cm) -- (\x:1cm);
                    % dots at each point
                    \filldraw[black] (\x:1cm) circle(0.4pt);
                    % draw each angle in degrees
                    \draw (\x:0.6cm) node[fill=white] {$\x^\circ$};
            }
    
            % draw each angle in radians
            \foreach \x/\xtext in {
                30/\frac{\pi}{6},
                45/\frac{\pi}{4},
                60/\frac{\pi}{3},
                90/\frac{\pi}{2},
                120/\frac{2\pi}{3},
                135/\frac{3\pi}{4},
                150/\frac{5\pi}{6},
                180/\pi,
                210/\frac{7\pi}{6},
                225/\frac{5\pi}{4},
                240/\frac{4\pi}{3},
                270/\frac{3\pi}{2},
                300/\frac{5\pi}{3},
                315/\frac{7\pi}{4},
                330/\frac{11\pi}{6},
                360/2\pi}
                    \draw (\x:0.85cm) node[fill=white] {$\xtext$};
    
            \foreach \x/\xtext/\y in {
                % the coordinates for the first quadrant
                30/\frac{\sqrt{3}}{2}/\frac{1}{2},
                45/\frac{\sqrt{2}}{2}/\frac{\sqrt{2}}{2},
                60/\frac{1}{2}/\frac{\sqrt{3}}{2},
                % the coordinates for the second quadrant
                150/-\frac{\sqrt{3}}{2}/\frac{1}{2},
                135/-\frac{\sqrt{2}}{2}/\frac{\sqrt{2}}{2},
                120/-\frac{1}{2}/\frac{\sqrt{3}}{2},
                % the coordinates for the third quadrant
                210/-\frac{\sqrt{3}}{2}/-\frac{1}{2},
                225/-\frac{\sqrt{2}}{2}/-\frac{\sqrt{2}}{2},
                240/-\frac{1}{2}/-\frac{\sqrt{3}}{2},
                % the coordinates for the fourth quadrant
                330/\frac{\sqrt{3}}{2}/-\frac{1}{2},
                315/\frac{\sqrt{2}}{2}/-\frac{\sqrt{2}}{2},
                300/\frac{1}{2}/-\frac{\sqrt{3}}{2}}
                    \draw (\x:1.25cm) node[fill=white] {$\left(\xtext,\y\right)$};
    
            % draw the horizontal and vertical coordinates
            % the placement is better this way
            \draw (-1.25cm,0cm) node[above=1pt] {$(-1,0)$}
                  (1.25cm,0cm)  node[above=1pt] {$(1,0)$}
                  (0cm,-1.25cm) node[fill=white] {$(0,-1)$}
                  (0cm,1.25cm)  node[fill=white] {$(0,1)$};
        \end{tikzpicture}
    \end{document}

答案1

经过一些调整并使用rotate around键,这是我的尝试。主要更改由% <--

\documentclass{standalone}
\usepackage{tikz}
\begin{document}
  \begin{tikzpicture}[scale=5.3,cap=round,>=latex]
    \draw[->] (-1.5cm,0cm) -- (1.5cm,0cm) node[right,fill=white] {$x$}; % x axis
    \draw[->] (0cm,-1.5cm) -- (0cm,1.5cm) node[above,fill=white] {$y$}; % y axis
    
    % draw the unit circle
    \draw[thick] (0cm,0cm) circle(1cm);
    
    \foreach \x in {45,135, 225,315,0,30,...,360} { % <-- bissectrices added
      \draw[gray] (0cm,0cm) -- (\x:1cm); % lines from center to point
      \filldraw[black] (\x:1cm) circle(0.4pt); % dots at each point
    }
    
    % for the first and fourth quadrants
    \foreach \adeg/\radtext/\xc/\yc in {
      30/\frac{\pi}{6}/\frac{\sqrt{3}}{2}/\frac{1}{2},
      45/\frac{\pi}{4}/\frac{\sqrt{2}}{2}/\frac{\sqrt{2}}{2},
      60/\frac{\pi}{3}/\frac{1}{2}/\frac{\sqrt{3}}{2},
      300/\frac{5\pi}{3}/\frac{1}{2}/-\frac{\sqrt{3}}{2},
      315/\frac{7\pi}{4}/\frac{\sqrt{2}}{2}/-\frac{\sqrt{2}}{2},
      330/\frac{11\pi}{6}/\frac{\sqrt{3}}{2}/-\frac{1}{2}
    }
    {
      \draw (\adeg:0.6cm) node[fill=white, rotate around={\adeg:(0,0)}] {$\adeg^\circ$}; % <-- rotate around key used
      \draw (\adeg:0.85cm) node[fill=white, rotate around={\adeg:(0,0)}] {$\radtext$}; % <-- rotate around key used
      \draw (\adeg:1.025cm) node[fill=white, rotate around={\adeg:(0,0)}, anchor=west] {$\left(\xc,\yc\right)$}; % <-- rotate around key used, radius changed, anchor key used
    }
  
    % for the second and third quadrants
    \foreach \adeg/\radtext/\xc/\yc in {
      120 / \frac{2\pi}{3} / -\frac{1}{2} / \frac{\sqrt{3}}{2},
      135 / \frac{3\pi}{4} / -\frac{\sqrt{2}}{2} / \frac{\sqrt{2}}{2},
      150 / \frac{5\pi}{6} / -\frac{\sqrt{3}}{2} / \frac{1}{2},
      210 / \frac{7\pi}{6} / -\frac{\sqrt{3}}{2} / -\frac{1}{2},
      225 / \frac{5\pi}{4} / -\frac{\sqrt{2}}{2} / -\frac{\sqrt{2}}{2},
      240 / \frac{4\pi}{3} / -\frac{1}{2} / -\frac{\sqrt{3}}{2}
    }
    {
      \draw (\adeg:0.6cm) node[fill=white, rotate around={\adeg+180:(0,0)}] {$\adeg^\circ$}; % <-- rotate around key used
      \draw (\adeg:0.85cm) node[fill=white, rotate around={\adeg+180:(0,0)}] {$\radtext$}; % <-- rotate around key used
      \draw (\adeg:1.025cm) node[fill=white, rotate around={\adeg+180:(0,0)}, anchor=east] {$\left(\xc,\yc\right)$}; % <-- rotate around key used, radius changed, anchor key used
    }
    
    \foreach \adeg/\radtext/\xc/\yc in {0 / 2\pi / 1 / 0, 180 / \pi / -1 / 0}
    {
      \draw (\adeg:0.6cm) node[fill=white, above=1pt] {$\adeg^\circ$};
      \draw (\adeg:0.85cm) node[fill=white, above=1pt] {$\radtext$};
      \draw (\adeg:1.15cm) node[fill=white, above=1pt] {$\left(\xc,\yc\right)$}; % <-- radius changed
    }
    
    \foreach \adeg/\radtext/\xc/\yc in {90 / \frac{\pi}{2} / 0 / 1, 270 / \frac{3\pi}{2} / 0 / -1}
    {
      \draw (\adeg:0.6cm) node[fill=white, right=1pt] {$\adeg^\circ$};
      \draw (\adeg:0.85cm) node[fill=white, right=1pt] {$\radtext$};
      \draw (\adeg:1.1cm) node[fill=white, right=1pt] {$\left(\xc,\yc\right)$}; % <-- radius changed
    }
  \end{tikzpicture}
\end{document}

答案2

我会添加到节点选项sloped

编辑: 根据OP的评论我做了以下修改:

  • 在外节点上添加节点锚点(west for nodes on the left halfplane,对于右半平面的节点,为西边),
  • 所有节点的位置略有改变
  • 更改了单位圆标签
\documentclass[landscape]{article}
\usepackage{adjustbox}
\usepackage[margin=1in]{geometry}
\usepackage{tikz}

\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{5pt}%

\begin{document}
    \begin{tikzpicture}[scale=4.5,
cap = round,
  > = latex,
dot/.style = {circle, fill, minimum size=1.2mm},
lbl/.style = {fill=white, inner sep=2pt, near start, sloped}
                        ]
% draw the coordinates
\draw[->] (-1.5,0) -- (1.5,0) node[right] {$x$};
\draw[->] (0,-1.5) -- (0,1.5) node[above] {$y$};
% draw the unit circle
\draw[thick] (0,0) circle[radius=1];
% draw dots, labels
\foreach \i/\j/\k in {
    30/\frac{\pi}{6}/{\left(\frac{\sqrt{3}}{2},\frac{1}{2}\right)},
    45/\frac{\pi}{4}/{\left(\frac{\sqrt{2}}{2},\frac{\sqrt{2}}{2}\right)},
    60/\frac{\pi}{3}/{\left(\frac{1}{2},\frac{\sqrt{3}}{2}\right)},
    90/\frac{\pi}{2}/{\rotatebox{-90}{(0,1)}},
    120/\frac{2\pi}{3}/{\left(\frac{-1}{2},\frac{\sqrt{3}}{2}\right)},
    135/\frac{3\pi}{4}/{\left(\frac{-\sqrt{2}}{2},\frac{\sqrt{2}}{2}\right)},
    150/\frac{5\pi}{6}/{\left(\frac{-\sqrt{3}}{2},\frac{1}{2}\right)},
    180/\pi/{(-1,0)},
    210/\frac{7\pi}{6}/{\left(\frac{-1}{2},\frac{-\sqrt{3}}{2}\right)},
    225/\frac{5\pi}{4}/{\left(\frac{-\sqrt{2}}{2},\frac{-\sqrt{2}}{2}\right)},
    240/\frac{4\pi}{3}/{\left(\frac{-\sqrt{3}}{2},\frac{-1}{2}\right)},
    270/\frac{3\pi}{2}/{\rotatebox{90}{(0,-1)}},
    300/\frac{5\pi}{3}/{\left(\frac{1}{2},\frac{-\sqrt{3}}{2}\right)},
    315/\frac{7\pi}{4}/{\left(\frac{\sqrt{2}}{2},\frac{-\sqrt{2}}{2}\right)},
    330/\frac{11\pi}{6}/{\left(\frac{1}{2},\frac{-\sqrt{3}}{2}\right)},
    360/2\pi/{(1,0)}
                    }
{
\path[draw=gray]    (\i:0) -- (\i:0.5)
        -- node[lbl] {$\i$} (\i:0.75)
        -- node[lbl] {$\j$} (\i:1) node[dot] {};
\ifnum\i<270
    \ifnum\i>90
        \path   (\i:1) --  node[lbl, anchor=east] {$\k$} (\i:1.4);
    \else
        \path   (\i:1) --  node[lbl, anchor=west] {$\k$} (\i:1.4);
    \fi
\else
    \path   (\i:1) --  node[lbl, anchor=west] {$\k$} (\i:1.3);
\fi
}
    \end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容