TikZ를 사용하여 음영 경계를 그리는 방법

TikZ를 사용하여 음영 경계를 그리는 방법

TikZ를 사용하여 아래 표시된 것과 같은 간단한 음영 영역을 어떻게 그릴 수 있습니까?

음영처리된 경계

방정식으로 둘러싸인 음영 영역

r1r2r3 - r1 - r2 - r3 + 2cos(theta)

그리고 입니다 r1=r2=r3=4. 경계는 의 값에 따라 약간 변경됩니다 theta. 이를 위해 우리는 다음과 같이 가정할 수 있습니다 theta=0.

여기서 아이디어는 특정 기능 및 fillbetween명령과 함께 TikZ를 사용하는 것이지만 3D 플롯에서는 까다로워집니다. 이 예는 더 많은 관련 경계를 그리는 데 사용될 수 있습니다.

모든 팁이나 관련 게시물이 도움이 될 것입니다!

편집하다

나는 pstricks가 아닌 TiKZ만을 사용하는 솔루션을 이상적으로 원합니다.

답변1

여기에 이미지 설명을 입력하세요

암시적 표면은 Ti로 스케치할 수 있다고 생각합니다.케이레벨 곡선(또는 기타 초평면 섹션)을 그릴 수 있는 경우 Z입니다. 표면의 경우xyz - x - y - z + 2 = 0(사실 어떤 값에 대해서도세타문제에서) 수준 곡선은 쌍곡선이므로 그리는 것이 어렵지 않습니다.

일부 댓글

  1. 원점에 특이점이 있도록 좌표를 변경했습니다. 즉, 다음과 같이 정의된 표면을 고려했습니다.xyz + xy + yz + zx = 0. 이전 내용을 번역한 것일 뿐입니다.

  2. 주어진 예를 보면 표면의 "시트"만 표현했습니다. 명시적으로 나는 큐브에 살고 있는 표면의 부분을 고려했습니다.[-1, 5]^3그리고 각 가지 중 한 가지에 의해서만 휩쓸려갑니다.z=h쌍곡선.

  3. 을 위한z=0쌍곡선은 두 직선의 합집합으로 변질됩니다. 을 위한z=-1그것은 다시 두 개의 선으로 변질되지만 하나는 무한대에 있습니다. 이러한 이유로 수준 곡선의 그리기는 다음의 부호에 따라 달라집니다.. 근처에는-1Ti의 한계 때문에 상황이 더 미묘해졌습니다.케이Z에 쉽게 도달할 수 있습니다. 예를 들어, 첫 번째 작업이 또는 \foreach에 대해 수행된 경우 얻은 곡선은 "실제"(또는 적어도 의도한 곡선)가 아닙니다.\i=1\i=2

  4. 코드가 길어 보일 수 있지만 \foreach코드를 그리는 처음 두 명령 은 무엇입니까?z=h레벨 곡선. 그 후, 그들은 단지 복사되고 수정되어x=h그리고y=h레벨 곡선.

  5. 쌍곡선의 각 가지는 매개변수화된 곡선으로 그려집니다. 매개변수의 경계는 큐브 내부 부분만 얻기 위해 계산됩니다.

코드

\documentclass[margin=.5cm]{standalone}

\usepackage{tikz}
\usetikzlibrary{math}
\usepackage{tikz-3dplot}
\usetikzlibrary{3d}
\usetikzlibrary{arrows.meta}

\begin{document}

\xdefinecolor{Cy}{RGB}{17, 170, 187}
\xdefinecolor{VB}{RGB}{102, 25, 240}

\tikzmath{
  integer \N-, \N+;
  \N- = 12;
  \N+ = 50;
  real \a;
  \a = 5;
}
\tikzset{
  pics/level curve+/.style args={height=#1, varbound=#2, color=#3}{%
    code={%
      \draw[#3, variable=\t, domain=-#2:#2, samples=40]
      plot ({#1/(#1 +1)*(exp(\t) -1)}, {#1/(#1 +1)*(exp(-\t) -1)});
    }
  },
  pics/level curve-/.style args={height=#1, varbound=#2, color=#3}{%
    code={%
      \draw[#3, variable=\t, domain=-#2:#2, samples=40]
      plot ({-#1/(#1 +1)*(exp(\t) +1)}, {-#1/(#1 +1)*(exp(-\t) +1)});
    }
  }
}
\begin{tikzpicture}
  \tdplotsetmaincoords{76}{67}
  \begin{scope}[tdplot_main_coords]
    % axes first part
    \draw (-1, 0, 0) -- (\a +.2, 0, 0);
    \draw (0, -1, 0) -- (0, \a +.2, 0);
    \draw (0, 0, -1) -- (0, 0, \a +.2);
    
    %%% $z=h$ level curves
    % close to $0^-$
    \foreach \i
    [evaluate=\i as \h using {-(\N- +1 -\i)/(\N- +1))*\a/(\a +1)},
    evaluate=\i as \b using {ln(-(\h +1)*\a/\h -1)}]
    in {1, 2, 3, 4, ..., \N-}{
      \path[canvas is xy plane at z=\h, transform shape] (0, 0)
      pic {level curve-={height=\h, varbound=\b, color=Cy}};
    }    

    % $h=0$
    \draw[Cy, canvas is xy plane at z=0] (0, \a) |- (\a, 0);

    % $h>0$
    \foreach \i
    [evaluate=\i as \h using {(\i/\N+)*\a},
    evaluate=\i as \b using {ln((\h +1)*\a/\h +1)}]
    in {1, 2, ..., \N+}{
      \path[canvas is xy plane at z=\h, transform shape] (0, 0)
      pic {level curve+={height=\h, varbound=\b, color=Cy}};
    }

    %%% $y=h$ level curves
    % close to $0^-$
    \foreach \i
    [evaluate=\i as \h using {-(\N- +1 -\i)/(\N- +1))*\a/(\a +1)},
    evaluate=\i as \b using {ln(-(\h +1)*\a/\h -1)}]
    in {3, 4, ..., \N-}{
      \path[canvas is xz plane at y=\h, transform shape] (0, 0)
      pic {level curve-={height=\h, varbound=\b, color=Cy}};
    }    

    % $h=0$
    \draw[Cy, thin, canvas is xz plane at y=0] (0, \a) |- (\a, 0);
    
    % $h>0$
    \foreach \i
    [evaluate=\i as \h using {(\i/\N+)*\a},
    evaluate=\i as \b using {ln((\h +1)*\a/\h +1)}]
    in {1, 2, ..., \N+}{
      \path[canvas is xz plane at y=\h, transform shape] (0, 0)
      pic {level curve+={height=\h, varbound=\b, color=Cy}};
    }

    %%% $x=h$ level curves
    % close to $0^-$
    \foreach \i
    [evaluate=\i as \h using {-(\N- +1 -\i)/(\N- +1))*\a/(\a +1)},
    evaluate=\i as \b using {ln(-(\h +1)*\a/\h -1)}]
    in {3, 4, ..., \N-}{
      \path[canvas is yz plane at x=\h, transform shape] (0, 0)
      pic {level curve-={height=\h, varbound=\b, color=Cy}};
    }    

    % $h=0$
    \draw[VB, canvas is yz plane at x=0] (0, \a) |- (\a, 0);
    
    % $h>0$
    \foreach \i
    [evaluate=\i as \h using {(\i/\N+)*\a},
    evaluate=\i as \b using {ln((\h +1)*\a/\h +1)}]
    in {1, 2, ..., \N+}{
      \path[canvas is yz plane at x=\h, transform shape] (0, 0)
      pic {level curve+={height=\h, varbound=\b, color=VB}};
    }

    %%% axes second part
    \begin{scope}[arrows={->[length=1ex, width=1.5ex]}]
      \draw (\a, 0, 0) -- (\a +2, 0, 0)  node[pos=1.2] {$x$};
      \draw (0, \a, 0) -- (0, \a +2, 0)  node[pos=1.2] {$y$};
      \draw (0, 0, \a) -- (0, 0, \a +2)  node[pos=1.2] {$z$};          
    \end{scope}
  \end{scope}
\end{tikzpicture}

\end{document}

관련 정보