1

I'm trying to plot the intersection points of two ellipses, but they appear to be off.

My code:

\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}

And a picture of the issue:

Plot points misplaced

And just to make sure I wasn't going crazy, I checked the intersection points on WolframAlpha.

How can I accurately plot the points I need?

1

You should check your math again. I don't know what you really want, but here is one correct solution, which matches the formulas you used on 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}

Output:

ellipse

  • Ah right, the ellipses aren't 3 long, they're √3 long. My mistake, thank you. – Emilio Garcia Feb 28 '16 at 0:20
1

You can use the intersections library of tikz to get the real intersection point. I recommend you double-check the math to ensure the calculated coordinates are accurate.

\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}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.