-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6b67811
commit d8ef8ac
Showing
6 changed files
with
132 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Sim 3 - Interference Wavefront</title> | ||
<style> | ||
canvas { | ||
background-color: black; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<canvas width="1000px" height="500px"></canvas> | ||
|
||
<div class="frequency"> | ||
<input type="range" min="0.2" max="1" step="0.1" value="1" class="slider" id="frequencyInput"> | ||
Frequency: <span id="frequencyValue">1.0</span> Hz | ||
</div> | ||
<div class="amplitude"> | ||
<input type="range" min="0.1" max="0.3" step="0.05" value="0.2" class="slider" id="amplitudeInput"> | ||
Amplitude: <span id="amplitudeValue">0.2</span> | ||
</div> | ||
|
||
Path Difference = <span id="pathDifference">0</span>λ | ||
<br> | ||
Phase Difference Δϕ = <span id="phaseDifference">0</span>π | ||
<br> | ||
<span id="interference">Constructive Interference!</span> | ||
|
||
<script type="module" src="static/js/sim3.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { WaveFrontDisplay } from "./shared/waves.js"; | ||
|
||
const fps = 60; | ||
|
||
const cvs = document.querySelector('canvas'); | ||
const c = cvs.getContext('2d'); | ||
const frequencyInput = document.getElementById("frequencyInput"); | ||
const amplitudeInput = document.getElementById("amplitudeInput"); | ||
const pathDifference = document.getElementById("pathDifference"); | ||
const phaseDifference = document.getElementById("phaseDifference"); | ||
const interference = document.getElementById("interference"); | ||
|
||
const waveDisplay = new WaveFrontDisplay(cvs, c); | ||
|
||
const animate = () => { | ||
c.clearRect(0, 0, cvs.width, cvs.height); | ||
waveDisplay.update(); | ||
|
||
setTimeout(() => { | ||
requestAnimationFrame(animate); | ||
}, 1000 / fps); | ||
|
||
} | ||
|
||
frequencyInput.oninput = () => { | ||
document.getElementById("frequencyValue").innerText = frequencyInput.value; | ||
simulation.setFrequency(frequencyInput.value); | ||
} | ||
|
||
amplitudeInput.oninput = () => { | ||
document.getElementById("amplitudeValue").innerText = amplitudeInput.value; | ||
simulation.setAmplitude(amplitudeInput.value); | ||
} | ||
|
||
animate(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters