当我绘制圆弧时,我通过命令获取coordinate
圆弧末端的点(mypoint
在下面的代码中)以便进一步绘制,但它与预期点不对应。
看图:绿色的圆圈应该位于红色的弧(我放置的位置手动A蓝色的我按照代码的预期,在图中绘制了一个圆圈(如图所示),但它的位置离我有几毫米远。
我怎样才能获得弧末端的“正确”点以便进一步绘制?
这是我的代码:
\documentclass[tikz, border=0.3cm]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[scale=1.5]
\newcommand{\xradius}{0.22}
\newcommand{\yradius}{0.17}
%Ellipses centre
\newcommand{\xcent}{2}
\newcommand{\ycent}{2}
\newcommand{\myrotation}{20} %Ellipse rotation angle
\newcommand{\myangle}{30} %Angle before axis
\coordinate (center) at (\xcent, \ycent);
\draw (center) circle [x radius=\xradius, y radius=\yradius, rotate=\myrotation]; %Drawing black ellipse
\path (center) ++({-90+\myrotation}:\yradius) coordinate (startpoint); %Starting point of red arc
\draw [color=red] (startpoint) arc [x radius=\xradius, y radius=\yradius, start angle={-90}, delta angle={90-\myangle/2},
rotate=\myrotation] coordinate (mypoint); %Drawing red arc and getting the end point
\path [fill=green, radius=0.02] (mypoint) circle; %Drawing green circle
\draw [help lines] (center) -- +(\myrotation:{4*\xradius}); %Gray reference axis
\end{tikzpicture}
\end{document}
哦,是的,提前谢谢您的回答。
答案1
以下建议适用于当前 pgf 版本 (3.0.1a) 和旧版本 2.10。
用作rotate=\myrotation
整个路径的选项:
\documentclass[tikz, border=0.3cm]{standalone}
\begin{document}
\begin{tikzpicture}[scale=1.5]
\newcommand{\xradius}{0.22}
\newcommand{\yradius}{0.17}
%Ellipses centre
\newcommand{\xcent}{2}
\newcommand{\ycent}{2}
\newcommand{\myrotation}{20} %Ellipse rotation angle
\newcommand{\myangle}{30} %Angle before axis
\coordinate (center) at (\xcent, \ycent);
\draw[rotate=\myrotation] (center) circle [x radius=\xradius, y radius=\yradius];
\path[rotate=\myrotation] (center) ++(-90:\yradius) coordinate (startpoint);
\draw [color=red,rotate=\myrotation] (startpoint)
arc [x radius=\xradius, y radius=\yradius, start angle={-90}, delta angle={90-\myangle/2}]
coordinate (mypoint);
\path [fill=green, radius=0.02] (mypoint) circle;
\draw [help lines] (center) -- +(\myrotation:{4*\xradius});
\end{tikzpicture}
\end{document}
或者使用范围进行旋转:
\documentclass[tikz, border=2pt]{standalone}
\begin{document}
\begin{tikzpicture}[scale=1.5]
\newcommand{\xradius}{0.22}
\newcommand{\yradius}{0.17}
%Ellipses centre
\newcommand{\xcent}{2}
\newcommand{\ycent}{2}
\newcommand{\myrotation}{20} %Ellipse rotation angle
\newcommand{\myangle}{30} %Angle before axis
\coordinate (center) at (\xcent, \ycent);
\begin{scope}[rotate=\myrotation]
\draw (center) circle [x radius=\xradius, y radius=\yradius];
\path (center) ++(-90:\yradius) coordinate (startpoint);
\draw [color=red] (startpoint)
arc [x radius=\xradius, y radius=\yradius, start angle={-90}, delta angle={90-\myangle/2}]
coordinate (mypoint);
\draw [help lines] (center) -- +({4*\xradius},0);
\end{scope}
\path [fill=green, radius=0.02] (mypoint) circle;
\end{tikzpicture}
\end{document}