Skip to content

Instantly share code, notes, and snippets.

@wchargin
Created February 9, 2016 00:13
Show Gist options
  • Save wchargin/f458a4f353464537cd85 to your computer and use it in GitHub Desktop.
Save wchargin/f458a4f353464537cd85 to your computer and use it in GitHub Desktop.
\documentclass[tikz,border=24pt]{standalone}
\usetikzlibrary{patterns,calc,decorations.markings,arrows}
\usepackage{tkz-euclide}
\usetkzobj{all}
\tikzset{
ray/.style={
dashed,
},
ray segment/.style={
ray,
postaction=decorate,
decoration={
markings,
mark=at position .5 with {\arrow[thick]{stealth}}
}
},
ray terminator/.style={
ray,
-stealth,
},
}
\begin{document}
\begin{tikzpicture}[scale=6]
% Coordinate system origin
\tkzDefPoint(0,0){O};
% Source of the ray
\tkzDefPoint(0.9063,0.8452){start};
% Point of intersection of the ray with the first mirror
\tkzDefPoint(0,0.4226){P};
\tkzDefPoint(-0.1,0.4226){Pleft};
\tkzDefPoint(0.25,0.4226){Pright};
\tkzDefMidPoint(O,P);
\tkzGetPoint{MA};
% Intersection of the ray with the second mirror, plus normals
\tkzDefPoint(0.9063,0){Q};
\tkzDefPoint(0.9063,0.25){Qup};
\tkzDefMidPoint(O,Q);
\tkzGetPoint{MB};
% Extensions of the axis
\tkzDefPoint(0,1){vertical};
\tkzDefPoint(1.5,0){horizontal};
% Intersection of the ray with the water, plus normals
\tkzDefPoint(1.5,0.2768){hit};
\tkzDefPoint(1.2,0.2768){hitleft};
\tkzDefPoint(1.8,0.2768){hitright};
% Refraction vector of the ray
\tkzDefPoint(1.8865,0.3797){refract};
% Quadrilateral delimiters for the water
\tkzDefPoint(1.5,0.75){waterne};
\tkzDefPoint(2,0.75){waternw};
\tkzDefPoint(2,0){watersw};
% Coordinates and water drawing
\tkzDrawSegments(O,vertical O,horizontal);
\tkzLabelPoint[right](vertical){air ($n = 1$)};
\tkzFillPolygon[blue,fill opacity=0.15](horizontal,waterne,waternw,watersw);
\tkzLabelPoint[above right](waterne){water ($n' = 1.33$)};
% Mirror drawing
\tkzDrawSegments[ultra thick](O,P O,Q);
\tkzLabelPoint[left](MA){Mirror~A};
\tkzLabelPoint[below](MB){Mirror~B};
% Normal drawing
\tkzDrawSegment[dotted](Pleft,Pright);
\tkzDrawSegment[dotted](Q,Qup);
\tkzDrawSegment[dotted](hitleft,hitright);
% Intersection points
\tkzLabelPoint[above left](P){$P$};
\tkzLabelPoint[below](Q){$Q$};
\tkzLabelPoint[above left](hit){$R$};
% Light ray drawing
\tkzDrawSegments[ray segment](start,P P,Q Q,hit);
\tkzDrawSegment[ray terminator](hit,refract);
% The following angle commands extend the bounding box unnecessarily
% (by calculating the extension of the relevant arcs to full circles).
% Save the current bounding box and fix it.
\useasboundingbox (current bounding box.north east) rectangle (current bounding box.south west);
%% All theta-equivalent angles
\tkzMarkAngles[fill=yellow,fill opacity=0.25,size=0.2,mark=|](Pright,P,start Q,P,Pright P,Q,O horizontal,Q,hit hitleft,hit,Q);
\tkzLabelAngles[pos=0.25](Pright,P,start Q,P,Pright P,Q,O horizontal,Q,hit){$\theta$};
%%% (this one's weird and inverted for some reason)
\tkzLabelAngles[pos=-0.25](hitleft,hit,Q){$\theta$};
%% All phi-equivalent angles
\tkzMarkAngles[fill=red,fill opacity=0.25,size=0.15,mark=||](O,P,Q Q,hit,horizontal Qup,Q,P hit,Q,Qup);
\tkzLabelAngles[pos=0.225,mark=||](O,P,Q Q,hit,horizontal Qup,Q,P hit,Q,Qup){$\phi$};
%% The desired angle
\tkzMarkAngle[fill=blue,fill opacity=0.25,size=0.15](hitright,hit,refract);
\tkzLabelAngle[pos=0.3](hitright,hit,refract){$\theta'$};
%% All right angles
\tkzMarkRightAngles[size=0.050](Q,O,P watersw,horizontal,waterne);
% Draw intersection points last (otherwise segments are above)
\tkzDrawPoints(P,Q,hit);
\end{tikzpicture}
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment