Skip to content

Instantly share code, notes, and snippets.

@aitatanit
Created November 1, 2016 16:38
Show Gist options
  • Save aitatanit/077c8f39742906e724bab63f28e1d12d to your computer and use it in GitHub Desktop.
Save aitatanit/077c8f39742906e724bab63f28e1d12d to your computer and use it in GitHub Desktop.
EM Wave propagating in the Z direction
% EM Wave propagating in the Z-direction
% Author: Jimmy Touma
% adapted from: Cyril Langlois (http://www.texample.net/tikz/examples/polarizing-microscope/)
\documentclass[11pt]{article}
\usepackage{tikz}
\usetikzlibrary{arrows}
%%%<
\usepackage{verbatim}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{5pt}%
%%%>
\usetikzlibrary{%
decorations.pathreplacing,%
decorations.pathmorphing%
}
\begin{comment}
:Title: EM Wave propagating in the Z-direction
:Tags: Arrows;Decorations;Postactions;Markings;Angles;Optics;Physics;Geometry;Mathematics;EM wave
:Author: Jimmy Touma
:Slug: EM Wave propagating in the Z-direction
\end{comment}
\usetikzlibrary{arrows,shapes,positioning}
\usetikzlibrary{decorations.markings}
\tikzstyle arrowstyle=[scale=1]
\tikzstyle directed=[postaction={decorate,decoration={markings,
mark=at position .65 with {\arrow[arrowstyle]{stealth}}}}]
\tikzstyle reverse directed=[postaction={decorate,decoration={markings,
mark=at position .65 with {\arrowreversed[arrowstyle]{stealth};}}}]
\begin{document}
\pagestyle{empty}
\begin{tikzpicture}
[x={(0.866cm,-0.5cm)}, y={(0.866cm,0.5cm)}, z={(0cm,1cm)}, scale=1.0,
%Option for nice arrows
>=stealth, %
inner sep=0pt, outer sep=2pt,%
axis/.style={thick,->},
wave/.style={thick,color=#1,smooth},
polaroid/.style={fill=black!60!white, opacity=0.3},
]
% Colors
\colorlet{darkgreen}{green!50!black}
\colorlet{lightgreen}{green!80!black}
\colorlet{darkred}{red!50!black}
\colorlet{lightred}{red!80!black}
% Frame
\coordinate (O) at (0, 0, 0);
\draw[axis] (O) -- +(14, 0, 0) node [right] {z};
\draw[axis] (O) -- +(0, 2.5, 0) node [right] {x};
\draw[axis] (O) -- +(0, 0, 2) node [above] {y};
% Magnetic field vectors
\draw[wave=blue, variable=\x,samples at={0,0.25,...,13}]
plot (\x,{-sin(2*\x r)},0)node[anchor=north]{$\vec{B}$};
\foreach \x in{0, 0.25,...,13}
\draw[color=blue,->] (\x,0,0) -- (\x,{-sin(2*\x r)},0);
% Electric field vectors
\draw[wave=darkred, variable=\x,samples at={0,0.25,...,13}]
plot (\x,0,{sin(2*\x r)})node[anchor=south]{$\vec{E}$};
\foreach \x in{0, 0.25,...,13}
\draw[color=darkred,->] (\x,0,0) -- (\x,0,{sin(2*\x r)});
% wavelength
\draw[-] (3.926875,-1, 0) -- (3.926875,-2,0);
\draw[-] (7.068375,-1, 0) -- (7.068375,-2,0);
\draw[<->] (3.926875,-2.1, 0) -- (7.068375,-2.1, 0);
\draw (5.4976249, -2.4, 0) node {$\lambda$};
\end{tikzpicture}
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment