我想在特定点绘制地面(0.25,0,-0.15)
。我使用的是 3dplot,因此地面看起来与主轴不对齐(有一点坡度)。如何使地面看起来与主 xy、yz 或 xz 平面对齐?(例如,如果要与 yz 对齐,它将看起来像螺旋线)
\documentclass{article}
\usepackage{tikz}
\usepackage{tikz-3dplot}
\usetikzlibrary{decorations.pathmorphing,patterns}
\begin{document}
%sets the Euler matrix to use an XYZ (yaw-pitch-roll) order for the rotations.
\newcommand{\tdseteulerxyz}{
\renewcommand{\tdplotcalctransformrotmain}{%
%perform some trig for the Euler transformation
\tdplotsinandcos{\sinalpha}{\cosalpha}{\tdplotalpha}
\tdplotsinandcos{\sinbeta}{\cosbeta}{\tdplotbeta}
\tdplotsinandcos{\singamma}{\cosgamma}{\tdplotgamma}
%
\tdplotmult{\sasb}{\sinalpha}{\sinbeta}
\tdplotmult{\sasg}{\sinalpha}{\singamma}
\tdplotmult{\sasbsg}{\sasb}{\singamma}
%
\tdplotmult{\sacb}{\sinalpha}{\cosbeta}
\tdplotmult{\sacg}{\sinalpha}{\cosgamma}
\tdplotmult{\sasbcg}{\sasb}{\cosgamma}
%
\tdplotmult{\casb}{\cosalpha}{\sinbeta}
\tdplotmult{\cacb}{\cosalpha}{\cosbeta}
\tdplotmult{\cacg}{\cosalpha}{\cosgamma}
\tdplotmult{\casg}{\cosalpha}{\singamma}
%
\tdplotmult{\cbsg}{\cosbeta}{\singamma}
\tdplotmult{\cbcg}{\cosbeta}{\cosgamma}
%
\tdplotmult{\casbsg}{\casb}{\singamma}
\tdplotmult{\casbcg}{\casb}{\cosgamma}
%
%determine rotation matrix elements for Euler transformation
\pgfmathsetmacro{\raaeul}{\cacb}
\pgfmathsetmacro{\rabeul}{\casbsg - \sacg}
\pgfmathsetmacro{\raceul}{\sasg + \casbcg}
\pgfmathsetmacro{\rbaeul}{\sacb}
\pgfmathsetmacro{\rbbeul}{\sasbsg + \cacg}
\pgfmathsetmacro{\rbceul}{\sasbcg - \casg}
\pgfmathsetmacro{\rcaeul}{-\sinbeta}
\pgfmathsetmacro{\rcbeul}{\cbsg}
\pgfmathsetmacro{\rcceul}{\cbcg}
}
}
%translation for drawing spiral
\newcommand{\translatepoint}[1]%
{ \coordinate (mytranslation) at (#1);
}
\begin{tikzpicture}[scale=5,tdplot_rotated_coords,
cube/.style={very thick,black},
grid/.style={very thin,gray},
axis/.style={->,blue,thick},
spring/.style={decorate,decoration={zigzag,pre length=0.1cm,post length=0.1cm,segment length=3}},
rotated axis/.style={->,purple,thick}]
%draw the spiral
\translatepoint{0.25,0,0}
\begin{scope}[canvas is yz plane at x=0]
\draw [domain=0:30,variable=\t,smooth,samples=75,shift=(mytranslation), black]
plot ({\t r}: {0.00005*\t*\t});
\end{scope}
%draw ground
\tikzstyle{ground}=[fill,pattern=north east lines,draw=none,minimum width=0.5cm,minimum height=0.2cm]
\node (ground1) at (0.25,0,-0.15) [ground, xshift=2, anchor=north] {};
\draw (ground1.north west) -- (ground1.north east);
\end{tikzpicture}
\end{document}
答案1
通过添加tdplot_main_coords
和canvas is yz plane at x=0
地面样式选项来解决:
\tikzstyle{ground}=[fill,tdplot_main_coords,canvas is yz plane at x=0, pattern=north east lines,draw=none,minimum width=0.5cm,minimum height=0.2cm]