|
SmtC: Show me the Code
Ole Peter Smith
Instituto de Matemática e Estatística
Universidade Federal de Goiás
http://www.olesmith.com.br
|
|
-
-
Rotation in $\mathbb{R}^3$*
Como libertar um povo que preza seus correntes?
Niculau Maquiavel.
|
Is TikZ 3D?
\[
\underline{p}'=
\frac{\underline{p} \cdot \underline{v}}{\underline{v} \cdot \underline{v}}
\underline{v}
\]
\newcommand{\Determinant}[5]
{
\tikzmath{#5=#1*#4-#2*#3;}
}
\newcommand{\VectorProd}[7]
{
%Cyclic in 123 and 456
\Determinant{#2}{#3}{#5}{#6}{\x}
\Determinant{#3}{#1}{#6}{#4}{\y}
\Determinant{#1}{#2}{#4}{#5}{\z}
\coordinate (#7) at (\x,\y,\z);
}
\newcommand{\DotProduct}[7]
{
\tikzmath{#7=#1*#4+#2*#5+#3*#6;}
}
\newcommand{\SqLength}[4]
{
\tikzmath{#4=#1*#1+#2*#2+#3*#3;}
}
\newcommand{\Projection}[7]
{
\SqLength{#4}{#5}{#6}{\L}
\DotProduct{#1}{#2}{#3}{#4}{#5}{#6}{\D}
\tikzmath{\x=#4*\D/\L;}
\tikzmath{\y=#5*\D/\L;}
\tikzmath{\z=#6*\D/\L;}
\coordinate (#7) at (\x,\y,\z);
}
\tikzstyle{cs}=[lightgray,very thin,-latex]
\tikzstyle{V}=[gray,thin,-latex]
\tikzstyle{P}=[blue,-latex]
\begin{tikzpicture}
\coordinate (OO) at (3,3,3);
\coordinate (O) at (0,0,0);
\coordinate (i) at (1,0,0);
\coordinate (j) at (0,1,0);
\coordinate (k) at (0,0,1);
%Vector p
\tikzmath{\px=2;}
\tikzmath{\py=2;}
\tikzmath{\pz=2;}
\coordinate (P) at (\px,\py,\pz);
%Vector v
\tikzmath{\vx=2;}
\tikzmath{\vy=1;}
\tikzmath{\vz=2;}
\tikzmath{\l=sqrt(\vx*\vx+\vy*\vy+\vz*\vz);}
\tikzmath{\wx=\vx/\l;}
\tikzmath{\wy=\vy/\l;}
\tikzmath{\wz=\vz/\l;}
\coordinate (V) at (\vx,\vy,\vz);
\Projection{\px}{\py}{\pz}{\vx}{\vy}{\vz}{VP}
\tikzmath{\vpx=\x;}
\tikzmath{\vpy=\y;}
\tikzmath{\vpz=\z;}
%Complement vector
\coordinate (VPP) at (\vpx-\px,\vpy-\py,\vpz-\pz);
%p x v
\VectorProd{\px}{\py}{\pz}{\wx}{\wy}{\wz}{PP}
\tikzmath{\ppx=\x;}
\tikzmath{\ppy=\y;}
\tikzmath{\ppz=\z;}
\VectorProd{\ppx}{\ppy}{\ppz}{\wx}{\wy}{\wz}{PPP}
\draw [V] (O) -- (V);
\draw [P] (O) -- (P);
\draw [P] (O) -- (PP);
%\draw [P] (O) -- (PPP);
\node[P] at ($(O)!1.1!(P)$)
{$\underline{p}$};
\node[V] at ($(O)!1.1!(V)$)
{$\underline{v}$};
\node[P] at ($(O)!1.1!(PP)$)
{$\underline{p} \times \underline{v}$};
%\node[P] at ($(O)!1.1!(PPP)$)
% {$(\underline{p} \times \underline{v}) \times \underline{v}$};
\node[orange,-latex] at ($(O)!1.1!(VP)$)
{$\underline{p'}$};
\node[orange,-latex] at ($(O)!1.1!(VPP)$)
{$\underline{p''}$};
\draw [thick,-latex] (O) -- (VP);
\draw [thick,-latex] (O) -- (VPP);
\draw[cs] (OO) -- +(i);
\draw[cs] (OO) -- +(j);
\draw[cs] (OO) -- +(k);
\end{tikzpicture}
|
|
Messages:
0 secs.
|