在直线和弯折线之间画角

在直线和弯折线之间画角

我试图在直线和弯曲线之间画一个角度 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(而不使用anglesquotes库)。

在此处输入图片描述

\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}

演示

相关内容