所以我一直在寻找一种绘制圆柱体的方法,但似乎找不到办法。如何从以下隐式函数中获取坐标,以便使用 pgfplots 绘制它?或者有没有办法使用矩阵形式绘制它?
$$1=q(x,y,z)=(x,y,z) \begin{bmatrix}
2& -1 & -1\\
-1 & 2 & -1\\
-1 &-1 &2
\end{bmatrix} (x,y,z)^T$$
答案1
您可以对这种无限扩展的退化椭球进行参数化(这是数学!)。我为您做到了。
圆柱体必须画两次,以处理图之间的假 3d:让线成为“里面”汽缸。
我将把取下一个气缸作为练习。
输出
代码
\documentclass[12pt,tikz,border=0pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset%{{{
{
mySurface/.style =
{
mesh, % there should be better options : look at the PGFplots manual
opacity=.1,
}
}
%}}}
\begin{document}
\begin{tikzpicture}
\begin{axis}
[
%{{{
width=30cm,
xticklabels=\empty,
yticklabels=\empty,
zticklabels=\empty,
samples = 2, % for the lines
samples y = 100, % for the circles
% limits of the box
xmin = -12, xmax = 12,
ymin = -12, ymax = 12,
zmin = -12, zmax = 12,
unit vector ratio = 1 1 1,
% parametrize the 3d view
view/az=15,
view/h=80,
%length of the cylinder
domain = -8:8,
%}}}
]
\def\X{\r*cos(y)-\r*sin(y) + x}
\def\Y{-\r*cos(y)-\r*sin(y) + x}
\def\Z{2 * \r*sin(y) + x}
\def\r{2}
\addplot3[mySurface,domain y= 90:270] ({\X},{\Y},{\Z});
\def\r{1}
\addplot3[mySurface,domain y= 90:270] ({\X},{\Y},{\Z});
\addplot3[domain=-12:12, samples=2, blue, thick] (x,x,x);
\addplot3[mySurface,domain y= -90:90] ({\X},{\Y},{\Z}); ;
\def\r{2}
\addplot3[mySurface,domain y= -90:90] ({\X},{\Y},{\Z}); ;
\end{axis}
\end{tikzpicture}
\end{document}