How to draw an ellipse, with the foci, center, and axes labeled?

How do I plot this modified GeoGebra picture using LaTeX code? • If you don't care too much about the quality of the code, export TikZ or PSTricks from GeoGebra. – Torbjørn T. Apr 19 '16 at 19:01
• Your question leaves all the effort to our community, even typing the essentials of a TeX document such as \documentclass{}...\begin{document} etc. Please always post a minimal working example (MWE). – Henri Menke Apr 19 '16 at 20:04

While the other solution looks great as well, the code is needlessly complicated. This code is very minimal and allows for easy customization by defining the relevant parameters as macros.

\documentclass[tikz]{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing}
\begin{document}
\begin{tikzpicture}[dot/.style={draw,fill,circle,inner sep=1pt}]
\def\a{4} % large half axis
\def\b{3} % small half axis
\def\angle{-45} % angle at which X is placed
% Draw the ellipse
\draw (0,0) ellipse ({\a} and {\b});
% Draw the inner lines and labels
\draw (-\a,0) coordinate[label={left:$A$}] (A)
-- (\a,0) coordinate[label={right:$B$}] (B);
\draw (0,-\b) coordinate[label={below:$D$}] (D)
-- (0,\b) coordinate[label={above:$C$}] (C);
\coordinate[label={below right:$S(p,q)$}] (O) at (0,0);
% Nodes at the focal points
\node[dot,label={below:$F_1$}] (F1) at ({-sqrt(\a*\a-\b*\b)},0) {};
\node[dot,label={below:$F_2$}] (F2) at ({+sqrt(\a*\a-\b*\b)},0) {};
% Node on the rim, connected to foci
\node[dot,label={\angle:$X$}] (X) at (\angle:{\a} and {\b}) {};
\draw (F1) -- (X) (X) -- (F2);
% Brace
\draw[decorate,decoration=brace,draw=red] (C) -- (O);
\end{tikzpicture}
\end{document} For example, we can easily create these nice animations (me, 2016)  \documentclass{standalone}

\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing}
\begin{document}

\begin{tikzpicture}[help lines/.style={blue!30,very thin},scale=0.6]
\draw [help lines] (-7, -6) grid (7, 6);
\draw[color=blue,very thick] (0, 0) ellipse (5cm and 4cm);

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

\foreach \x/\y in { -3/0, 3/0}
\filldraw[blue] (\x, \y) circle(2pt);

\draw[->] (-7, 0) -- (7, 0) node[below]{\footnotesize $x$};
\draw[->] (0, -5) -- (0, 5) node[right]{\footnotesize $y$};
\draw[-] (-3, 0) -- (4, -2.4);
\draw[-] (3, 0) -- (4, -2.4);
\draw [decorate,decoration={brace,amplitude=6pt},xshift=-0.2cm,yshift=0pt,red]
(0,0) -- (0,4);
\node at (.9,-0.6) {$S(p,q)$};
\node at (-5.6,-0.5) {$A$};
\node at (5.6,-0.5) {$B$};
\node at (-.3,4.4) {$C$};
\node at (-.5,-4.4) {$D$};
\node at (-3.3,0.6) {$F_1$};
\node at (3.3,0.6) {$F_2$};
\node at (5.2,-2.8) {$(x,y)$};
\end{tikzpicture}
\end{document} • I've added the red brace, but after \usetikzlibrary{decorations.pathreplacing} – Olga K Apr 19 '16 at 19:25
• Did you know, that you can specify points on an ellipse by polar coordinates as in (45:5 and 4). This way you do not have to compute the points by hand. – Henri Menke Apr 19 '16 at 19:54
• Thank you, I use polar or cartesian coordinates according my mood) Actually the example above is naive, I agee. – Olga K Apr 19 '16 at 20:04
• Strictly speaking, your red brace is on the wrong side of the y axis. You should flip it with the mirror optional argument, and then shift it slightly on the positive side by replacing xshift=-0.2 by xshift=0.1. See tex.stackexchange.com/a/20887/80509. – Matsmath May 5 '16 at 9:22
• Thank you, I see. Indeed such "wrong" brace is more suitable to keep balance of the picture. – Olga K May 5 '16 at 9:46

Here's a Metapost + luamplib solution, showing an MP function to find the focus points of an arbitrary ellipse. The ellipse is only rotated to show that it works with any ellipse...

\documentclass[border=5mm]{standalone}
\usepackage{luamplib}
\mplibtextextlabel{enable}
\begin{document}
\begin{mplibcode}
vardef focus(expr e, n) =
save a, b; numeric a,b;
a = arclength (point 0 of e .. center e);
b = arclength (point 2 of e .. center e);
((a+-+b)/a)[center e, point if n=1: 4 else: 0 fi of e]
enddef;

beginfig(1);
path E; E = fullcircle xscaled 8cm yscaled 5cm rotated 6;

draw point 0 of E -- point 4 of E withcolor .7 white;
draw point 2 of E -- point 6 of E withcolor .7 white;
draw E withcolor .67 blue;

z0 = point 6.812 of E;
z1 = focus(E,1);
z2 = focus(E,2);

draw z1 -- z0 -- z2 withcolor .53 red;

dotlabel.top("$f_1$", z1);
dotlabel.top("$f_2$", z2);
dotlabel.bot("$X$", z0);

label.lft("$A$", point 4 of E);
label.rt ("$B$", point 0 of E);
label.top("$C$", point 2 of E);
label.bot("$D$", point 6 of E);

endfig;
\end{mplibcode}
\end{document}

Notes

• On a fullcircle path there are 8 points starting at 3 o'clock.

• center returns the center point of the bounding box of any path.

• The function uses arclength to measure the semi-major axes of the ellipse, and then the Pythagorean minus operator +-+ to work out the length from the center to the focus.

A PSTricks solution:

\documentclass{article}

\psset{dimen = m}
\usepackage{xfp}

% parameters
\def\pointX{1.5} % |\pointX| < |\radiiA|
\def\braceSize{4pt}
\def\braceColor{red}
% shortened code
\ifdim \pointX pt < 0pt
\newcommand*\vinkel{\fpeval{round(atan(\pointY/\pointX)*180/pi+180)}}
\else
\newcommand*\vinkel{\fpeval{round(atan(\pointY/\pointX)*180/pi)}}
\fi

\begin{document}

% picture
\begin{pspicture}%
\pnodes(\pointX,\pointY){P}
{\psset{linewidth = 0.5\pslinewidth}
\uput(\radiiA,0){$B$}
\uput(0,\radiiB){$C$}
\uput(-\radiiA,0){$A$}
\uput(0,-\radiiB){$D$}
\uput(0,0){$S(p,q)$}
\psdot(\focal,0)
\uput(\focal,0){$F_{1}$}
\psdot(-\focal,0)
\uput(-\focal,0){$F_{2}$}
\psdot(P)
\uput[\vinkel](P){$X$}
\psline(\focal,0)(P)(-\focal,0)
\psbrace[
braceWidth = 1pt,
braceWidthInner = \braceSize,
braceWidthOuter = \braceSize,
fillstyle = solid,
fillcolor = \braceColor,
linecolor = \braceColor 