Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdiffractiongrating.html
More file actions
Latest commit
197 lines (178 loc) · 9.42 KB
/
Copy pathdiffractiongrating.html
File metadata and controls
197 lines (178 loc) · 9.42 KB
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
<!DOCTYPE html>
<htmllang="en">
<head>
<metacharset="UTF-8">
<metaname="viewport" content="width=device-width, initial-scale=1.0">
<title>Diffraction Grating Simulator</title>
<linkrel="icon" type="image/png" href="/favicon.png">
<!-- Font Awesome CDN for icons -->
<linkrel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css" />
<!-- Google Fonts -->
<linkrel="preconnect" href="https://fonts.googleapis.com">
<linkrel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<linkhref="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700&display=swap" rel="stylesheet">
<!-- Link to local and shared styles -->
<linkrel="stylesheet" href="style.css">
<linkrel="stylesheet" href="/header.css">
<linkrel="stylesheet" href="/footer.css">
</head>
<body>
<!-- This div will be populated by layout.js with the shared header content -->
<divid="header-placeholder"></div>
<!-- This H1 block contains the title and info specific to this page -->
<h1>
<!-- Wrapper for title and copyright -->
<divclass="h1-title-group">
<spanclass="h1-title">Diffraction Grating Simulator</span>
<divclass="h1-copyright">
© 2025 <ahref="https://github.com/visuphy" target="_blank" title="Visit VisuPhy on GitHub">VisuPhy</a>
</div>
</div>
<!-- Container for the info links -->
<divclass="h1-info">
<divclass="info-item">
<spanclass="info-label">About and discussion</span>
<divclass="info-content">
<ahref="." target="_blank" title="About and Discussion">
<iclass="fa-solid fa-file-invoice"></i>
</a>
</div>
</div>
<divclass="info-item">
<spanclass="info-label">Source</span>
<divclass="info-content">
<ahref="https://github.com/visuphy/DiffractionGrating" target="_blank" title="View Source on GitHub">
<iclass="fab fa-github"></i>
</a>
</div>
</div>
<divclass="info-item">
<spanclass="info-label">Original Author</span>
<divclass="info-content">
<ahref="https://github.com/Hussein-Tofaili" target="_blank">Hussein-Tofaili</a>
</div>
</div>
<divclass="info-item">
<spanclass="info-label">Other Contributors</span>
<divclass="info-content">
<spanstyle="color: #555;">none</span>
</div>
</div>
</div>
</h1>
<!-- Main content container, now holding the simulator -->
<divclass="main-content">
<pclass="page-description">Simulates the diffraction pattern of light from a reflective or transmissive grating.</p>
<mainclass="app-layout">
<divclass="controls-container">
<!-- First Row: Incident Beam Properties -->
<divclass="control-row">
<divclass="row-title">Incident Beam Properties</div>
<divclass="control-group">
<label>Light Type</label>
<divclass="radio-group">
<div>
<inputtype="radio" id="monochromatic" name="lightType" value="monochromatic" checked>
<labelfor="monochromatic">Monochromatic</label>
</div>
<div>
<inputtype="radio" id="whiteLight" name="lightType" value="whiteLight">
<labelfor="whiteLight">White Light</label>
</div>
</div>
</div>
<divid="monoControls" class="mono-controls-group">
<divclass="control-group">
<divclass="label-input-group">
<labelfor="wavelength">Wavelength (λ):</label>
<inputtype="number" id="wavelengthInput" value="550" step="1" class="value-input">
<labelfor="wavelengthInput">nm</label>
</div>
<inputtype="range" id="wavelength" min="380" max="750" value="550">
<divclass="input-group">
<inputtype="number" id="minWavelength" value="380">
<label>to</label>
<inputtype="number" id="maxWavelength" value="750">
<buttonid="updateWavelengthRange">Set</button>
</div>
</div>
<divclass="control-group">
<divclass="label-input-group">
<labelfor="bandwidth">Bandwidth (Δλ):</label>
<inputtype="number" id="bandwidthInput" value="0" step="1" class="value-input">
<labelfor="bandwidthInput">nm</label>
</div>
<inputtype="range" id="bandwidth" min="0" max="100" value="0" step="1">
</div>
</div>
<divclass="control-group">
<divclass="label-input-group">
<labelfor="angle">Angle of Incidence (α):</label>
<inputtype="number" id="angleInput" value="30" step="1" class="value-input">
<labelfor="angleInput">°</label>
</div>
<inputtype="range" id="angle" min="-90" max="90" value="30">
</div>
</div>
<!-- Second Row: Grating Properties -->
<divclass="control-row">
<divclass="row-title">Grating Properties</div>
<divclass="control-group">
<divclass="label-input-group">
<labelfor="gratingSpacing">Grating Spacing (d):</label>
<inputtype="number" id="gratingSpacingInput" value="2000" step="10" class="value-input">
<labelfor="gratingSpacingInput">nm</label>
</div>
<inputtype="range" id="gratingSpacing" min="500" max="5000" value="2000">
</div>
<divclass="control-group">
<divclass="label-input-group">
<labelfor="grooveDensity">Groove Density:</label>
<inputtype="number" id="grooveDensityInput" value="500" step="10" class="value-input">
<labelfor="grooveDensityInput">l/mm</label>
</div>
<inputtype="range" id="grooveDensity" min="200" max="2000" value="500">
</div>
<divclass="control-group">
<divclass="label-input-group">
<labelfor="orders">Diffraction Orders (±m):</label>
<inputtype="number" id="ordersInput" value="3" step="1" class="value-input">
</div>
<inputtype="range" id="orders" min="1" max="20" value="3">
</div>
<divclass="control-group">
<divclass="label-input-group">
<labelfor="grooves">Illuminated Grooves (N):</label>
<inputtype="number" id="groovesInput" value="1000" step="100" class="value-input">
</div>
<inputtype="range" id="grooves" min="100" max="20000" value="1000" step="100">
</div>
<divclass="control-group">
<label>Grating Type</label>
<divclass="radio-group">
<div>
<inputtype="radio" id="reflective" name="gratingType" value="reflective" checked>
<labelfor="reflective">Reflective</label>
</div>
<div>
<inputtype="radio" id="transmissive" name="gratingType" value="transmissive">
<labelfor="transmissive">Transmissive</label>
</div>
</div>
</div>
</div>
</div>
<divclass="canvas-wrapper">
<canvasid="simulationCanvas" width="800" height="600"></canvas>
<pclass="canvas-hint">Hint: Click on a diffraction order (in monochromatic mode) to view its properties.</p>
<pclass="canvas-hint">The sign of the diffraction orders and the sign of angles depends on your convention. </p>
</div>
</main>
</div>
<!-- This div will be populated by layout.js with the shared footer content -->
<divid="footer-placeholder"></div>
<!-- Scripts -->
<scriptsrc="/layout.js" defer></script>
<scriptsrc="script.js"></script>
</body>
</html>