
我正在嘗試在直線和彎曲線之間繪製角度 alpha。結果如下圖所示。然而,期望的結果是這個角度稍微偏移並且稍微彎曲,因此它適合在 ∠BAC 之間。
\documentclass{article}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{xcolor}
\usetikzlibrary{angles,quotes}
\begin{document}
\begin{figure}[H]
\begin{tikzpicture}[> = stealth]
\coordinate (a) at (0,0);
\coordinate (b) at (3,0);
\coordinate (c) at (3,-1);
\filldraw [gray] (a) circle (2pt)(b) circle (2pt)(c) circle (2pt);
\draw[->] (a) to (b);
\draw[->] (a) [out=7] to (c);
% [out=9]
\node [below] at (0,0) {$A$};
\node [below] at (3,0) {$B$};
\node [below] at (3,-1) {$C$};
% pic[draw, <->, "$\beta$" shift={(-3mm,5mm)}, angle eccentricity=1.2, angle radius=1cm] {angle=a--b--c};
\draw pic[draw,fill=green!30,angle radius=1cm,"foo" shift={(6mm,1mm)}] {angle=c--a--b};
\end{tikzpicture}
\caption{Angle visualised}
\label{fig:offset_visualised}
\end{figure}
\end{document}
有人可以幫我看看角度嗎?
答案1
有一個簡單的繪製方法:使用clip
(以及不使用angles
或quotes
庫)。
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{figure}[h]
\begin{center}
\begin{tikzpicture}[>=stealth]
\path
(0,0) coordinate (a) node[left]{$A$}
(3,0) coordinate (b) node[right]{$B$}
(3,-2) coordinate (c) node[below]{$C$};
\def\ba{(b)--(a)}
\def\ac{(a) to[out=-10] (c)}
\begin{scope}
\clip \ba--\ac--cycle;
\fill[green] (a) circle(1);
\end{scope}
\foreach \p in {a,b,c} \fill[orange] (\p) circle(2.5pt);
\draw[<-] \ba; \draw[->] \ac;
\end{tikzpicture}
\caption{Angle visualised}
\label{fig:offset_visualised}
\end{center}
\end{figure}
\end{document}
答案2
這是一個替代方案(僅供比較)使用梅塔普斯特, 包裹在luamplib
.在這裡,我使用subpath
符號和方向功能直接為彩色段建立路徑,而無需求助於剪切。編譯用lualatex
.
\documentclass[border=5mm]{standalone}
\usepackage{luatex85}
\usepackage{luamplib}
\begin{document}
\mplibtextextlabel{enable}
\begin{mplibcode}
beginfig(1);
z.A = origin;
z.B = 100 right rotated 10;
z.C = z.B shifted 42 down;
forsuffixes $=A, B, C:
dotlabel.bot("$" & str $ & "$", z$) withcolor 1/2 white;
endfor
path a[];
a1 = z.A -- z.B;
a2 = z.A {z.B-z.A} .. z.C;
numeric a, b;
a = arctime 42 of a1;
b = arctime 42 of a2;
path segment;
segment = subpath (0, b) of a2 {direction b of a2 rotated 90} ..
{direction a of a1 rotated 94} subpath (a, 0) of a1 ..
cycle;
fill segment withcolor 7/8[blue, white];
draw segment withcolor 2/3 blue withpen pencircle scaled 1/4;
interim ahangle := 30;
drawarrow a1;
drawarrow a2;
endfig;
\end{mplibcode}
\end{document}
答案3
另一個 MetaPost 替代方案,使用 MetaPost 的 Metafun 格式中的一些預先存在的巨集。也包含在 LuaLaTeX 程式中。
\documentclass[border=2mm]{standalone}
\usepackage{luatex85,luamplib}
\mplibsetformat{metafun}
\mplibtextextlabel{enable}
\begin{document}
\begin{mplibcode}
u = 3cm; pair A, B, C; A = origin; B = (3u,0); C = u*(3,-1);
path p[]; p1 = A -- B; p2 = A{right} .. C;
beginfig(1);
labeloffset := 4.5bp;
forsuffixes P = A, B, C:
drawdot P withcolor .8white withpen pencircle scaled 5bp;
label.bot("$" & str P & "$", P);
endfor;
anglelength := 1.5u;
fill buildcycle(p1, anglebetween(p1, p2, "$\alpha$"), p2) withcolor green;
drawarrow p1; drawarrow p2;
drawarrow anglebetween(p1, p2, "$\alpha$");
endfig;
\end{mplibcode}
\end{document}
答案4
我不確定曲線之間的角度是否已定義。這使用剪裁來繪製並填充與角度圖片等效的曲線。
另一種方法是計算角度或使用\pgfpatharcto
.
\documentclass{standalone}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{xcolor}
\usetikzlibrary{angles,quotes}
\begin{document}
\begin{tikzpicture}[> = stealth]
\coordinate (a) at (0,0);
\coordinate (b) at (3,0);
\coordinate (c) at (3,-1);
\filldraw [gray] (a) circle (2pt)(b) circle (2pt)(c) circle (2pt);
\draw[->] (a) to (b);
\draw[->] (a) [out=7] to (c);
% [out=9]
\node [below] at (0,0) {$A$};
\node [below] at (3,0) {$B$};
\node [below] at (3,-1) {$C$};
% pic[draw, <->, "$\beta$" shift={(-3mm,5mm)}, angle eccentricity=1.2, angle radius=1cm] {angle=a--b--c};
\begin{scope}
\clip (a) [out=7] to (c) -- (b) -- cycle;
\path[very thin,draw=black,fill=green] (a) circle[radius=1cm];
\end{scope}
%\draw pic[draw,fill=green!30,angle radius=1cm,"foo" shift={(6mm,1mm)}] {angle=c--a--b};
\end{tikzpicture}
\end{document}