In this tutorial, We will show how to draw a plane intersecting a cone in \LaTeX using TikZ package. The intersection corresponds to an ellipse, which is a well known problem in geometry. We will use directly equations that defines the ellipse.

To draw our illustration, we have to simplify it to small tasks:

- We need axis environment (we need to upload
*pgfplots*package); - we need to draw the bottom cone first (
*\addplot3*); - then we draw the plane (
*\addplot3*) and the ellipse that highlight the intersection (*\draw*with*plot*). - The last thing is the remaining part of the cone (
*\addplot3*).

## 1. Set up tikzpicture environment

\documentclass{standalone} \usepackage{tikz} \usepackage{pgfplots} \usepgfplotslibrary{colormaps} \pgfplotsset{compat = newest} \begin{document} \begin{tikzpicture} \begin{axis}[ axis equal image, grid = both, minor tick num = 2, xlabel = {$x$}, ylabel = {$y$}, zlabel = {$z$}, major grid style = {draw = lightgray}, minor grid style = {draw = lightgray!25}, legend cell align={left}, xmin = -1, xmax = 1, ymin = -1, ymax = 1, scale = 3, zmin = 0, zmax = 2, z buffer = sort, ] % here comes the code \end{axis} \end{tikzpicture} \end{document}

In the options of the *axis *environment we have added the following options:

**axis equal image:**This options keeps an equal aspect ratio of the axis.**grid = both:**Plots the major and minor grid.**grid style:**Helps to change the default style of the grids like colours or stroke.**label:**Adds a name to the axis.**legend cell align**: Aligns the legend to the left, right or centre, we are going to see how it works at the end of the document.**scale:**Enlarges or stretches the graphics according with the parameter passed.**z buffer = sort**: Specify the way the*pgfplots*computes and orders the plots.

It is also important to set the limits of the graphic by the *min * and *max* commands. Specify the limits according to the range of the elements you will plot. Next step is to draw the bottom of the cone.

## 2. Draw a truncated cone in \LaTeX

As we mentioned before, we are not going to explain or deduce where the parametric equation of the bottom of the cone comes from, instead we limit us to show what the equation is and show how to plot it. In fact, the parametric equation of the bottom cone is given by the parametric equation:

\addplot3[ surf, shader = interp, samples = 50, samples y = 20, domain = 0:2*pi, domain y = 0:1, colormap/violet, ] ( {cos(deg(x)) + ((sin(60) / (2*sin(60)-cos(60)*cos(deg(x))))*cos(deg(x))-cos(deg(x)))*y}, {sin(deg(x)) + ((sin(60) / (2*sin(60)-cos(60)*cos(deg(x))))*sin(deg(x))-sin(deg(x)))*y}, {0 + (-2*(sin(60) / (2*sin(60)-cos(60)*cos(deg(x))))+2-0)*y} );

We have used the *\addplot3* command to plot the parametric surface. Here are the description of the used options in this command:

**surf**: Specifies that the plot is a surface.**shader**: It’s the interpretation of the compiler, you can use**inter**for a smooth surface or**flat**for a rough one.**samples**: Defines the number of subdivisions for the surface.**domain**: Defines the domain of the parameter t and s, which are represented by*x*and*y*, respectively in the code above.**colormap**: With this command you can change the gradient colour of the surfaces.

## 3. Draw a plane in 3D coordinates using \LaTeX

z = -\cfrac{\cos({60}{\degree})}{\sin({60}{\degree})}\cdot x + 1

*\addplot3*command by providing the plane equation as follows:

\addplot3[ surf, shader = interp, opacity = 0.65, domain = -0.65:0.9, domain y = -1:1, colormap/redyellow ] {-cos(60)/sin(60)*x+1};

## 4. Draw an ellipse defined by a parametric equation in \LaTeX

*\draw*to plot a parametric equation. Indeed, the intersection of a plane and a cone is an ellipse that can be described by a parametric curve, which is given by:

\draw[ samples = 50, smooth, domain = 0:2*pi, variable = \t, dashed, ultra thick ] plot ( {(sin(60) / (2*sin(60) - cos(60)*cos(deg(\t))))*cos(deg(\t))}, {(sin(60) / (2*sin(60) - cos(60)*cos(deg(\t))))*sin(deg(\t))}, {-2*(sin(60) / (2*sin(60) - cos(60)*cos(deg(\t))))+2} );

## 5. Draw the rest of the cone in \LaTeX

\legend{Bottom of the cone, Plane, Top of the cone},This will add a box with the description of the surfaces at the top right of the graph. The obtained illustration is shown below. Remember that the order of plotting is important since TikZ doesn’t have auto sorting algorithms.

## Leave a Reply