我想要绘制四条圆锥曲线(圆周,椭圆,抛物线和双曲线),如图所示:
梅威瑟:
\documentclass{article}
\usepackage{pst-plot}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[line cap=round,line join=round,x=1.0cm,y=1.0cm]
\clip(-2.48,-2.52) rectangle (2.68,5.44);
\draw [line width=1.pt] (0.,0.) ellipse (2.cm and 0.8cm);
\draw [line width=1.pt] (2.,0.)-- (0.,5.);
\draw [line width=1.pt] (0.,5.)-- (-2.,0.);
\draw [rotate around={25.:(-0.2,2.3)}] (-0.2,2.3) ellipse (1.15cm and 0.4cm);
\draw [line width=1.pt] (0.,3.4) ellipse (0.65cm and 0.2cm);
\draw [line width=1.pt] (1.4,1.4) parabola (1.6,-0.5);
\draw [line width=1.pt] (1.4,1.4) parabola (0.75,0.75);
\end{tikzpicture}
\end{document}
答案1
这是一个建议。该函数radius
取自这里,这也可能是您图片的来源。但是,最后两个图的上限,即像这样的值69.6
,是通过反复试验找到的。
\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{tikz-3dplot}
\usetikzlibrary{3d,backgrounds,intersections}
% small fix for canvas is xy plane at z % https://tex.stackexchange.com/a/48776/121799
\makeatletter
\tikzoption{canvas is xy plane at z}[]{%
\def\tikz@plane@origin{\pgfpointxyz{0}{0}{#1}}%
\def\tikz@plane@x{\pgfpointxyz{1}{0}{#1}}%
\def\tikz@plane@y{\pgfpointxyz{0}{1}{#1}}%
\tikz@canvas@is@plane}
\makeatother
\begin{document}
\tdplotsetmaincoords{70}{0}
\begin{tikzpicture}[declare function={radius(\x,\y,\z)=\z/(1+\y*cos(\x));
h(\x)=2.5*(2-\x);},scale=2,set scale/.code={\xdef\msc{#1}}]
\begin{scope}[tdplot_main_coords]
\begin{scope}[canvas is xy plane at z=0]
\path[fill=orange!30] (0,0) circle (2);
\coordinate (l) at (10:2);
\coordinate (r) at (170:2);
\draw[dashed,name path=back] (l) arc(10:170:2);
\draw[thick,name path=front] (r) arc(170:370:2);
\end{scope}
\begin{scope}[on background layer]
\draw[fill=orange!10] (l) -- (0,0,5) -- (r);
\end{scope}
\path[name path global=coat] (l) -- (0,0,5) -- (r);
\pgfmathsetmacro{\meps}{0}
%\pgfmathsetmacro{\msc}{0.75}
\path[fill=blue] plot[variable=\x,domain=-180:180,samples=72,set scale=0.75]
({radius(\x,\meps,\msc)*cos(\x)},
{radius(\x,\meps,\msc))*sin(\x)},{h(radius(\x,\meps,\msc))});
%\pgfmathsetmacro{\msc}{0.76}
\fill[blue!60] plot[variable=\x,domain=170:370,samples=72,set scale=0.76]
({radius(\x,\meps,\msc)*cos(\x)},
{radius(\x,\meps,\msc))*sin(\x)},{h(radius(\x,\meps,\msc))})
--
plot[variable=\x,domain=370:170,samples=72,set scale=0.75]
({radius(\x,\meps,\msc)*cos(\x)},
{radius(\x,\meps,\msc))*sin(\x)},{h(radius(\x,\meps,\msc))})
-- cycle ;
\pgfmathsetmacro{\meps}{0.15}
\path[fill=green!30!black] plot[variable=\x,domain=-180:180,samples=72,set
scale=1.25]
({radius(\x,\meps,\msc)*cos(\x)},
{radius(\x,\meps,\msc))*sin(\x)},{h(radius(\x,\meps,\msc))});
\fill[green!70!black] plot[variable=\x,domain=170:370,samples=72,set
scale=1.265] ({radius(\x,\meps,\msc)*cos(\x)},
{radius(\x,\meps,\msc))*sin(\x)},{h(radius(\x,\meps,\msc))})
-- plot[variable=\x,domain=370:170,samples=72,set
scale=1.25] ({radius(\x,\meps,\msc)*cos(\x)},
{radius(\x,\meps,\msc))*sin(\x)},{h(radius(\x,\meps,\msc))});
\pgfmathsetmacro{\meps}{1.5}
\path[fill=red!80!black] plot[variable=\x,domain=-70.6:70.6,samples=72,set
scale=3]
({radius(\x,\meps,\msc)*cos(\x)},
{radius(\x,\meps,\msc))*sin(\x)},{h(radius(\x,\meps,\msc))});
\path[fill=red!80] plot[variable=\x,domain=-70.6:10,samples=72,set
scale=3] ({radius(\x,\meps,\msc)*cos(\x)},
{radius(\x,\meps,\msc))*sin(\x)},{h(radius(\x,\meps,\msc))})
-- plot[variable=\x,domain=10:-69.6,samples=72,set
scale=3.05] ({radius(\x,\meps,\msc)*cos(\x)},
{radius(\x,\meps,\msc))*sin(\x)},{h(radius(\x,\meps,\msc))})
-- cycle;
\pgfmathsetmacro{\meps}{4}
\path[fill=orange!80!black] plot[variable=\x,domain=-51.4:51.4,samples=72,set
scale=7]
({radius(\x,\meps,\msc)*cos(\x)},
{radius(\x,\meps,\msc))*sin(\x)},{h(radius(\x,\meps,\msc))});
\path[fill=orange!60] plot[variable=\x,domain=-51.4:10,samples=72,set
scale=7]
({radius(\x,\meps,\msc)*cos(\x)},
{radius(\x,\meps,\msc))*sin(\x)},{h(radius(\x,\meps,\msc))})
-- plot[variable=\x,domain=10:-50,samples=72,set
scale=7.15]
({radius(\x,\meps,\msc)*cos(\x)},
{radius(\x,\meps,\msc))*sin(\x)},{h(radius(\x,\meps,\msc))}) -- cycle;
\end{scope}
\end{tikzpicture}
\end{document}