# Drawing a Conic Section (Ellipse)

TeX - LaTeX Asked by Guilherme Vargas on December 19, 2020

I’m looking for a simple way to draw (ideally using TikZ) a cone with a plane through it to show my students where the ellipse comes from. It’s my very first year as a high school teacher and since teaching from home is the norm this year, I want to make nice images to use in the materials, rather than just writing equations and telling them where these things come from.

Draw the four conic sections

To try to better understand and ellaborate an approach, but I’m stuck at the very begining. I’m finding that not only I can’t create the image, I’m not understanding the answers on those posts.

I’m using the beamer class, but in the future I’ll want to be able to use these drawings on worksheets, too. I have also consulted other websites, which seemed to suggest using the pst-solides3d package, but I also read I can’t use it on pdflatex

Here’s the code I have so far (made a rough-looking cone, and decided the points where the ellipse will appear on it).

usepackage{pgfplots}
%pgfplotsset{compat=1.3}
pgfkeys{/pgf/number format/.cd,use comma}
usepgfplotslibrary{fillbetween,statistics}
usepackage{tikz,tikz-3dplot} %Para fazer desenhos


That’s in my preamble. Now in a frame in beamer, I have:

begin{tikzpicture}

%The Cone
draw [dashed] (-1,0) arc (170:10:1.01 and 0.4) -- (1,0);
draw (-1,0) -- (0,3) -- (1,0) arc(-10:-170:1.01 and 0.4) --cycle;

%The Ellipse's starting and end points
path (-1,0) -- (0,3) coordinate [near end] (A);
path (0,3) -- (1,0) coordinate [midway] (B);
end{tikzpicture}


And here’s an image of what I’m trying to do. It does not need to have colors (just the "wireframe" is decent enough to me, although I’d appreciate to add color just to the ellipse, for the sake of making it clear).

Is there a simpler way to achieve the desired result? If possible, please explain the procedures so I’m not just copying and pasting but learning, too 🙂

This is not an answer to your question, but I want to advice it is time consuming to draw nice images using TikZ, however there is a nice software for this purpose and it is GeoGebra. It can draw more, nice and complicated and animated pictures just by a few clicks.

Anyway, If you want to draw using TiKz, the common trick is that, first you should do some calculus for intersection ellipse equation (if it is not matter, choose arbitrary ellipse) and draw the shapes in three steps:

1. First the below part of the cone then
2. draw the plane with opacity=0.5 and
3. finally draw above part of the cone.

for circle section it is easy to draw, but in other cases it is complicated.

Simple Example:

documentclass[border=10pt]{standalone}
usepackage{pgfplots}
pgfplotsset{width=7cm,compat=1.8}
begin{document}
begin{tikzpicture}
begin{axis}[view={20}{40},hide axis, domain=0:1,
y domain=-1:1, xmin=-1.5, xmax=1.5,
ymin=-1.5, ymax=1.5, zmin=0.0]%

mesh/interior colormap=
{blueblack}{color=(black) color=(blue)},
colormap/blackwhite,
samples=20,
samples y=40,
z buffer=sort,]
({x*cos(deg((y+1)*pi))},{x*sin(deg((y+1)*pi))},{x});

addplot3 [surf,domain=-.5:1.2, domain y=-1.5:1,samples=2, samples y=2,opacity=0.5]({x},{y},{.85});

mesh/interior colormap=
{blueblack}{color=(black) color=(blue)},
colormap/blackwhite,
samples=20,
samples y=40,
z buffer=sort,]
({x*cos(deg((y+1)*pi))},{x*sin(deg((y+1)*pi))},{x});
%
end{axis}
end{tikzpicture}
end{document}


Output:

Correct answer by user108724 on December 19, 2020