是否可以不使用角度而是使用两个位置来绘制圆弧?
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\pgfmathsetmacro{\a}{2.5}
\pgfmathsetmacro{\b}{2}
\pgfmathsetmacro{\c}{sqrt(\a^2 - \b^2)}
\draw (0, 0) ellipse (\a cm and \b cm);
\filldraw[black] (\c, 0) circle (.05cm) node[right = 2pt, scale = .75]
{\(F\)};
\begin{scope}[decoration = {markings,
mark = at position 0.5 with {\node[circle, inner sep = .01cm,
fill = white, scale = .75] {\(\mathbf{r}_1\)};},
}]
\draw[postaction = decorate]
(\c , 0) -- ({\a * cos(90)}, {\b * sin(90)});
\end{scope}
\begin{scope}[decoration = {markings,
mark = at position 0.5 with {\node[circle, inner sep = .01cm,
fill = white, scale = .75] {\(\mathbf{r}_2\)};},
}]
\draw[postaction = decorate]
(\c , 0) -- ({\a * cos(60)}, {-\b * sin(60)});
\end{scope}
\begin{scope}[decoration = {markings,
mark = at position 0.5 with {\node[circle, inner sep = .01cm,
fill = white, scale = .75] {\(2a - r_1\)};},
}]
\draw[postaction = decorate]
(-\c , 0) -- ({\a * cos(90)}, {\b * sin(90)});
\end{scope}
\begin{scope}[decoration = {markings,
mark = at position 0.5 with {\node[circle, inner sep = .01cm,
fill = white, scale = .75] {\(2a - r_2\)};},
}]
\draw[postaction = decorate]
(-\c , 0) -- ({\a * cos(60)}, {-\b * sin(60)});
\end{scope}
\filldraw[draw = black, fill = white] (-\c, 0) circle (.05cm)
node[left = 2pt, scale = .75]
{\(F^*\)};
\filldraw[black] ({\a * cos(60)}, {-\b * sin(60)})
node[below = 2pt, scale = .75] {\(P_2\)};
\filldraw[black] ({\a * cos(90)}, {\b * sin(90)})
node[above = 2pt, scale = .75] {\(P_1\)};
\end{tikzpicture}}
\end{document}
我想从 到 画一条弧线,({\a * cos(60) / 4}, {-\b * sin(60) / 4})
而不({\a * cos(90) / 4}, {\b * sin(90) / 4})
需要计算角度(这很简单,但我想让乳胶来完成这项工作)。
这该怎么做?如果做不到,那我就自己算一下,自己完成。
答案1
您可以使用以下方法之一使用 tikz 标签角度。这里,我将 Shiyu 的答案包装成一个宏,该宏以中心点和射线上的两个点为参数,绘制圆弧。它还接受一个可选参数,可用于设置选项draw
。
\def\angleRadius{0.5cm}
\newcommand{\markangle}[4][]{
\draw[#1] let \p1=#2, \p2=#3, \p3=#4,
\n1={atan2(\x2-\x1,\y2-\y1)}, \n2={atan2(\x3-\x1,\y3-\y1)} in
($(\p1)!\angleRadius!(\p3)$) arc [start angle=\n2-360, end angle=\n1, radius=\angleRadius];
}
我稍微简化了你的代码,你不需要所有这些scope
和markings
装饰,只需将节点放在线上:
\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\def\angleRadius{0.5cm}
\newcommand{\markangle}[4][]{
\draw[#1] let \p1=#2, \p2=#3, \p3=#4,
\n1={atan2(\x2-\x1,\y2-\y1)}, \n2={atan2(\x3-\x1,\y3-\y1)} in
($(\p1)!\angleRadius!(\p3)$) arc [start angle=\n2-360, end angle=\n1, radius=\angleRadius];
}
\begin{document}
\begin{tikzpicture}[
radius=0.05cm
]
\pgfmathsetmacro{\a}{2.5}
\pgfmathsetmacro{\b}{2}
\pgfmathsetmacro{\c}{sqrt(\a^2 - \b^2)}
\draw (0, 0) ellipse [x radius=\a cm, y radius=\b cm];
\filldraw[black] (\c, 0) circle node[right = 2pt, scale = .75]
{$F$};
\draw (\c,0) -- ({\a * cos(90)}, {\b * sin(90)})
node [pos=0.5, fill=white, font=\small, inner sep=2pt] {$\mathbf{r}_1$};
\draw (\c , 0) -- ({\a * cos(60)}, {-\b * sin(60)})
node [pos=0.5, fill=white, font=\small, inner sep=2pt] {$\mathbf{r}_2$};;
\draw (-\c , 0) -- ({\a * cos(90)}, {\b * sin(90)})
node [pos=0.5, fill=white, font=\small, inner sep=2pt] {$2a - r_1$};;
\draw (-\c , 0) -- ({\a * cos(60)}, {-\b * sin(60)})
node [pos=0.5, fill=white, font=\small, inner sep=2pt] {$2a - r_2$};;
\filldraw[draw = black, fill = white] (-\c, 0) circle
node[left, font=\small] {\(F^*\)};
\node at ({\a * cos(60)}, {-\b * sin(60)}) [below = 2pt, scale = .75] {\(P_2\)};
\node at ({\a * cos(90)}, {\b * sin(90)}) [above = 2pt, scale = .75] {\(P_1\)};
\markangle[thick, red]{(\c, 0)}{({\a * cos(60)}, {-\b * sin(60)})}{({\a * cos(90)}, {\b * sin(90)})}
\end{tikzpicture}
\end{document}