summaryrefslogtreecommitdiff
path: root/graphics/pgf/contrib/simpleoptics/simpleoptics.sty
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-07 03:00:49 +0000
committerNorbert Preining <norbert@preining.info>2019-09-07 03:00:49 +0000
commit7345b8683c7cbeaedf53e992fda0b3fa6141084e (patch)
tree3246f6574e0921c2111b93b76720f54034238185 /graphics/pgf/contrib/simpleoptics/simpleoptics.sty
parentbd3ecfd29a422ad4d7f8f1e119ddc518494e567a (diff)
CTAN sync 201909070300
Diffstat (limited to 'graphics/pgf/contrib/simpleoptics/simpleoptics.sty')
-rw-r--r--graphics/pgf/contrib/simpleoptics/simpleoptics.sty140
1 files changed, 140 insertions, 0 deletions
diff --git a/graphics/pgf/contrib/simpleoptics/simpleoptics.sty b/graphics/pgf/contrib/simpleoptics/simpleoptics.sty
new file mode 100644
index 0000000000..6d24a6d266
--- /dev/null
+++ b/graphics/pgf/contrib/simpleoptics/simpleoptics.sty
@@ -0,0 +1,140 @@
+%%Author: Justin Cawood
+%%License: LPPL 1.3c
+
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{simpleoptics}[2019/09/05 v1.0.0 Simple Optics Package]
+\RequirePackage{tikz}
+
+%\mirror{x}{y}{focal length}{height}
+\newcommand{\mirror}[4]{
+
+
+ \pgfmathsetmacro{\mirrorX}{#1}
+ \pgfmathsetmacro{\mirrorY}{#2}
+
+ \pgfmathsetmacro{\mirrorRadius}{2*#3}
+ \pgfmathsetmacro{\mirrorHeight}{\mirrorY + #4}
+
+ \pgfmathsetmacro{\startAngle}{asin(\mirrorHeight/\mirrorRadius)}
+
+ \draw
+
+ (\mirrorX,\mirrorHeight) arc[start angle=180-\startAngle,delta angle=2*\startAngle,radius=\mirrorRadius]
+
+ ;
+}
+
+%\lens{x}{y}{focal length}{height}{thickness}
+\newcommand{\lens}[5]{
+
+
+ \pgfmathsetmacro{\lensX}{#1}
+ \pgfmathsetmacro{\lensY}{#2}
+ \pgfmathsetmacro{\lensRadius}{2*#3}
+ \pgfmathsetmacro{\lensHeight}{#4}
+ \pgfmathsetmacro{\lensThickness}{#5}
+
+ \pgfmathsetmacro{\lensXright}{\lensX +(0.5*\lensThickness)}
+ \pgfmathsetmacro{\lensXleft}{\lensX-(0.5*\lensThickness)}
+
+ \mirror{\lensXleft}{\lensY}{\lensRadius}{\lensHeight}
+ \mirror{\lensXright}{\lensY}{-\lensRadius}{\lensHeight}
+
+ \draw
+
+ (\lensXleft,\lensHeight) -- (\lensXright,\lensHeight)
+ (\lensXright,-\lensHeight) -- (\lensXleft,-\lensHeight)
+
+ ;
+}
+
+%\biconvexlens{x}{y}{focal length}{height}{thickness}
+\newcommand{\biconvexlens}[5]{
+\lens{#1}{#2}{#3}{#4}{#5}
+}
+
+%\biconcavelens{x}{y}{focal length}{height}{thickness}
+\newcommand{\biconcavelens}[5]{
+\lens{#1}{#2}{-#3}{#4}{#5}
+}
+
+%\concaveconvexlens{x}{y}{focal length}{height}{thickness}
+\newcommand{\concaveconvexlens}[5]{
+ \pgfmathsetmacro{\lensX}{#1}
+ \pgfmathsetmacro{\lensY}{#2}
+ \pgfmathsetmacro{\lensRadius}{-2*#3}
+ \pgfmathsetmacro{\lensHeight}{#4}
+ \pgfmathsetmacro{\lensThickness}{#5}
+
+ \pgfmathsetmacro{\lensXright}{\lensX +(0.5*\lensThickness)}
+ \pgfmathsetmacro{\lensXleft}{\lensX-(0.5*\lensThickness)}
+
+ \mirror{\lensXleft}{\lensY}{\lensRadius}{\lensHeight}
+ \mirror{\lensXright}{\lensY}{\lensRadius}{\lensHeight}
+
+ \draw
+
+ (\lensXleft,\lensHeight) -- (\lensXright,\lensHeight)
+ (\lensXright,-\lensHeight) -- (\lensXleft,-\lensHeight)
+
+ ;
+}
+
+%\convexconcavelens{x}{y}{focal length}{height}{thickness}
+\newcommand{\convexconcavelens}[5]{
+\concaveconvexlens{#1}{#2}{-#3}{#4}{#5}
+}
+
+%\rightplanoconvexlens{x}{y}{focal length}{height}{thickness}
+\newcommand{\rightplanoconvexlens}[5]{
+ \pgfmathsetmacro{\lensX}{#1}
+ \pgfmathsetmacro{\lensY}{#2}
+ \pgfmathsetmacro{\lensRadius}{2*#3}
+ \pgfmathsetmacro{\lensHeight}{#4}
+ \pgfmathsetmacro{\lensThickness}{#5}
+
+ \pgfmathsetmacro{\lensXright}{\lensX +(0.5*\lensThickness)}
+ \pgfmathsetmacro{\lensXleft}{\lensX-(0.5*\lensThickness)}
+
+ \mirror{\lensXleft}{\lensY}{\lensRadius}{\lensHeight}
+
+ \draw
+
+ (\lensXleft,\lensHeight) -- (\lensXright,\lensHeight)
+ (\lensXright,-\lensHeight) -- (\lensXleft,-\lensHeight)
+ (\lensXright,\lensHeight) -- (\lensXright,-\lensHeight)
+
+ ;
+}
+
+%\leftplanoconvexlens{x}{y}{focal length}{height}{thickness}
+\newcommand{\leftplanoconvexlens}[5]{
+\pgfmathsetmacro{\lensX}{#1}
+ \pgfmathsetmacro{\lensY}{#2}
+ \pgfmathsetmacro{\lensRadius}{2*#3}
+ \pgfmathsetmacro{\lensHeight}{#4}
+ \pgfmathsetmacro{\lensThickness}{#5}
+
+ \pgfmathsetmacro{\lensXright}{\lensX +(0.5*\lensThickness)}
+ \pgfmathsetmacro{\lensXleft}{\lensX-(0.5*\lensThickness)}
+
+ \mirror{\lensXright}{\lensY}{-\lensRadius}{\lensHeight}
+
+ \draw
+
+ (\lensXleft,\lensHeight) -- (\lensXright,\lensHeight)
+ (\lensXright,-\lensHeight) -- (\lensXleft,-\lensHeight)
+ (\lensXleft,\lensHeight) -- (\lensXleft,-\lensHeight)
+
+ ;
+}
+
+%\rightplanoconcavelens{x}{y}{focal length}{height}{thickness}
+\newcommand{\rightplanoconcavelens}[5]{
+\rightplanoconvexlens{#1}{#2}{-#3}{#4}{#5}
+}
+
+%\leftplanoconcavelens{x}{y}{focal length}{height}{thickness}
+\newcommand{\leftplanoconcavelens}[5]{
+\leftplanoconvexlens{#1}{#2}{-#3}{#4}{#5}
+} \ No newline at end of file