我试图重现下面的双圆锥体与平面相交的图片,但是在以适当的不透明度级别绘制圆锥体时却失败了。
这是我取得的进展:
\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}[thick]
\draw[->] (-3,0)--(3,0); \node[below] at (3,0) {$x_2$};
\draw[->] (0,-1)--(0,2.5); \node[right] at (0,2.5) {$x_0$};
\draw[<-] (-1.5,-.6)--(1.5,.6); \node[below] at (-1.5,-.8) {$x_1$};
\fill[gray!20,opacity=.7] (-4.5,.2)--(-1.5,1.4)--(4.5,1.4)--(1.5,.2)--cycle;
\draw (0,1.4)--(0,.8);
\fill[gray,opacity=.2] (-3,0) ellipse (0.6cm and 1.6cm);
\fill[gray,opacity=.2] (3,0) ellipse (.6cm and 1.6cm);
\fill[gray,opacity=.5] (-3,-1.6)--(0,0)--(-3,1.6) arc (90:270:.6cm and 1.6cm);
\end{tikzpicture}
\end{document}
我失败的主要原因是追踪从椭圆下点到原点再到椭圆上点的路径,然后沿着内弧返回(而不是像现在这样沿着外弧返回)。
我不需要像上图那样将其旋转(“围绕 x_0”)并以奇特的方式进行阴影处理,我只想获得正确的不透明度,以便我的图片有意义。
任何帮助将不胜感激!
答案1
这是我的旧图。它不完全一样,但我认为它可能有用。您可以旋转它或更改轴并添加标签。
这里的技巧是使用 tikz 3d 库中的选项在平面内绘制双曲线canvas is yz plane...
。然后我们需要查看不同部分的顺序以获得正确的可见性。不幸的是,我们需要“几个”数学计算和变量变化来找到椭圆中的切线和切点。
\documentclass[border=2mm]{standalone}
\usepackage {tikz}
\usetikzlibrary{3d}
% isometric axes
\pgfmathsetmacro\xx{1/sqrt(2)}
\pgfmathsetmacro\xy{1/sqrt(6)}
\pgfmathsetmacro\zz{sqrt(2/3)}
% dimensions and some maths
\def\ch{2} % cone height
\def\cr{1} % cone radius \cr < \ch
\def\px{1.5} % plane semi-width \px > \cr
\def\py{0.5} % plane distance to z-axis \py < \cr
\pgfmathsetmacro\ca{atan(\cr/\ch)} % cone angle
\pgfmathsetmacro\cg{sqrt(\ch*\ch+\cr*\cr} % cone generatrix
\pgfmathsetmacro\gs{sqrt((2*\ch*\ch-\cr*\cr)/(3*\cr*\cr))} % generatrix slope
\pgfmathsetmacro\xt{sqrt(6)*\gs*\ch/(1+3*\gs*\gs)} % tangent point x
\pgfmathsetmacro\yt{\gs*\xt} % tangent point y
\pgfmathsetmacro\aa{(\ch*\zz-\yt)/\xy/2-\xt/\xx/2} % coordinate x in xy plane
\pgfmathsetmacro\bb{(\ch*\zz-\yt)/\xy/2+\xt/\xx/2} % coordinate y in xy plane
\pgfmathsetmacro\at{atan(\bb/\aa)+180} % angle to the tangent point
\pgfmathsetmacro\ix{sqrt(\cr*\cr-\py*\py)} % intersection plane-cone x
\pgfmathsetmacro\hv{\ch*\py/\cr} % hyperbola vertex
% styles
\tikzset%
{%
cone back/.style={red,left color=white,right color=red!50!black,fill opacity=0.8},
cone front/.style={red,left color=red, fill opacity=0.5},
plane/.style={blue,fill=blue!20,fill opacity=0.75}
}
\begin{document}
\begin{tikzpicture}[line cap=round,line join=round,%
x={(-\xx cm,-\xy cm)},y={(\xx cm,-\xy cm)},z={(0cm,\zz cm)}]
% cone, top base
\begin{scope}[canvas is xy plane at z=\ch]
\coordinate (TLT) at (90-\at:\cr); % tangent point, left
\coordinate (TRT) at (\at:\cr); % tangent point, right
\draw[cone back] (0,0) circle (\cr);
\end{scope}
% plane and hyperbola
\begin{scope}[rotate around z=-30,canvas is xz plane at y=\py,]
\draw[plane] plot[domain=-\ix:\ix,samples=21,smooth] (\x,{-\ch/\cr*sqrt(\x*\x+\py*\py)}) -- cycle;
\draw[plane] plot[domain=\ix:-\ix,samples=21,smooth] (\x,{ \ch/\cr*sqrt(\x*\x+\py*\py)}) -- cycle;
\end{scope}
% cone, bottom base
\begin{scope}[canvas is xy plane at z=-\ch]
\coordinate (TLB) at (180+\at:\cr); % tangent point, left
\coordinate (TRB) at (270-\at:\cr); % tangent point, right
\draw[red] (0,0) circle (\cr);
\end{scope}
% cone, surface
\draw[cone front]
{[canvas is xy plane at z= \ch] (TLT) arc (90-\at:\at:\cr)} -- (TLB)
{[canvas is xy plane at z=-\ch] arc (180+\at:-90-\at:\cr)} -- cycle;
% plane and hyperbola revisited
\begin{scope}[rotate around z=-30,canvas is xz plane at y=\py,]
\draw[plane] (-\px,-\ch) -- (-\ix,-\ch) -- plot[domain=-\ix:\ix,samples=21,smooth] (\x,{-\ch/\cr*sqrt(\x*\x+\py*\py)}) -|
(\px,\ch) -- (\ix,\ch) -- plot[domain=\ix:-\ix,samples=21,smooth] (\x,{ \ch/\cr*sqrt(\x*\x+\py*\py)}) -| cycle;
\end{scope}
\end{tikzpicture}
\end{document}