%20%E3%82%92%E6%8F%8F%E3%81%8F.png)
曲線を描こうとしているtikz-3dplot
それは円弧ではありません。 が を持っtikz
ているのと同様に、これを制御点で指定したいと思います(0,0) to [controls=+(45:1) and +(135:1)] (1,0)
。 を使用して円弧を描くことができることは知っています\tdplotdrawpolytopearc
が、ドキュメントには他の種類の曲線を描く方法に関する記述が見つかりませんでした。 2D 曲線と同じ構文を使用すると、制御点が作用するデフォルトの平面 (xy 平面のようです) が選択されるようです。その平面を選択する (そしてすべての点に対して変更する) 方法はあるでしょうか?
ここに私が持っている MWE と出力を示します:
\documentclass[tikz]{standalone}
\usepackage{tikz,tikz-3dplot}
\begin{document}
\tdplotsetmaincoords{75}{130}
\begin{tikzpicture}[tdplot_main_coords]
% Shape and boundary
\draw[blue] (0,0,0)--(-1,1,0);
\fill[green,fill opacity=.8] (0,0,0)--(0,1,0)--(-1,1,0)--(-1,1,1)--(0,0,1);
\draw[blue] (0,0,0)--(0,1,0)--(-1,1,0)--(-1,1,1)--(0,1,1)--(0,0,1)--(0,0,0);
\draw[blue] (0,0,1)--(-1,1,1) (0,1,0)--(0,1,1);
% Natural guess how to draw curve
\draw[red] (0,0,0) to [controls=+(45:1) and +(135:1)] (0,1,0);
% Closest documented way how to draw curve
\tdplotdefinepoints(0,.5,-.3)(0,-.5,.3)(0,1.5,.3)
\tdplotdrawpolytopearc{.583}{}{}
\end{tikzpicture}
\end{document}
このプリズムの「面」に、黒い曲線のように左向きの曲線を描きたいのですが、端点ではより「強い」曲線 (正弦曲線のように) を描きたいです。失敗したのは、プリズムの「底面」の平面にあるように見える赤い曲線です。
そこで私の質問は次のとおりです。円弧ではない曲線を 3D で描くにはどうすればよいでしょうか?
答え1
tikz-3dplot
のマニュアルではこの点についてあまり明確に説明されていないのは事実です。しかし、私の意見では、 の主な機能tikz-3dplot
は、3D座標系の直交投影をインストールすることです。それ以外では、標準のTiを使用できます。けZ コマンド。
特に、パラメトリック プロットを使用すると、必要なものを何でも描画できます。
\documentclass[tikz]{standalone}
\usepackage{tikz,tikz-3dplot}
\begin{document}
\tdplotsetmaincoords{75}{130}
\begin{tikzpicture}[tdplot_main_coords]
% Shape and boundary
\draw[blue] (0,0,0)--(-1,1,0);
\fill[green,fill opacity=.8] (0,0,0)--(0,1,0)--(-1,1,0)--(-1,1,1)--(0,0,1);
\draw[blue] (0,0,0)--(0,1,0)--(-1,1,0)--(-1,1,1)--(0,1,1)--(0,0,1)--(0,0,0);
\draw[blue] (0,0,1)--(-1,1,1) (0,1,0)--(0,1,1);
\draw plot[variable=\x,domain=0:1] (0,\x,{0.3*sin(\x*180)});
\end{tikzpicture}
\end{document}
ただし、例では、面の 1 つに通常の曲線を描く方法を探しているようです。このためには、ライブラリを使用して3d
、対応する面と一致する平面に曲線を描くだけで済みます。
\documentclass[tikz]{standalone}
\usepackage{tikz,tikz-3dplot}
\usetikzlibrary{3d}
\begin{document}
\tdplotsetmaincoords{75}{130}
\begin{tikzpicture}[tdplot_main_coords]
% Shape and boundary
\draw[blue] (0,0,0)--(-1,1,0);
\fill[green,fill opacity=.8] (0,0,0)--(0,1,0)--(-1,1,0)--(-1,1,1)--(0,0,1);
\draw[blue] (0,0,0)--(0,1,0)--(-1,1,0)--(-1,1,1)--(0,1,1)--(0,0,1)--(0,0,0);
\draw[blue] (0,0,1)--(-1,1,1) (0,1,0)--(0,1,1);
\begin{scope}[canvas is yz plane at x=0]
\draw[red] (0,0) to [controls=+(45:1) and +(135:1)] (1,0);
\end{scope}
%\draw plot[variable=\x,domain=0:1] (0,\x,{0.3*sin(\x*180)});
\end{tikzpicture}
\end{document}
これらの投影はTiだけでなくけZ コマンドだけでなく、外部グラフィックスでも使用できます。
\documentclass[tikz]{standalone}
\usepackage{tikz,tikz-3dplot}
\usetikzlibrary{3d}
\begin{document}
\tdplotsetmaincoords{75}{130}
\begin{tikzpicture}[tdplot_main_coords]
% Shape and boundary
\draw[blue] (0,0,0)--(-1,1,0);
\fill[green,fill opacity=.8] (0,0,0)--(0,1,0)--(-1,1,0)--(-1,1,1)--(0,0,1);
\draw[blue] (0,0,0)--(0,1,0)--(-1,1,0)--(-1,1,1)--(0,1,1)--(0,0,1)--(0,0,0);
\draw[blue] (0,0,1)--(-1,1,1) (0,1,0)--(0,1,1);
\begin{scope}[canvas is xz plane at y=1,transform shape]
\node at (-0.5,0.5) {\includegraphics[width=0.9cm]{example-image-duck}};
\end{scope}
%\draw plot[variable=\x,domain=0:1] (0,\x,{0.3*sin(\x*180)});
\end{tikzpicture}
\end{document}