我想表示两个向量 $\vec a,\vec b$ 的叉积。我想制作一个右手三角。如何沿 $\hat n$ 绘制一个螺旋线以及如何用 $\theta$ 标记角度?
\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[line width=.8pt,x={(1,0)}, z={(-0.5,-0.5)}]
\coordinate (O) at (0,0,0);
\coordinate (Ay) at (0,3,0);
% Draw the axes
\foreach \c/\l/\p in {{4.5,0,0}/\vec{b}/right, {3,-3,0}/\vec{a}/below left}{
\draw[->] (O) -- +(\c) node[\p] {$\l$};
}
\draw[->] (O) -- node[pos=0.7,above left] {$\hat{n}$} (Ay);
\end{tikzpicture}
\end{document}
编辑:
\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc,angles,positioning,quotes}
\begin{document}
\begin{tikzpicture}
\draw (0,0) coordinate (O) -- (0,2)
\draw (3,0) coordinate (A) -- (0,0) coordinate (B)
-- (2,-2) coordinate (C)
pic [fill=black!50] {angle = C--B--A}
pic [draw,->,red,thick,angle radius=1cm] {angle = C--B--A};
\end{tikzpicture}
\end{document}
答案1
我发现了一个参数化方程螺旋维基百科。tikz
从头开始处理三维图形,但我相信额外的库可以简化绘制更复杂图形的过程。
这是您要尝试实现的某个目标的示例。从下面的代码开始。3d view
让您更改向量的方向。
\documentclass{standalone}
\usepackage[svgnames]{xcolor}
\usepackage{tikz}
\usetikzlibrary {perspective,arrows.meta}
\begin{document}
\begin{tikzpicture}[
3d view={135}{30}, % "isometric view" with azimuth=45
axes/.style = {-Latex,line width=0.5pt,Gray},
helix/.style = {-{Latex[scale=0.75,sep=-10pt]},line width=2pt,black},
]
% \path (tpp cs:x=4, y=5, z=0) node [font=\Large, below left=-3mm and 5mm] {$\mathcal{S}$};
\draw[axes] (0,0,0) -- (4,0,0) node [pos=1.1,black] {$\bar{a}$};
\draw[axes] (0,0,0) -- (0,3,0) node [pos=1.1,black] {$\bar{b}$};
\draw[axes] (0,0,0) -- (0,0,5) node [pos=1.1,black] {$\bar{a} \times \bar{b}$};
\draw [helix] (0.35,0,0) \foreach \t [
evaluate=\t as \x using 0.35*cos(\t),
evaluate=\t as \y using 0.35*sin(\t),
evaluate=\t as \z using 0.0015*\t,
] in {10,20,...,3000} {-- (\x,\y,\z)};
\draw [-Latex] (tpp cs:x=2, y=0, z=0) arc (0:90:2) node [pos=0.5,above] {$\phi$};
\end{tikzpicture}
\end{document}
答案2
我的代码很长,因为至少在我看来,在空间中生成一个带有向量的弹簧并不容易。有许多变量和常量(对于向量 a 和 b,以及它们的叉积,对于弹簧的半径等等)。您也可以尝试改变视角...
代码
\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usepackage{tikz-3dplot}
\usetikzlibrary{math, calc, arrows.meta}
\begin{document}
\tikzset{%
view/.style 2 args={% observer longitude and latitude (y upwards)
% Remark. lomg=0 means x=0
z={({-sin(#1)}, {-cos(#1)*sin(#2)})},
x={({cos(#1)}, {-sin(#1)*sin(#2)})},
y={(0, {cos(#2)})},
evaluate={%
\tox={sin(#1)*cos(#2)};
\toy={sin(#2)};
\toz={cos(#1)*cos(#2)};
},
longitude = #1,
latitude = #2
}
}
\pgfkeys{/tikz/.cd,
latitude/.store in=\aLatit, % observer's latitude
latitude=0
}
\pgfkeys{/tikz/.cd,
longitude/.store in=\aLongit, % observer's longitude
longitude=0 % corresponds to x=0
}
\tikzset{
arc from/.style args={#1 towards #2}{%
insert path={coordinate (tmp) let
\p1 = (tmp),
\p2 = (#1),
\p3 = (#2),
\n1 = {veclen(\x1-\x2, \y1-\y2)},
\n2 = {atan2(\y2-\y1, \x2-\x1)},
\n3 = {atan2(\y3-\y1, \x3-\x1)}
in (\p2) arc (\n2: \n3 : \n1)
}
}
}
\tikzmath{
real \ax, \ay, \az, \bx, \by, \bz, \cx, \cy, \cz;
\ax = 2; \ay = -1.5; \az = 1;
\bx = 1.5; \by = .5; \bz = -.75;
\cx = \ay*\bz -\az*\by;
\cy = -\ax*\bz +\az*\bx;
\cz = \ax*\by -\ay*\bx;
real \an, \bn, \ux, \uy, \uz, \vx, \vy, \vz, \vn, \uv, \wx, \wy, \wz;
\an = {sqrt(\ax*\ax +\ay*\ay + \az*\az)};
\ux = \ax/\an; \uy = \ay/\an; \uz = \az/\an;
\bn = {sqrt(\bx*\bx +\by*\by + \bz*\bz)};
\vx = \bx/\bn; \vy = \by/\bn; \vz = \bz/\bn;
\uv = \ux*\vx +\uy*\vy +\uz*\vz;
\vx = \vx -\uv*\ux;
\vy = \vy -\uv*\uy;
\vz = \vz -\uv*\uz;
\vn = {sqrt(\vx*\vx +\vy*\vy + \vz*\vz)};
\vx = \vx/\vn; \vy = \vy/\vn; \vz = \vz/\vn;
\wx = \uy*\vz -\uz*\vy;
\wy = -\ux*\vz +\uz*\vx;
\wz = \ux*\vy -\uy*\vx;
real \r, \wl;
\r = .2;
\wl = .5;
integer \N, \nbPoints;
\N = 4;
\nbPoints = 24;
}
\begin{tikzpicture}[view={45}{28}, line width=.8pt, every node/.style={scale=.7}]
% canonical coordinate system
\begin{scope}[color=gray!80, line width=.2pt]
\draw[->] (0, 0, 0) -- (1, 0, 0) node[shift={(.2, .1, 0)}] {$x$};
\draw[->] (0, 0, 0) -- (0, 1, 0) node[shift={(.2, .2, 0)}] {$y$};
\draw[->] (0, 0, 0) -- (0, 0, 1) node[shift={(0, .2, .2)}] {$z$};
\end{scope}
% the vectors
\draw[arrows={-Latex}] (0, 0, 0) -- (\ax, \ay, \az)
node[pos=.7, left] {$\vec{a}$};
\draw[arrows={-Latex}] (0, 0, 0) -- (\bx, \by, \bz)
node[pos=.7, above] {$\vec{b}$};
\draw (0, 0, 0) -- (\cx, \cy, \cz)
node[pos=.7, above right] {$\vec{a}\times\vec{b}$};
% Gram Schmidt on the vectors
\begin{scope}[color=orange!80, line width=.4pt]
\draw[->] (0, 0, 0) -- (\ux, \uy, \uz) coordinate (U);
\path (\bx/\bn, \by/\bn, \bz/\bn) coordinate (V);
\draw[->] (0, 0, 0) -- (\vx, \vy, \vz);
% \draw[->] (0, 0, 0) -- (\wx, \wy, \wz);
\end{scope}
% the arc
\draw[->, very thin] (0, 0, 0) [arc from=U towards V];
% cross product inside the spring
\draw[white, opacity=.7, line width=3pt]
(0, 0, 0) -- (${(\N -1)*\wl}*(\wx, \wy, \wz)$) coordinate (seen);
% the spring
\foreach \j [parse=true, evaluate=\j as \s using {(\j -1)/\nbPoints*360},
evaluate=\j as \t using {\j/\nbPoints*360}]
in {1, ..., \N*\nbPoints}{%
\tikzmath{%
\x1 = \r*cos(\s)*\ux +\r*sin(\s)*\vx +(\j -1)/\nbPoints*\wl*\wx;
\y1 = \r*cos(\s)*\uy +\r*sin(\s)*\vy +(\j -1)/\nbPoints*\wl*\wy;
\z1 = \r*cos(\s)*\uz +\r*sin(\s)*\vz +(\j -1)/\nbPoints*\wl*\wz;
\x2 = \r*cos(\t)*\ux +\r*sin(\t)*\vx +\j/\nbPoints*\wl*\wx;
\y2 = \r*cos(\t)*\uy +\r*sin(\t)*\vy +\j/\nbPoints*\wl*\wy;
\z2 = \r*cos(\t)*\uz +\r*sin(\t)*\vz +\j/\nbPoints*\wl*\wz;
}
\draw[blue, preaction={draw=white, opacity=.9, line width=2pt}]
(\x1, \y1, \z1) -- (\x2, \y2, \z2);
}
% the cross product over the spring
\draw[arrows={-Latex}, preaction={draw=white, opacity=.9, line width=2pt}]
(seen) -- (\cx, \cy, \cz);
\end{tikzpicture}
\end{document}