箭头旋转

箭头旋转

我希望箭头看起来更自然,而不是傻乎乎的(这是目前的状态)

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows.new, decorations.markings, calc, fadings,
decorations.pathreplacing, patterns, decorations.pathmorphing, positioning}
\newcommand{\AxisRotator}[1][rotate=0] {%
  \tikz \draw[x = .5em, y = 1.25em, line width = .2ex, -latex, #1] (0,0)  arc (-150:150:.5 and .5);%                                                   
  }

\begin{document}
\begin{center}
  \begin{tikzpicture}[scale = .75]
    \draw (-2,0) -- (-3,1.5);
    \draw (2,0) -- (3,1.5);
    \draw (-2,0) -- (2,0);
    \draw[-latex] (0,.75) -- (0,2);
    \draw (0,1.5) node {\AxisRotator[rotate = -90]};
    \begin{scope}[yshift = .25cm]
      \clip (-2.5,1) -- (2.5,1) -- (2.5,.25) -- (-2.5,.25) -- cycle;
      \draw (0,1) ellipse (2.75cm and .5cm);
    \end{scope}
  \end{tikzpicture}
\end{center}
\end{document}

答案1

也许使用装饰:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows.new, decorations.markings, calc, fadings,
decorations.pathreplacing, patterns, decorations.pathmorphing, positioning}
\newcommand{\AxisRotator}[1][rotate=0]{%
  \tikz[decoration={
    markings,
    mark=at position 1 with {\arrow{latex}}}]\draw[x = .5em, y = 2.75em, line width = .2ex,#1,postaction=decorate] (0,0)  arc (-150:150:.45 and .5) -- ++(-95:2pt);%                                                   
}

\begin{document}
\begin{center}
  \begin{tikzpicture}[scale = .75]
    \draw (-2,0) -- (-3,1.5);
    \draw (2,0) -- (3,1.5);
    \draw (-2,0) -- (2,0);
    \draw[-latex] (0,.75) -- (0,2);
    \draw (0,1.5) node {\AxisRotator[rotate = -90]};
    \begin{scope}[yshift = .25cm]
      \clip (-2.5,1) -- (2.5,1) -- (2.5,.25) -- (-2.5,.25) -- cycle;
      \draw (0,1) ellipse (2.75cm and .5cm);
    \end{scope}
  \end{tikzpicture}
\end{center}

\end{document}

在此处输入图片描述

为了进行比较,这里是问题中原始代码的结果:

在此处输入图片描述

以下是各个角度的结果:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows.new, decorations.markings, calc, fadings,
decorations.pathreplacing, patterns, decorations.pathmorphing, positioning}

\newcommand{\AxisRotator}[1][rotate=0] {%
  \tikz[decoration={
    markings,
    mark=at position 1 with {\arrow{latex}}}]\draw[x = .5em, y = 2.75em, line width = .2ex,#1,postaction=decorate] (0,0)  arc (-150:150:.45 and .5) -- ++(-95:2pt);%                                                   
  }

\begin{document}

\begin{tikzpicture}[scale = .75]
\foreach \angle[count=\xi] in {0,45,...,315}
  \draw (0,1.5) node at (0,1.5*\xi) {\AxisRotator[rotate = \angle]};
\end{tikzpicture}

\end{document}

在此处输入图片描述

我使用-- ++(-95:2pt)弧形路径的末端来稍微延长它以使箭头能够处于良好的位置。

答案2

arrows.meta库(TikZ 3.0,第 16 节)为绘制箭头引入了更多灵活性。此版本还提供了pics有助于避免tikzpictures在内部绘制的tikzpictures。下一个代码结合了这两个工具。

图片AxisRotator是根据椭圆的中心(通过反复试验确定)放置的。

\documentclass[tikz,border=2mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta, positioning}

\tikzset{
    pics/AxisRotator/.style={
    code={
        \draw [x=1em, y=1em, line width=.2ex, -{Latex[length=.5em, quick]},rotate=#1] (-.25,-.7) arc (-150:165:.3375 and 1.375);
    }},
    pics/AxisRotator/.default=0
}

\begin{document}
  \begin{tikzpicture}[scale = .75]
    \draw (-2,0) -- (-3,1.5);
    \draw (2,0) -- (3,1.5);
    \draw (-2,0) -- (2,0);
    \draw[-latex] (0,.75) -- (0,2);
    \draw (0,1.5) pic {AxisRotator=-90};
    \begin{scope}[yshift = .25cm]
      \clip (-2.5,1) -- (2.5,1) -- (2.5,.25) -- (-2.5,.25) -- cycle;
      \draw (0,1) ellipse (2.75cm and .5cm);
    \end{scope}
  \end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容