使用二次式形式繪製圓柱體

使用二次式形式繪製圓柱體

所以我一直在尋找一種繪製圓柱體的方法,但似乎找不到方法。如何從以下隱式函數中取得座標,以便可以使用 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}

相關內容