How to draw a plane intersecting a cone in LaTeX?

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.

3D intersection plane and cone tikz

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

As we have discussed above, we need to load the tikz and pgfplots packages. Here we also use the colormaps library from the pgfplots package which allows us to change the gradient colour of the surfaces. The initial code looks as follows:
\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}
axis environment tikz

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:

\begin{aligned}x & = \cos(t) + (m\cdot \cos(t) – \cos(t))\cdot s\\ y & = \sin(t) + (m\cdot \sin(t) – \sin(t))\cdot s\\ z & = (-2\cdot m + 2)\cdot s \end{aligned}
draw truncated cone latex tikz
Where m = \sin({60}{\degree})/(2\cdot \sin({60}{\degree}) – \cos({60}{\degree})\cdot \cos(t)). The parameter t takes values from [0:2\pi] and the parameter s from [0:1].
\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

Once we have plotted the bottom of the cone, we can now plot the plane. we just need to do something very similar but with another equation. The equation of the plane is given by the explicit equation:

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

To plot the plane, we can use again the \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};
Draw plane in Latex tikz

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

To highlight the intersection area between the plane and the cone, we can add the plot of the ellipse. We can use the command \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:
\begin{aligned} x & = m\cdot \cos(t)\\ y & = m\cdot \sin(t)\\ z & = -2\cdot m + 2 \end{aligned}
draw ellipse tikz latex
Check the code below to figure out how to use the \verb|\draw| command and its options.
\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

Finally we have to add to the graph the top of the cone by plotting its parametric equation given by:
\begin{aligned} x & = (m\cdot \cos(t) – \cos(t))\cdot s\\ y & = (m\cdot \sin(t) – \sin(t))\cdot s\\ z & = 2+(-2\cdot m)\cdot s \end{aligned}
Now we have plotted three surfaces and a parametric curve. Finally, it remains to add the legend using the following command:
\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.
legend tikz latex
3D intersection of a plane and a cone drawn in LaTeX.

Leave a Reply

Close Menu