1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
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}
}
|