有没有办法使用 TikZ 来计算两个向量的叉积?
这是我的代码:
\begin{tikzpicture}[scale=2]
\coordinate (ey) at (1,0,0);
\coordinate (ez) at (0,1,0);
\coordinate (ex) at (0,0,1);
\begin{scope}[x={(ex)},y={(ey)},z={(ez)}]
\def\xM{1.2}
\def\yM{1.6}
\def\zM{1.8}
\def\ech{2}
\coordinate (O) at (0,0,0);
\coordinate (X) at (\ech,0,0);
\coordinate (Y) at (0,\ech,0);
\coordinate (Z) at (0,0,\ech);
\coordinate (Pz) at (0,0,\zM);
\coordinate (M) at (\xM,\yM,\zM);
\coordinate (H) at (\xM,\yM,0);
\coordinate (V) at ($0.4*(H)+0.48*(Pz)$);
\coordinate (W) at ($0.4*(H)$);
\coordinate (Vz) at ($0.48*(Pz)$);
\coordinate (U) at ($0.33*(Pz)$);
\draw[->,thick] (0,0,0) -- (1,0,0) node[above left] {$\vec{\imath}$};
\draw[->,thick] (0,0,0) -- (0,1,0) node[below] {$\vec{\jmath}$};
\draw[->,thick] (0,0,0) -- (0,0,1) node[left] {$\vec{k}$};
\draw (O) -- (X);
\draw (O) -- (Y);
\draw (O) -- (Z);
\draw (O) -- (H);
\draw[very thick,->,blue] (O) -- (V) node[above right] {$\vec{v}$};
\draw[very thick,->,blue] (O) -- (W) node[below] {$\vec{w}$};
\draw[very thick,->,blue] (O) -- (U) node[left] {$\vec{u}$};
\draw (M) -- (H);
\draw (M) -- (Pz);
\draw[ultra thin] (V) -- (Vz);
\draw[ultra thin] (V) -- (W);
\path (O) node[left] {$O$};
\pgfmathsetmacro\angletheta{atan(\yM/\xM)} % rotation angle for OHM plane (theta)
\draw pic [rotate around z=\angletheta,canvas is xz plane at y=0,% draws in the OHM plane
draw,angle radius=0.75cm,
"$\theta$", % angle label (requires quotes library)
angle eccentricity=1.4 % angle position
] {angle = V--O--Z};
\draw[ultra thin] pic [draw,angle radius=0.2cm] {right angle = V--Vz--O};
\draw pic [canvas is xy plane at z=0,% draws in the xy plane
draw,->,angle radius=0.75cm,
"$\varphi$", % angle label (requires quotes library)
angle eccentricity=1.8 % angle position
] {angle = X--O--H};
\end{scope}
\end{tikzpicture}
所以,现在我想在平面 Oxy(以原点 O)上绘制矢量 n,它是 ux v 的叉积。
我怎样才能做到这一点?
答案1
使用tikz-3dplot
包。从您的示例中,我了解到v
上的投影Oxy
是w
。一切都取决于两个角度,phi 和 theta,以及u
和的范数w
。它们是在开始时定义的。
代码
\documentclass[11pt, border=10pt]{standalone}
\usepackage{tikz}
\usepackage{tikz-3dplot}
\usetikzlibrary{math, calc}
\begin{document}
\tikzmath{%
real \f, \t, \uNorm, \wNorm, \bound;
\f = 40; % phi angle
\t = 35; % theta angle
\uNorm = .6;
\wNorm = 1.3;
\bound = 1.5;
}
\tikzset{%
vec/.style={#1, thick, ->}
}
\tdplotsetmaincoords{75}{120}
\begin{tikzpicture}[every node/.style={scale=.7}, scale=2]
\begin{scope}[tdplot_main_coords]
\draw[thin] (0, 0, 0) -- (\bound, 0, 0) node[pos=1.1] {$x$};
\draw[thin] (0, 0, 0) -- (0, \bound, 0) node[pos=1.1] {$y$};
\draw[thin] (0, 0, 0) -- (0, 0, \bound) node[pos=1.1] {$z$};
\draw[vec=red] (0, 0, 0) -- (1, 0, 0) node[below] {$i$};
\draw[vec=red] (0, 0, 0) -- (0, 1, 0) node[above] {$j$};
\draw[vec=red] (0, 0, 0) -- (0, 0, 1) node[left] {$k$};
\draw[vec=blue] (0, 0, 0) -- (0, 0, \uNorm)
coordinate (u) node[left] {$u$};
\begin{scope}[rotate around z=\f, canvas is zx plane at y=0]
\draw[very thin, gray!50] (0, 0) rectangle (\bound, 1.4*\bound);
\draw[vec=blue] (0, 0) -- (0, \wNorm) coordinate (w) node[left] {$w$};
\draw[vec=blue] (0, 0) -- ({\wNorm*tan(\t)}, \wNorm)
coordinate (v) node[right] {$v$};
\draw[red, dashed, very thin] (w) -- (v)
let \p1 = (v) in -- (\x1, 0);
\end{scope}
%\draw[red, dashed] (v) -- (w);
\draw[vec=blue, rotate around z=\f]
(0, 0, 0) -- (0, -\uNorm*\wNorm, 0) node[above] {$u\times v$};
\end{scope}
\end{tikzpicture}
\end{document}