Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm trying to draw an ellipse that must pass through (0, -1), (0, 1), (-1, 0), (1, 0), (1, -1) and (-1, 1). My MWE is below. I know that, I'm missing some math here.

enter image description here

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}

\begin{document}

\begin{tikzpicture}

\draw [help lines] (-2, -2) grid (2, 2);
\draw[rotate=45] (0, 0) ellipse (0.5cm and 1.5cm);

\filldraw[black] (0, 0) circle(1.5pt);
\filldraw[black] (0, 1) circle(1.5pt);
\filldraw[black] (1, 0) circle(1.5pt);
\filldraw[black] (-1, 0) circle(1.5pt);
\filldraw[black] (0, -1) circle(1.5pt);
\filldraw[black] (1, -1) circle(1.5pt);
\filldraw[black] (-1, 1) circle(1.5pt);

\draw[<->] (-2.0, 0) -- (2.0, 0) node[right]{\footnotesize $X_{1}$};
\draw[<->] (0, -1.5) -- (0, 1.5) node[above]{\footnotesize $X_{2}$};

\node[above right] at (0, 1)   {\tiny $\left(0, 1\right)$}; 
\node[above right] at (1, 0)   {\tiny $\left(1, 0\right)$}; 
\node[above left]   at (-1, 0)  {\tiny $\left(-1, 0\right)$}; 
\node[below right] at (0, -1)  {\tiny $\left(0, -1\right)$}; 
\node[below right] at (1, -1)  {\tiny $\left(1, -1\right)$}; 
\node[above left]   at (-1,  1)  {\tiny $\left(-1, 1\right)$}; 

\end{tikzpicture}

\end{document}

Edit

The equation of the ellipse is $X_1^2 + X_1 X_2 + X_2^2 = 1$.

share|improve this question

1 Answer 1

up vote 5 down vote accepted

Output

enter image description here

You can manually perform the computations as suggested by JoeDub. You can then change

\draw[rotate=45] (0, 0) ellipse (0.5cm and 1.5cm);

into

\draw[rotate=45] (0, 0) ellipse (0.82cm and 1.4cm);

Code

%http://tex.stackexchange.com/questions/99714/drawing-ellipse-that-passes-through-specified-coordinates#99714
\documentclass[border=5,convert={density=150}]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}

\begin{document}

\begin{tikzpicture}

\draw [help lines] (-2, -2) grid (2, 2);
\draw[rotate=45,color=blue,very thick] (0, 0) ellipse (0.82cm and 1.4cm);

\foreach \x/\y in {0/0, 0/1, 1/0, -1/0, 0/-1, 1/-1, -1/1}
\filldraw[black] (\x, \y) circle(1.5pt);

\draw[<->] (-2.0, 0) -- (2.0, 0) node[right]{\footnotesize $X_{1}$};
\draw[<->] (0, -1.5) -- (0, 1.5) node[above]{\footnotesize $X_{2}$};

\foreach \x/\y/\direction in {0/1/above right, 1/0/above right, -1/0/above left, 0/-1/below left, 1/-1/below right, -1/1/above left}
\node [\direction] at (\x,\y) {\tiny $\left(\x, \y\right)$}; 
\end{tikzpicture}

\end{document}

You can also do this without rotation by specifying your major axis and minor axis (first axis and second axis in the manual) through the use of the \pgfpathellipse command. Here it is with your MWE.

\documentclass[border=5,convert={density=150}]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}

\begin{document}

\begin{tikzpicture}

\draw [help lines] (-2, -2) grid (2, 2);
\pgfpathellipse{\pgfpointorigin}{\pgfpointxy{1}{-1}}{\pgfpointxy{0.58}{0.58}} % Create an ellipse with one end of major axis passing through (1,-1) and with one end of minor axis at (0.58,0.58)
\pgfusepath{stroke}

\foreach \x/\y in {0/0, 0/1, 1/0, -1/0, 0/-1, 1/-1, -1/1}
\filldraw[black] (\x, \y) circle(1.5pt);

\draw[<->] (-2.0, 0) -- (2.0, 0) node[right]{\footnotesize $X_{1}$};
\draw[<->] (0, -1.5) -- (0, 1.5) node[above]{\footnotesize $X_{2}$};

\foreach \x/\y/\direction in {0/1/above right, 1/0/above right, -1/0/above left, 0/-1/below left, 1/-1/below right, -1/1/above left}
\node [\direction] at (\x,\y) {\tiny $\left(\x, \y\right)$}; 
\end{tikzpicture}

\end{document}

Note here that the length of the semi-minor axis is approximately the square root of 0.58^2 + 0.58^2.

Edit

I have used \foreach in the above codes to make them shorter.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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