使用 \pgfpatharctoprecomputed 构造弧

使用 \pgfpatharctoprecomputed 构造弧

我无法使用 \pgfpatharctoprecomputed 从明确定义的椭圆生成圆弧。我的代码是:

\documentclass[tikz,convert={outfile=\jobname.svg}]{standalone}
\usepackage{tikz}
\usepackage{graphicx}% http://ctan.org/pkg/graphicx
\usepackage{pst-3dplot}% http://ctan.org/pkg/pst-3dplot
\usepackage{tikz-3dplot}
\usepackage{xcolor}% http://ctan.org/pkg/xcolor
\begin{document}

\begin{tikzpicture}
\draw[help lines] (-25,-25) grid (25,25);  
\pgfsetlinewidth{3pt}

\node (image) at (0,0) {\includegraphics{Chloromethane.png}};

\pgfpathellipse{\pgfpoint{-10.0cm}{-2.0cm}}
{\pgfpoint{-3.5cm}{10.5cm}}
{\pgfpoint{-6.5cm}{2.0cm}}
\pgfusepath{draw}

\pgfpathmoveto{\pgfpoint{-16.2cm}{-0.8cm}}
\pgfpatharcto{6.8007cm}{11.068cm}{0}{0}{0}{\pgfpoint{-16.7cm}{7.6cm}}
\pgfusepath{draw}

%\pgfpathmoveto{\pgfpoint{-2.75cm}{-10.0cm}}
%\pgfpatharcto{6.8007cm}{11.068cm}{17.1}{0}{0}{\pgfpoint{-12.1cm}{7.9cm}}
%\pgfusepath{draw}

\pgfpathmoveto{\pgfpoint{-2.75cm}{-10.0cm}}
\pgfpatharctoprecomputed{\pgfpoint{-10.0cm}{-2.0cm}}{-47.8156}{101.976} {\pgfpoint{-12.1cm}{7.9cm}}{6.801cm}{11.068cm}{0.61447}{1.6274}
\pgfusepath{draw}

%\pgfpathmoveto{\pgfpoint{11cm}{0.5cm}}
%\pgfpatharcto{11cm}{9cm}{0}{0}{0}{\pgfpoint{-3.5cm}{-7.5cm}}
%\pgfusepath{draw} 

\pgfpathellipse{\pgfpoint{-2.5cm}{1.5cm}}
{\pgfpoint{17.5cm}{9.5cm}}
{\pgfpoint{-8.0cm}{11.0cm}}
\pgfusepath{draw}

%\pgfpathellipse{\pgfpoint{0.0cm}{1cm}}
%{\pgfpoint{-10.7cm}{1.5cm}}
%{\pgfpoint{0.75cm}{7.1cm}}
%\pgfusepath{draw}

\pgfpathellipse{\pgfpoint{-2.5cm}{1.5cm}}
{\pgfpoint{17.4cm}{9.4cm}}
{\pgfpoint{0.0cm}{4.0cm}}
\pgfusepath{draw}


\end{tikzpicture}

\end{document}

但是,使用上述代码时,圆弧无法正确形成:

enter image description here

尤其是 \pgfpatharctoprecomputed。是否有其他代码可用于从明确定义的椭圆重现圆弧?

答案1

初始点不在定义的椭圆上,这就是起点和终点摆动的原因。目测一下会得到不错的结果,但我认为你的 y 半径也有问题。

请注意,如果您事先进行计算,此命令特别有用。对于目测,这不是很有用。看我画的红色椭圆。

\begin{tikzpicture}
\draw[help lines] (-25,-25) grid (25,25);  
\pgfsetlinewidth{3pt}

\draw[red,line width=3mm] (-10,-3) ellipse (6.801 and 11.068);
\pgfpathmoveto{\pgfpoint{-4.75cm}{-10.0cm}}
\pgfpatharctoprecomputed{\pgfpoint{-10.0cm}{-3.0cm}}{-47.8156}{101.976} {\pgfpoint{-12.1cm}{7.55cm}}{6.801cm}{11.068cm}{0.61447}{1.6274}
\pgfusepath{draw}

\end{tikzpicture}

enter image description here

答案2

我能够使用替代命令“\pgfpatharcto”实现所需的输出。为了生成圆弧,我必须定义椭圆相对于垂直方向倾斜的角度。

\documentclass[tikz,convert={outfile=\jobname.svg}]{standalone}
\usepackage{tikz}
\usepackage{graphicx}% http://ctan.org/pkg/graphicx
\usepackage{pst-3dplot}% http://ctan.org/pkg/pst-3dplot
\usepackage{tikz-3dplot}
\usepackage{xcolor}% http://ctan.org/pkg/xcolor
\begin{document}

\begin{tikzpicture}
\draw[help lines] (-25,-25) grid (25,25);
\pgfsetlinewidth{3pt}

%\node (image) at (0,0) {\includegraphics{Chloromethane.png}};

%\pgfpathellipse{\pgfpoint{-10.0cm}{-2.0cm}}
%{\pgfpoint{-5.7cm}{10.5cm}}
%{\pgfpoint{-4.5cm}{-2.5cm}}
%\pgfusepath{draw}

\pgfpathmoveto{\pgfpoint{-16.2cm}{-0.8cm}}  
\pgfpatharcto{5.148cm}{11.947cm}{28.496}{0}{0}{\pgfpoint{-16.7cm}{7.6cm}}
\pgfusepath{draw}

%\pgfpathmoveto{\pgfpoint{-2.75cm}{-10.0cm}}
%\pgfpatharctoprecomputed{\pgfpoint{-10.0cm}{-2.0cm}}{-47.8156}{101.976} {\pgfpoint{-12.1cm}{7.9cm}}{5.148cm}{11.947cm}{0.4309}{2.3207}
%\pgfusepath{draw}

\pgfpathmoveto{\pgfpoint{-12.1cm}{7.9cm}}
\pgfpatharcto{5.148cm}{11.947cm}{28.496}{0}{0}{\pgfpoint{-2.75cm}{-10.0cm}}
\pgfusepath{draw}

\draw [fill] (-15.7,8.5) circle [radius=0.1];
\draw [fill] (-14.5,-4.5) circle [radius=0.1];

\draw [fill] (-12.1,7.9) circle [radius=0.1];
\draw [fill] (-2.75,-10.0) circle [radius=0.1];

\end{tikzpicture}

\end{document}

附加的 PNG 文件中还标记了一些定义弧线所需的点。还显示了原始问题中同一椭圆的第二个弧线。enter image description here

相关内容