下列的这帖子,这是另一种我不明白的情况。无论我使用什么矩阵(P
、P projected
或PI
)PI projected
,ey'
和ey''
总是不同的(虽然它们不应该不同)!
\documentclass{article}
\usepackage{tikz}
\usepackage{tikz-3dplot}
\begin{document}
\begin{tikzpicture}[scale=2]
% Choose a good looking canonical basis
\pgfmathsetmacro\mainRx{70}
\pgfmathsetmacro\mainRz{110}
\tdplotsetmaincoords{\mainRx}{\mainRz}
\begin{scope}[tdplot_main_coords]
% Draw canonical basis
\draw[blue,-latex] (0,0,0) -- (1,0,0) node[shift={(0.1,0,0)}] {$e_x$};
\draw[red,-latex] (0,0,0) -- (0,1,0) node[shift={(0,0.1,0)}] {$e_y$};
\draw[green,-latex] (0,0,0) -- (0,0,1) node[shift={(0,0,0.1)}] {$e_z$};
% An other basis P
\pgfmathsetmacro\Pxx{-sqrt(2)/2}
\pgfmathsetmacro\Pxy{sqrt(2)/2}
\pgfmathsetmacro\Pxz{0}
\pgfmathsetmacro\Pyx{-sqrt(2)/2}
\pgfmathsetmacro\Pyy{-sqrt(2)/2}
\pgfmathsetmacro\Pyz{0}
\pgfmathsetmacro\Pzx{0}
\pgfmathsetmacro\Pzy{0}
\pgfmathsetmacro\Pzz{1}
% Compute the inverse of P
\pgfmathsetmacro\detP{\Pxx*\Pyy*\Pzz-\Pxx*\Pyz*\Pzy-\Pxy*\Pyx*\Pzz+\Pxy*\Pyz*\Pzx+\Pxz*\Pyx*\Pzy-\Pxz*\Pyy*\Pzx}
\pgfmathsetmacro\PIxx{(\Pyy*\Pzz-\Pzy*\Pyz)/\detP}
\pgfmathsetmacro\PIxy{(\Pzy*\Pxz-\Pxy*\Pzz)/\detP}
\pgfmathsetmacro\PIxz{(\Pxy*\Pyz-\Pyy*\Pxz)/\detP}
\pgfmathsetmacro\PIyx{(\Pzx*\Pyz-\Pyx*\Pzz)/\detP}
\pgfmathsetmacro\PIyy{(\Pxx*\Pzz-\Pzx*\Pxz)/\detP}
\pgfmathsetmacro\PIyz{(\Pyx*\Pxz-\Pxx*\Pyz)/\detP}
\pgfmathsetmacro\PIzx{(\Pyx*\Pzy-\Pzx*\Pyy)/\detP}
\pgfmathsetmacro\PIzy{(\Pzx*\Pxy-\Pxx*\Pzy)/\detP}
\pgfmathsetmacro\PIzz{(\Pxx*\Pyy-\Pyx*\Pxy)/\detP}
% Draw basis
\draw[blue,-latex] (0,0,0) -- (\Pxx,\Pxy,\Pxz) node[shift={(0.1,0,0)}] {$e_{x'}$};
\draw[red,-latex] (0,0,0) -- (\Pyx,\Pyy,\Pyz) node[shift={(0,0.1,0)}] {$e_{y'}$};
\draw[green,-latex] (0,0,0) -- (\Pzx,\Pzy,\Pzz) node[shift={(0,0,0.1)}] {$e_{z'}$};
% Use of matrix P
\begin{scope}[x={(\Pxx,\Pxy,\Pxz)},y={(\Pyx,\Pyy,\Pyz)},z={(\Pzx,\Pzy,\Pzz)}]
% Use of matrix P projected
%\begin{scope}[x={(\Pxx,\Pxy)},y={(\Pyx,\Pyy)},z={(\Pzx,\Pzy)}]
% Use of matrix PI
%\begin{scope}[x={(\PIxx,\PIxy,\PIxz)},y={(\PIyx,\PIyy,\PIyz)},z={(\PIzx,\PIzy,\PIzz)}]
% Use of matrix PI projected
%\begin{scope}[x={(\PIxx,\PIxy)},y={(\PIyx,\PIyy)},z={(\PIzx,\PIzy)}]
% Draw canonical basis after change of basis
\draw[blue,-latex] (0,0,0) -- (1,0,0) node[shift={(0.1,0,0)}] {$e_{x''}$};
\draw[red,-latex] (0,0,0) -- (0,1,0) node[shift={(0,0.1,0)}] {$e_{y''}$};
\draw[green,-latex] (0,0,0) -- (0,0,1) node[shift={(0,0,0.1)}] {$e_{z''}$};
\end{scope}
\end{scope}
\end{tikzpicture}
\end{document}
答案1
好吧,我得到了答案。经过大量工作后,才得到一个令人沮丧的答案……
看来我们必须\coordinate
在改变基础之前使用宏。
我的意思是,这个改变会起作用:
\coordinate (X) at (\Pxx,\Pxy,\Pxz);
\coordinate (Y) at (\Pyx,\Pyy,\Pyz);
\coordinate (Z) at (\Pzx,\Pzy,\Pzz);
\begin{scope}[x={(X)},y={(Y)},z={(Z)}]
% Draw canonical basis after change of basis
\draw[blue,-latex] (0,0,0) -- (1,0,0) node[shift={(0.1,0,0)}] {$e_{x''}$};
\draw[red,-latex] (0,0,0) -- (0,1,0) node[shift={(0,0.1,0)}] {$e_{y''}$};
\draw[green,-latex] (0,0,0) -- (0,0,1) node[shift={(0,0,0.1)}] {$e_{z''}$};
\end{scope}
但是这个不会:
\begin{scope}[x={(\Pxx,\Pxy,\Pxz)},y={(\Pyx,\Pyy,\Pyz)},z={(\Pzx,\Pzy,\Pzz)}]
% Draw canonical basis after change of basis
\draw[blue,-latex] (0,0,0) -- (1,0,0) node[shift={(0.1,0,0)}] {$e_{x''}$};
\draw[red,-latex] (0,0,0) -- (0,1,0) node[shift={(0,0.1,0)}] {$e_{y''}$};
\draw[green,-latex] (0,0,0) -- (0,0,1) node[shift={(0,0,0.1)}] {$e_{z''}$};
\end{scope}
当然,这两个部分必须集成到问题的代码中。因此,基础的工作变化意味着(ex',ey',ez')
将与相同(ex'',ey'',ez'')
。
另一个细节是,如果您想改变基础的起源,您必须在改变基础之后再进行。
我的意思是这样:
\begin{scope}[x={(X)},y={(Y)},z={(Z)},shift={(O)}]
不是这样:
\begin{scope}[shift={(O)},x={(X)},y={(Y)},z={(Z)}]