
および を使用すると、や同様のオブジェクトが図の残りの部分とともに回転するtikz-3dplot
ことを期待します。ただし、それらは 2D であるかのように描画されます。を回転した座標で強制的に描画するにはどうすればよいでしょうか。rectangle
grid
rectangle
\documentclass{article}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{patterns, arrows, matrix, positioning, decorations.markings, arrows.meta, decorations.pathreplacing}
\usepackage{tikz-3dplot}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\begin{document}
\tdplotsetmaincoords{70}{110}
\def\mycolor{blue}
\begin{tikzpicture}[scale=1, tdplot_main_coords, axis/.style={->,\mycolor,thick}]
\def\latnum{8}
\def\lonnum{8}
\draw[axis] (0,0,0) -- (\latnum+1,0,0) node[anchor=north east]{\huge $lat$};
\draw[axis] (0,0,0) -- (0,\lonnum+1,0) node[anchor=north west]{\huge $lon$};
\fill [orange] (\latnum-2,\lonnum-2,0) rectangle (2,2,0);
\end{tikzpicture}
\end{document}
答え1
これは非常に興味深い質問です。
次の行は同等であると予想されます。しかし、そうではありません。
\draw[red](0,0)rectangle(1,1);
\draw[blue](0,0)--(1,0)--(1,1)--(0,1)--cycle;
のrectangle
はTiによって処理されるけZを次の行(tikz.code.tex
行3140-3148
\pgfpathmoveto{\pgfqpoint{\pgf@xa}{\pgf@ya}}% \tikz@path@lineto{\pgfqpoint{\pgf@xa}{\tikz@lasty}}% \tikz@path@lineto{\pgfqpoint{\tikz@lastx}{\tikz@lasty}}% \tikz@path@lineto{\pgfqpoint{\tikz@lastx}{\pgf@ya}}% \pgfpathclose% \pgfpathmoveto{\pgfqpoint{\tikz@lastx}{\tikz@lasty}}%
このレベルでは、PGF はグラフィックスの 3D 構造を認識しないため、四角形は 2D 形式でキャンバスに描画されます。
\usetikzlibrary{3d}
そして、ここには本当に皮肉なことがあります。
\draw[canvas is xy plane at z=0](0,0)rectangle(1,1)circle(1);
\draw[canvas is yz plane at x=0](0,0)rectangle(1,1)circle(1);
\draw[canvas is zx plane at y=0](0,0)rectangle(1,1)circle(1);
すると、3 つの円が正しく描かれ、3 つの長方形のうち 2 つが正しく描かれます。間違っているのは、xy 平面上にある長方形です。
これは修正されました3D長方形を描く。