From 7a8ac022f12717cefa5fd991e95b2d7f2742a4c7 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Fri, 6 Sep 2019 21:12:46 +0000 Subject: simpleoptics (6sep19) git-svn-id: svn://tug.org/texlive/trunk@52038 c570f23f-e606-0410-a88d-b1316a301751 --- .../tex/latex/simpleoptics/simpleoptics.sty | 140 +++++++++++++++++++++ 1 file changed, 140 insertions(+) create mode 100644 Master/texmf-dist/tex/latex/simpleoptics/simpleoptics.sty (limited to 'Master/texmf-dist/tex/latex/simpleoptics') diff --git a/Master/texmf-dist/tex/latex/simpleoptics/simpleoptics.sty b/Master/texmf-dist/tex/latex/simpleoptics/simpleoptics.sty new file mode 100644 index 00000000000..6d24a6d266f --- /dev/null +++ b/Master/texmf-dist/tex/latex/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 -- cgit v1.2.3