2. Optics tikz๏
2.1. Reflection๏
Reflection of light is shown below.
1\documentclass[border=3pt,tikz]{standalone}
2\usetikzlibrary{calc}
3
4
5\begin{document}
6\begin{tikzpicture}
7 % Draw the mirror
8 \draw[ultra thick] (0,0) -- (6,0);
9
10 % Draw the normal
11 \draw[dashed] (3,0) -- (3,3);
12
13 % Draw the incident ray
14 \draw[red,->] (1.5,3) -- (3,0);
15
16 % Draw the reflected ray
17 \draw[blue,->] (3,0) -- (4.5,3);
18
19 % Draw the angle arcs
20 \draw[red] (3,0.375) arc (90:120:0.375);
21 \draw[blue] (3,0.375) arc (90:60:0.375);
22 % Label the normal
23 \node[] at (3,2.6) {normal};
24
25 % Label the incident ray
26 \node[red,left] at (2.25,1.5) {incident ray};
27
28 % Label the reflected ray
29 \node[blue,right] at (3.75,1.5) {reflected ray};
30
31 % Label the angles
32 \node[red] at ($(3,0)+(120:0.6)+(0.0,0.8)$) {$\theta_i$};
33 \node[blue] at ($(3,0)+(60:0.6)+(-0.0,0.8)$) {$\theta_r$};
34\end{tikzpicture}
35\end{document}
36
2.2. Total internal Reflection๏
Total internal Reflection of light is shown below.
1\documentclass
2[border=3pt,tikz]{standalone}
3\usetikzlibrary{arrows,arrows.meta}
4\usetikzlibrary{calc}
5\usetikzlibrary{decorations.markings}
6\usetikzlibrary{angles,quotes} % for pic (angle labels)
7%\usepackage{tkz-euclide} % for \tkzMarkRightAngle
8%\usetkzobj{all}
9\tikzset{>=latex} % for LaTeX arrow head
10
11\colorlet{myblue}{blue!80!black}
12\colorlet{mydarkblue}{blue!35!black}
13\colorlet{myred}{black!50!red}
14\colorlet{glasscol}{blue!10}
15\colorlet{Ecol}{orange!90!black}
16\tikzstyle{myarr}=[-{Latex[length=3,width=2]}]
17\tikzstyle{Evec}=[Ecol,{Latex[length=2.8,width=2.5]}-{Latex[length=2.8,width=2.5]},line width=0.6]
18\tikzstyle{glass}=[top color=glasscol!88!black,bottom color=glasscol,shading angle=0]
19%\tikzstyle{glass}=[top color=glasscol!88!black,bottom color=glasscol,middle color=glasscol!98!black,shading angle=0]
20\tikzset{
21 light beam/.style={thick,myblue,decoration={markings,
22 mark=at position #1 with {\arrow{latex}}},
23 postaction={decorate}},
24 light beam/.default=0.5}
25
26\newcommand\rightAngle[4]{
27 \pgfmathanglebetweenpoints{\pgfpointanchor{#2}{center}}{\pgfpointanchor{#3}{center}}
28 \coordinate (tmpRA) at ($(#2)+(\pgfmathresult+45:#4)$);
29 \draw[white,line width=0.6] ($(#2)!(tmpRA)!(#1)$) -- (tmpRA) -- ($(#2)!(tmpRA)!(#3)$);
30 \draw[blue!40!black] ($(#2)!(tmpRA)!(#1)$) -- (tmpRA) -- ($(#2)!(tmpRA)!(#3)$);
31}
32
33
34\begin{document}
35
36% INTERNAL REFLECTION: critical
37\begin{tikzpicture}
38 \def\L{4.0}
39 \def\l{2.3}
40 \def\t{0.5}
41 \def\h{2.0}
42 \def\f{0.5}
43 \def\na{1.0} % air
44 \def\ng{1.5} % glass
45 \def\angg{41.804} % asin(1/1.5)*180/pi
46 \def\anga{asin(\ng/\na*sin(\angg))}
47 \coordinate (O) at (0,0);
48 \coordinate (I) at (-90-\angg:\l);
49 \coordinate (M) at (-90+\angg:\l);
50 \coordinate (F) at ({90-\anga}:0.8*\l);
51 \coordinate (L) at (-\f*\L,0);
52 \coordinate (R) at ({(1-\f)*\L},0);
53 \coordinate (T) at (0,0.7*\h);
54 \coordinate (B) at (0,-\h);
55
56 % MEDIUM
57 % \fill[glass] (L) rectangle++ (\L,-\t);
58 % \fill[glasscol] (-\f*\L,-0.99*\t) rectangle ({1-\f)*\L},-\h);
59 %\fill[glass] (L) rectangle (\L/2,-\h);
60 \draw[] (L) -- (R);
61 \node[above right=1] at (L) {$n_2$};
62 \node[below right=1] at (L) {$n_1>n_2$};
63 \node[above left=1] at (R) {$air$};
64 \node[below left=1] at (R) {$water$};
65
66
67 % LINES
68 \draw[dashed] (T) -- (B);
69 \draw[light beam={0.48}] (I) -- (O);
70 \draw[light beam={0.65},line width=0.6] (O) -- (M);
71 \draw[light beam={0.60},line width=0.2] (O) -- (F);
72
73 % ANGLES
74 \draw pic["$\theta_1$",draw=black,angle radius=17,angle eccentricity=1.3] {angle = I--O--B}; %\contour{white}{
75 \draw pic["$\theta_\mathrm{r}$",draw=black,angle radius=22,angle eccentricity=1.3] {angle = B--O--M};
76 \draw pic["$\theta_2$",draw=black,angle radius=12,angle eccentricity=1.5] {angle = F--O--T};
77 \rightAngle{L}{O}{T}{0.3}
78
79\end{tikzpicture}
80
81\end{document}
2.3. Refraction๏
Refraction of light is shown below.
1\documentclass[11pt]{standalone}
2\usepackage{tikz}
3\usetikzlibrary{arrows,shapes,positioning}
4\usetikzlibrary{decorations.markings}
5\tikzstyle arrowstyle=[scale=1]
6\tikzstyle directed=[postaction={decorate,decoration={markings,
7 mark=at position .65 with {\arrow[arrowstyle]{stealth}}}}]
8\tikzstyle reverse directed=[postaction={decorate,decoration={markings,
9 mark=at position .65 with {\arrowreversed[arrowstyle]{stealth};}}}]
10\begin{document}
11\begin{tikzpicture}
12
13 % define coordinates
14 \coordinate (O) at (0,0) ;
15 \coordinate (normal_top) at (0,4) ;
16 \coordinate (normal_bottom) at (0,-4) ;
17 \coordinate (boundary_left) at (-4,0) ;
18 \coordinate (boundary_right) at (4,0) ;
19
20 % boundary
21 \draw[black] (boundary_left) -- (boundary_right);
22 \node[above left] at (boundary_right) {Air};
23 \node[below left] at (boundary_right) {Water};
24
25 % normal
26 \draw[dash pattern=on5pt off3pt] (normal_top) -- (normal_bottom) ;
27 \node[left] at (normal_top) {Normal};
28
29 % rays
30 \draw[red,ultra thick,reverse directed] (O) -- (130:5.2);
31 \draw[blue,directed,ultra thick] (O) -- (-70:4.24);
32
33 % angles
34 \draw (0,1) arc (90:130:1);
35 \draw (0,-1.4) arc (270:290:1.4) ;
36 \node[] at (280:1.8) {$\theta_{2}$};
37 \node[] at (110:1.4) {$\theta_{1}$};
38\end{tikzpicture}
39\end{document}
1\documentclass[border=3pt,tikz]{standalone}
2\usetikzlibrary{arrows,arrows.meta}
3\usetikzlibrary{calc}
4\usetikzlibrary{decorations.markings}
5\usetikzlibrary{angles,quotes} % for pic (angle labels)
6%\usepackage{tkz-euclide} % for \tkzMarkRightAngle
7%\usetkzobj{all}
8\tikzset{>=latex} % for LaTeX arrow head
9
10\colorlet{myblue}{blue!80!black}
11\colorlet{mydarkblue}{blue!35!black}
12\colorlet{myred}{black!50!red}
13\colorlet{glasscol}{blue!10}
14\colorlet{Ecol}{orange!90!black}
15\tikzstyle{myarr}=[-{Latex[length=3,width=2]}]
16\tikzstyle{Evec}=[Ecol,{Latex[length=2.8,width=2.5]}-{Latex[length=2.8,width=2.5]},line width=0.6]
17\tikzstyle{glass}=[top color=glasscol!88!black,bottom color=glasscol,shading angle=0]
18%\tikzstyle{glass}=[top color=glasscol!88!black,bottom color=glasscol,middle color=glasscol!98!black,shading angle=0]
19\tikzset{
20 light beam/.style={thick,myblue,decoration={markings,
21 mark=at position #1 with {\arrow{latex}}},
22 postaction={decorate}},
23 light beam/.default=0.5}
24
25\newcommand\rightAngle[4]{
26 \pgfmathanglebetweenpoints{\pgfpointanchor{#2}{center}}{\pgfpointanchor{#3}{center}}
27 \coordinate (tmpRA) at ($(#2)+(\pgfmathresult+45:#4)$);
28 \draw[white,line width=0.6] ($(#2)!(tmpRA)!(#1)$) -- (tmpRA) -- ($(#2)!(tmpRA)!(#3)$);
29 \draw[blue!40!black] ($(#2)!(tmpRA)!(#1)$) -- (tmpRA) -- ($(#2)!(tmpRA)!(#3)$);
30}
31
32
33\begin{document}
34
35% INTERNAL REFLECTION: almost
36\begin{tikzpicture}
37 \def\L{4.0}
38 \def\l{2.3}
39 \def\t{0.5}
40 \def\h{2.0}
41 \def\f{0.5}
42 \def\na{1.0} % air
43 \def\ng{1.5} % glass
44 \def\angg{40} % asin(1/1.5)*180/pi
45 \def\anga{asin(\ng/\na*sin(\angg))}
46 \coordinate (O) at (0,0);
47 \coordinate (I) at (-90-\angg:\l);
48 \coordinate (M) at (-90+\angg:\l);
49 \coordinate (F) at ({90-\anga}:0.8*\l);
50 \coordinate (L) at (-\f*\L,0);
51 \coordinate (R) at ({(1-\f)*\L},0);
52 \coordinate (T) at (0,0.7*\h);
53 \coordinate (B) at (0,-\h);
54
55 % MEDIUM
56 % \fill[glass] (L) rectangle++ (\L,-\t); % glass gradient
57 % \fill[glasscol] (-\f*\L,-0.99*\t) rectangle ({1-\f)*\L},-\h);
58 %\fill[glass] (L) rectangle (\L/2,-\h);
59 \draw[] (L) -- (R);
60 \node[above right=1] at (L) {$n_2$};
61 \node[below right=1] at (L) {$n_1>n_2$};
62 \node[above left=1] at (R) {$air$};
63 \node[below left=1] at (R) {$water$};
64
65 % LINES
66 \draw[dashed] (T) -- (B);
67 \draw[light beam={0.48}] (I) -- (O);
68 \draw[light beam={0.65},line width=0.5] (O) -- (M);
69 \draw[light beam={0.60},line width=0.5] (O) -- (F);
70
71 % ANGLES
72 \draw pic["$\theta_1$",draw=black,angle radius=17,angle eccentricity=1.3] {angle = I--O--B}; %\contour{white}{
73 \draw pic["$\theta_\mathrm{r}$",draw=black,angle radius=22,angle eccentricity=1.3] {angle = B--O--M};
74 \draw pic["$\theta_2$",draw=black,angle radius=12,angle eccentricity=1.5] {angle = F--O--T};
75 \rightAngle{L}{O}{T}{0.3}
76
77\end{tikzpicture}
78
79
80\end{document}