
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(実際、シータ質問の場合、レベル曲線は双曲線であり、それを描くのは難しくありません。
コメント
座標を原点に特異点を持つように変更しました。つまり、次のように定義される表面を考えました。xyz + xy + yz + zx = 0。前回の翻訳のみです。
与えられた例を見ると、私は表面の「シート」のみを表しており、明示的には立方体に存在する表面の部分を考慮している。[-1, 5]^3そして、それぞれの枝の1つだけによって掃引されるz=h双曲線。
のために0 から 0 まで双曲線は2本の直線の和に退化する。z=-1それは再び2本の線に退化するが、そのうちの1本は無限遠にある。これらの理由から、レベル曲線の描画はず近隣の-1Tiの限界がけZ に簡単に到達できます。たとえば、最初のをまたは
\foreach
に対して実行した場合、得られる曲線は「実数」ではありません (少なくとも意図した曲線ではありません)。\i=1
\i=2
コードは長いように見えるかもしれませんが、重要なのは
\foreach
、z=hレベルカーブ。その後、それらをコピーして修正するだけで、x = hそしてy=hレベルカーブ。双曲線の各枝はパラメーター化された曲線として描画され、パラメーターの境界は立方体の内側の部分のみを取得するように計算されます。
コード
\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}