旋转圆弧怎么画

旋转圆弧怎么画

我想在黄色圆圈内画圆弧

在此处输入图片描述

答案1

欢迎来到 TeX.SX!如果您使用 TiZ(我根据标签假设),您可以定义一张图片,或者两张图片,一张用于正面,一张用于背面:

\documentclass[border=10pt]{standalone}
\usepackage{tikz}

\tikzset{
    revolving arrow back/.pic = {
        \draw[fill=white, pic actions] 
            (-90:1 and 2) ++(0.5,0)
            arc[start angle=-90, end angle=90, x radius=1, y radius=2] 
            -- ++(-1,0)
            arc[start angle=90, end angle=-90, x radius=1, y radius=2] -- cycle;
    },
    revolving arrow front/.pic = {
        \draw[fill=white, pic actions]
            (90:1 and 2) ++(0.5,0)
            arc[start angle=90, end angle=150, x radius=1, y radius=2] 
            -- ++(0.5,0) -- ++(-1,-1.5) -- ++(-1,1.5) -- ++(0.5,0) 
            arc[start angle=150, end angle=90, x radius=1, y radius=2] 
            -- cycle
            (210:1 and 2) ++(0.5,0)
            arc[start angle=210, end angle=270, x radius=1, y radius=2] 
            -- ++ (-1,0)
            arc[start angle=270, end angle=210, x radius=1, y radius=2] 
            -- cycle;
    }
}

\begin{document}

\begin{tikzpicture}

\pic[magenta, scale=0.5] at (0,0) {revolving arrow back};

\draw[-stealth] (-2,0) -- (2,0);

\pic[magenta, scale=0.5] at (0,0) {revolving arrow front};

\end{tikzpicture}

\end{document}

在此处输入图片描述


如果您还希望获得差距,您可以使用以下一些方法preaction

\documentclass[border=10pt]{standalone}
\usepackage{tikz}

\tikzset{
    revolving arrow back/.pic = {
        \draw[fill=white, pic actions] 
            (-90:1 and 2) ++(0.5,0)
            arc[start angle=-90, end angle=90, x radius=1, y radius=2] 
            -- ++(-1,0)
            arc[start angle=90, end angle=-90, x radius=1, y radius=2] -- cycle;
    },
    revolving arrow front/.pic = {
        \draw[fill=white, white border, pic actions]
            (90:1 and 2) ++(0.5,0)
            arc[start angle=90, end angle=150, x radius=1, y radius=2] 
            -- ++(0.5,0) -- ++(-1,-1.5) -- ++(-1,1.5) -- ++(0.5,0) 
            arc[start angle=150, end angle=90, x radius=1, y radius=2] 
            -- cycle
            (210:1 and 2) ++(0.5,0)
            arc[start angle=210, end angle=270, x radius=1, y radius=2] 
            -- ++ (-1,0)
            arc[start angle=270, end angle=210, x radius=1, y radius=2] 
            -- cycle;
    },
    white border/.default = 3pt,
    white border/.style = {
        preaction = {
            draw,
            white,
            line join = bevel,
            line width = #1,
        },
    }
}

\begin{document}

\begin{tikzpicture}

\pic[magenta, scale=0.25] at (0,0) {revolving arrow back};

\draw[-stealth, white border] (-1,0) -- (1,0);

\pic[magenta, scale=0.25] at (0,0) {revolving arrow front};

\end{tikzpicture}

\end{document}

在此处输入图片描述


利用该backgrounds库,可以创建一个自动将图片附加到其中心的路径:

\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc, backgrounds}

\tikzset{
    revolving arrow/.style = {
        preaction = {
            draw,
            white,
            line join = bevel,
            line width = 3pt,
        },
        to path = {
            -- (\tikztotarget) 
            pic at ($(\tikztostart)!0.5!(\tikztotarget)$) {revolving arrow back}
            pic at ($(\tikztostart)!0.5!(\tikztotarget)$) {revolving arrow front}
            \tikztonodes
        }
    },
    revolving arrow pic/.style = {
        scale=0.25,
        draw,
        fill=white,
    },
    revolving arrow pic front/.style = { 
        revolving arrow pic,
        preaction = {
            draw,
            white,
            line join = bevel,
            line width = 3pt,
        }
    },
    revolving arrow pic back/.style = { 
        revolving arrow pic,
    },
    revolving arrow back/.pic = {
        \begin{scope}[on background layer]
            \path[revolving arrow pic back] 
                (-90:1 and 2) ++(0.5,0)
                arc[start angle=-90, end angle=90, x radius=1, y radius=2] 
                -- ++(-1,0)
                arc[start angle=90, end angle=-90, x radius=1, y radius=2] -- cycle;
        \end{scope}
    },
    revolving arrow front/.pic = {
        \path[revolving arrow pic front]
            (90:1 and 2) ++(0.5,0)
            arc[start angle=90, end angle=150, x radius=1, y radius=2] 
            -- ++(0.5,0) to[bend right=2.5] ++(-1,-1.5) to[bend left=2.5] ++(-1,1.5) -- ++(0.5,0)
            arc[start angle=150, end angle=90, x radius=1, y radius=2] 
            -- cycle
            (210:1 and 2) ++(0.5,0)
            arc[start angle=210, end angle=270, x radius=1, y radius=2] 
            -- ++ (-1,0)
            arc[start angle=270, end angle=210, x radius=1, y radius=2] 
            -- cycle;
    }
}

\begin{document}

\begin{tikzpicture}

\draw[-stealth, revolving arrow] (-1,1.5) to (1,1.5);

\draw[-stealth, revolving arrow] (10:-1) to[revolving arrow pic/.append style={draw=magenta, rotate=10}] (10:1);

\end{tikzpicture}

\end{document}

在此处输入图片描述

相关内容