![向右旋转形状](https://linux22.com/image/312170/%E5%90%91%E5%8F%B3%E6%97%8B%E8%BD%AC%E5%BD%A2%E7%8A%B6.png)
我在 tikz 中绘制了以下 3D 形状。
\documentclass[10pt]{article}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{pgf,tikz}
\usepackage{tkz-tab}
\usetikzlibrary{shapes,snakes,arrows,backgrounds}
\usetikzlibrary{scopes,svg.path,shapes.geometric,shadows}
\usepackage{graphicx}
\usepackage{xcolor}
\begin{document}
\begin{tikzpicture}[xscale=1.5, yscale=1.5]
\draw [->](0,0,0) -- (3,0,0) node[anchor=west]{$y$};
\draw [->, dashed](0,0,0) -- (0,3,0) node[anchor=west]{$z$};
\draw [->](0,0,0) -- (0,0,3) node[anchor=west]{$x$};
\draw [thick](1, 0, 0)--(0, 1, 0) -- (0, 0, 1)--(1, 0, 0);
\fill [blue!50!gray!30] (1, 0, 0)--(0, 1, 0) -- (0, 0, 1)--(1, 0, 0);
\draw (1, 0, 0) node[below] {$1$};
\draw (0, 1, 0) node[left] {$1$};
\draw (0, 0, 1) node[below] {$1$};
\end{tikzpicture}
\end{document}
我怎样才能将形状向右旋转,以便更好地查看轴?我在这里读过类似的问题,但我无法弄清楚。他们中的大多数旋转轴,但不旋转三角形。我也看到了 3D 绘图包,但我没有安装它,所以我无法使用它。
答案1
tikzpicture
您可以通过rotate=<angle>
向环境添加参数来旋转整个环境:
\begin{tikzpicture}[xscale=1.5, yscale=1.5,rotate=45]
但是,我认为这并不能使轴更容易看到。我认为您要做的就是先绘制三角形,然后在三角形顶部“上方”绘制轴,以便图像变成:
我所做的就是重新排列你的代码(所以没有旋转):
\documentclass[10pt]{article}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{pgf,tikz}
\usepackage{tkz-tab}
\usetikzlibrary{shapes,snakes,arrows,backgrounds}
\usetikzlibrary{scopes,svg.path,shapes.geometric,shadows}
\usepackage{graphicx}
\usepackage{xcolor}
\begin{document}
\begin{tikzpicture}[xscale=1.5, yscale=1.5]
\fill [blue!50!gray!30] (1, 0, 0)--(0, 1, 0) -- (0, 0, 1)--(1, 0, 0);
\draw [->](0,0,0) -- (3,0,0) node[anchor=west]{$y$};
\draw [->, dashed](0,0,0) -- (0,3,0) node[anchor=west]{$z$};
\draw [->](0,0,0) -- (0,0,3) node[anchor=west]{$x$};
\draw [thick](1, 0, 0)--(0, 1, 0) -- (0, 0, 1)--(1, 0, 0);
\draw (1, 0, 0) node[below] {$1$};
\draw (0, 1, 0) node[left] {$1$};
\draw (0, 0, 1) node[below] {$1$};
\end{tikzpicture}
\end{document}
话虽如此,你也可以稍微简化代码并编写:
\begin{tikzpicture}[xscale=1.5, yscale=1.5]
\draw[thick,fill=blue!50!gray!30] (1, 0, 0)node[below right]{$1$}
--(0, 1, 0)node[above left]{$1$}
--(0, 0, 1)node[below right]{$1$}--cycle;
\draw [->](0,0,0) -- (3,0,0) node[anchor=west]{$y$};
\draw [->, dashed](0,0,0) -- (0,3,0) node[anchor=west]{$z$};
\draw [->](0,0,0) -- (0,0,3) node[anchor=west]{$x$};
\end{tikzpicture}
获得几乎相同的输出(1
s 略微移动)。
答案2
要绕轴旋转,y
可以使用rotate around y=<degrees>
。在平均能量损失下面是我用来rotate around y=50
实现的:
笔记:
- 我重新标记了轴以使用更标准的方式,这也解释了为什么需要
(x,y,z)
绕轴旋转。y
\draw
当您只是想要一个 时,不需要一个\node
。- 这
join=round
使得角落更加平滑。
代码:
\documentclass[10pt]{article}
\usepackage{tikz}
\usepackage{xcolor}
\begin{document}
\begin{tikzpicture}[xscale=1.5, yscale=1.5, join=round, rotate around y=50]
\draw [->](0,0,0) -- (3,0,0) node[anchor=west]{$x$};
\draw [->, dashed](0,0,0) -- (0,3,0) node[anchor=west]{$y$};
\draw [->](0,0,0) -- (0,0,3) node[anchor=west]{$z$};
\draw [thick](1, 0, 0)--(0, 1, 0) -- (0, 0, 1)--(1, 0, 0);
\fill [blue!50!gray!30] (1, 0, 0)--(0, 1, 0) -- (0, 0, 1)--(1, 0, 0);
\node[below] at (1, 0, 0) {$1$};% <--- simplified
\node[left] at (0, 1, 0) {$1$};% <--- simplified
\node[below] at (0, 0, 1) {$1$};% <--- simplified
%% since we can now see the y-z axis
\fill [blue!50!gray!30] (0, 0, 0) -- (0, 1, 0) -- (0, 0, 1)-- cycle;
\draw (0,0,0) -- (0, 1, 0) -- (0,0,1) -- cycle;
\end{tikzpicture}%
\end{document}