我正在尝试绘制两个椭圆的交点,但它们似乎偏离了。
我的代码:
\documentclass [10pt] {article}
\usepackage{pgfplots}
\usepackage{tikz}
\usetikzlibrary{patterns}
\begin{document}
\begin{tikzpicture}
\begin{scope}
\clip (0,0) ellipse (1cm and 3cm);
\fill [blue,pattern=north east lines] (0,0) ellipse (3cm and 1cm);
\end{scope}
\draw[red] (0,0) ellipse (3cm and 1cm);
\draw[blue] (0,0) ellipse (1cm and 3cm);
\draw[step=1cm,gray,very thin,dashed,] (-2.9,-2.9) grid (2.9,2.9);
\draw[<->,thick] (-3.2,0) -- (3.2,0);
\draw[<->,thick] (0,-3.2) -- (0,3.2);
\draw (0.866,0.866) circle (0.5ex)[fill=black]node[anchor=south west, black]{$(\frac{\sqrt{3}}{2},\frac{\sqrt{3}}{2})$};
\end{tikzpicture}
\end{document}
以下是该问题的图片:
为了确保我没有发疯,我检查了WolframAlpha。
我怎样才能准确地绘制我需要的点?
答案1
你应该再检查一下你的数学。我不知道你真正想要什么,但这里有一个正确的解决方案,它与你在 WolframAlpha 上使用的公式相匹配。
\documentclass[10pt]{article}
\usepackage{pgfplots}
\usepackage{tikz}
\usetikzlibrary{patterns}
\begin{document}
\begin{tikzpicture}
\begin{scope}
\clip (0,0) ellipse (1 and 1.732050808);
\fill [blue,pattern=north east lines] (0,0) ellipse (1.732050808 and 1);
\end{scope}
\draw[red] (0,0) ellipse (1.732050808 and 1);
\draw[blue] (0,0) ellipse (1 and 1.732050808);
\draw[step=1,gray,very thin,dashed,] (-2.9,-2.9) grid (2.9,2.9);
\draw[<->,thick] (-3.2,0) -- (3.2,0);
\draw[<->,thick] (0,-3.2) -- (0,3.2);
\draw (0.866,0.866) circle (0.5ex)[fill=black]node[anchor=south west, black]{$\left(\frac{\sqrt{3}}{2},\frac{\sqrt{3}}{2}\right)$};
\end{tikzpicture}
\end{document}
输出:
答案2
您可以使用intersections
库tikz
来获取真实的交点。我建议您仔细检查数学运算以确保计算出的坐标准确无误。
\documentclass [10pt] {article}
\usepackage{tikz}
\usetikzlibrary{patterns,intersections}
\begin{document}
\begin{tikzpicture}[x=1cm,y=1cm]
\pgfmathsetmacro{\intp}{sqrt(3)/2.0};
\begin{scope}
\clip (0,0) ellipse (1cm and 3cm);
\fill [blue,pattern=north east lines] (0,0) ellipse (3cm and 1cm);
\end{scope}
\path[draw,red,name path=p1] (0,0) ellipse (3cm and 1cm);
\path[draw,blue,name path=p2] (0,0) ellipse (1cm and 3cm);
\draw[step=1cm,gray,very thin,dashed,] (-2.9,-2.9) grid (2.9,2.9);
\draw[<->,thick] (-3.2,0) -- (3.2,0);
\draw[<->,thick] (0,-3.2) -- (0,3.2);
\path [name intersections={of=p1 and p2}];
\draw (intersection-1) circle (0.5ex)[fill=black]node[anchor=south west, black]{$(\frac{\sqrt{3}}{2},\frac{\sqrt{3}}{2})$};
\end{tikzpicture}
\end{document}