我正在尝试在参数图上绘制复杂的参数轨迹。因此,我需要绘制半线并标记它们的角度。到目前为止,我已经做到了这一点,问题是角度偏离了一定量。有什么解决办法吗?
ps 如果有人能找到一种方法,让我只需要指定坐标 S 和角度\angle
,就可以自动绘制,那就太感激了(为了调试目的,角度命令绘制的内容变为红色)
\documentclass{article}
\usepackage{tikz}
% Bla Bla Bla...
\usetikzlibrary{calc}
\usetikzlibrary{intersections}
\usetikzlibrary{angles}
\usetikzlibrary{quotes}
\usetikzlibrary{babel}
% Some content Etc....
\begin{document}
\begin{figure}[H]
\centering
\begin{tikzpicture}[dot/.style={circle,inner sep=1pt,fill,name=#1},
extended line/.style={shorten >=-#1,shorten <=-#1},
extended line/.default=50cm, scale=2]
% ----- Zoom and clip ----- %
\clip (-4,-2) rectangle (2,2);
\draw[help lines, color=gray!30, dashed] (-19,-19) grid (19,19);
% ----- Coordinates ----- %
\def\angle{pi/4 r};
\coordinate (O) at (0, 0); % Origin
\coordinate (S) at (-3, 1); % Start of half-line
\coordinate (B) at (10, 0); % Base Line
\coordinate (L) at ({\angle}: 13); % The half-line
% ----- Main ----- %
\draw (B)--(S)--(L) pic [draw=green!50!black, fill=green!20, angle radius=2cm, "$\frac{\pi}{4}$"] {angle = B--S--L};
\draw[very thick] (S) -- +(L);
\draw[very thick, dashed] (S) -- +(B);
% ----- Axes ----- %
\draw[->,ultra thick] (-19,0)--(19,0) node[right]{$x$};
\draw[->,ultra thick] (0,-19)--(0,19) node[above]{$y$};
\end{tikzpicture}
\end{figure}
\end{document}
答案1
抱歉,不清楚您想要什么。考虑到@abcdefg 的评论,您的 MWE 可以重写如下:
\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{angles,
%calc,
%intersections,
quotes,
babel} % for language issues
\begin{document}
\begin{tikzpicture}[
%dot/.style={circle,inner sep=1pt,fill,name=#1},
extended line/.style={shorten >=-#1,shorten <=-#1},
extended line/.default=50cm, scale=2,
myangle/.style = {draw=#1!50!black, fill=#1!20,
angle eccentricity=0.8, angle radius=12m}
]
% ----- Zoom and clip ----- %
\clip (-4,-2) rectangle (2,2);
\draw[help lines, color=gray!30, dashed] (-19,-19) grid (19,19);
% ----- Coordinates ----- %
\def\angle{pi/4 r};
%\coordinate (O) at ( 0, 0); % Origin
\coordinate (S) at (-3, 1); % Start of half-line
\path (S) -- ++ (0:10) coordinate (B) % Base Line
(S) -- ++ (\angle:13) coordinate (L); % The half-line
% ----- Main ----- %
\pic [myangle=orange, "$\frac{\pi}{4}$"] {angle = B--S--L}; % <--- instead of "orange" select your color as you wish
\draw[very thick,cap=round] (S) -- (L);
\draw[very thick, dashed] (S) -- (B);
% ----- Axes ----- %
\draw[->,ultra thick] (-19,0)--(19,0) node[right]{$x$};
\draw[->,ultra thick] (0,-19)--(0,19) node[above]{$y$};
\end{tikzpicture}
\end{document}
上面的 MWE 注释了您 MWE 中未在此处使用的所有库和样式定义。此外,为了集中精力于图表,使用的是standalone
文档类,它仅显示图像(而不是整个页面)。
书写角度标签时也存在细微差别。为此,我们定义了新样式(\myangle
),以缩短代码。绘制方式与 相同\pic
,因此您的方法中使用的线条不再可见。
这就是你要找的吗?