我想绘制伯努利双纽线(见下文):
不过,我想以类似于下面这个问题中的图片的方式绘制它,这个问题已经得到回答了:水平曲线与水平线之间的关系
特别是,我想突出显示值 0 处的水平曲线,即 f(x,y)=0(对于 f 为伯努利双纽线)。
答案1
好吧...这只是为了好玩。最好的(矢量)解决方案可能是 pgfplots。但我想知道 tikz 能做什么,然后我就想到了这个。
我正在绘制函数 (1),或者在圆柱坐标系 (2) 中绘制。表达式 (3) 以 theta 的形式给出了 rho。 这是我的建议:
\documentclass[border=2mm]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[scale=2,line cap=round,line join=round,
x={(-0.7766cm,-0.1369cm)},y={(0.6300cm,-0.1688cm)},z={(0cm,0.9761cm)}]
\def\xmin{1}
\def\ymin{0.7}
\pgfmathsetmacro\xstep{\xmin-0.2}
\pgfmathsetmacro\ystep{\ymin-0.1}
\def\h{-1.4} % projection height
% blue lines, sections perpendicular to the x axis
\foreach\i in{-\xmin,-\xstep,...,\xmin}
{% domain in which z>=-1
\pgfmathsetmacro\xdom{min(\ymin,sqrt(-0.5-\i*\i+0.5*sqrt(5+8*\i*\i)))}
\draw[blue] plot[domain=-\xdom:\xdom,samples=25,smooth]
(\i,\x,{-(\i*\i+\x*\x)*(\i*\i+\x*\x)+(\i*\i-\x*\x)});
}
% cyan lines, sections perpendicular to the y axis
\foreach\i in{-\ymin,-\ystep,...,\ymin}
{% domain in which z>=-1
\pgfmathsetmacro\xdom{min(\xmin,sqrt(0.5-\i*\i+0.5*sqrt(5-8*\i*\i)))}
\draw[cyan] plot[domain=-\xdom:\xdom,samples=25,smooth]
(\x,\i,{-(\x*\x+\i*\i)*(\x*\x+\i*\i)+(\x*\x-\i*\i)});
}
% Bernouilli's lemniscate (and projection)
\foreach\a in {0,180} \foreach\z in {0,\h}
{%
\draw[thick,red] plot[domain=-45+\a: 45+\a,samples=25,smooth]
({sqrt(cos(2*\x))*cos(\x)},{sqrt(cos(2*\x))*sin(\x)},\z);
}
% Other level curves (and projections)
\def\z{0.2}
\pgfmathsetmacro\xdom{0.5*acos(2*sqrt(\z))-0.005} % precission problem, I think
\foreach\zz in {\z,\h} \foreach\a in {0,180} \foreach\s in {-1,1}
{%
\draw[red] plot[domain=\a-\xdom:\a+\xdom,samples=25,smooth]
({sqrt(0.5*cos(2*\x)+0.5*\s*sqrt(cos(2*\x)*cos(2*\x)-4*\z))*cos(\x)},
{sqrt(0.5*cos(2*\x)+0.5*\s*sqrt(cos(2*\x)*cos(2*\x)-4*\z))*sin(\x)},\zz);
}
\foreach\z in {-0.2,-0.4,-0.6} \foreach\zz in {\z,\h}
{%
\draw[red] plot[domain=-180:180,samples=51,smooth]
({sqrt(0.5*cos(2*\x)+0.5*sqrt(cos(2*\x)*cos(2*\x)-4*\z))*cos(\x)},
{sqrt(0.5*cos(2*\x)+0.5*sqrt(cos(2*\x)*cos(2*\x)-4*\z))*sin(\x)},\zz);
}
% axes
\draw[-latex] (0,0,0) -- (2,0,0) node[left] {$x$};
\draw[-latex] (0,0,0) -- (0,2,0) node[right] {$y$};
\draw[-latex] (0,0,0) -- (0,0,1) node[above] {$z$};
\end{tikzpicture}
\end{document}