Compare commits
6 Commits
bcdc8b1baa
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 1b45c515d4 | |||
| ebd2ba2e51 | |||
| e78af26734 | |||
| 42d69b6ce4 | |||
| 8d42cda17f | |||
| 5010c30886 |
66
README.md
66
README.md
@ -1 +1,65 @@
|
|||||||
# TODO
|
# Simulateur d'Interféromètre de Michelson
|
||||||
|
|
||||||
|
Une simulation interactive temps réel et physiquement réaliste de l'interféromètre de Michelson. Ce projet permet de visualiser les figures d'interférences (franges et anneaux) en manipulant les composants optiques (miroirs, source lumineuse, milieu).
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## Fonctionnalités
|
||||||
|
|
||||||
|
### Contrôle et Simulation
|
||||||
|
* **Miroir Mobile (M1) :** Translation et inclinaison sur deux axes.
|
||||||
|
* **Sources Lumineuses :**
|
||||||
|
* Spectre (380nm - 780nm).
|
||||||
|
* Gestion de **sources polychromatiques** (ajout/suppression de longueurs d'onde multiples).
|
||||||
|
* Rendu additif des couleurs.
|
||||||
|
* **Milieux dispersifs :** Ajout d'une cuve de gaz avec indice de réfraction variable n pour visualiser le déphasage.
|
||||||
|
|
||||||
|
### Performance & Rendu
|
||||||
|
* **Rendu GPU :** Calcul des interférences par **shader (GLSL)** pour des performances élevées.
|
||||||
|
* **Interface UI :** `raygui`.
|
||||||
|
* **Optimisation :** Sélecteur de **FPS Cible** (30, 60, 120, 144, Illimité).
|
||||||
|
* **Vues :** Schéma optique 2D + Vue "Écran".
|
||||||
|
|
||||||
|
## Installation et Compilation
|
||||||
|
|
||||||
|
### Prérequis
|
||||||
|
* **[Raylib](https://www.raylib.com/)**
|
||||||
|
* **[Emscripten](https://github.com/emscripten-core/emscripten/)**
|
||||||
|
|
||||||
|
### Compilation (Linux / Mac)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
make
|
||||||
|
make run
|
||||||
|
```
|
||||||
|
ou
|
||||||
|
```bash
|
||||||
|
gcc main.c -o michelson -lraylib -lGL -lm -lpthread -ldl -lrt -lX11
|
||||||
|
./michelson
|
||||||
|
```
|
||||||
|
|
||||||
|
### Version Web (Emscripten)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
make web
|
||||||
|
make webrun
|
||||||
|
```
|
||||||
|
ou
|
||||||
|
```bash
|
||||||
|
mkdir -p web && emcc -o web/index.html main.c -Os -Wall -std=c99 -DPLATFORM_WEB -s USE_GLFW=3 -s ALLOW_MEMORY_GROWTH=1 -I. --shell-file minshell.html --preload-file glsl/michelson_web.frag raylib/libraylib.web.a
|
||||||
|
```
|
||||||
|
|
||||||
|
## Contrôles Utilisateur
|
||||||
|
|
||||||
|
| Action | Commande |
|
||||||
|
| --- | --- |
|
||||||
|
| **Plein Écran** | Touche `F` |
|
||||||
|
| **Sélectionner une longueur d'onde** | `Clic Gauche` sur le spectre |
|
||||||
|
| **Ajouter une longueur d'onde** | `Clic Droit` sur une zone vide du spectre |
|
||||||
|
| **Supprimer une longueur d'onde** | `Clic Droit` sur une ligne existante |
|
||||||
|
| **Régler les miroirs** | Sliders / boutons `+` / `-` |
|
||||||
|
| **Précision / Vitesse** | Maintenir `Shift` |
|
||||||
|
|
||||||
|
## Physique du projet
|
||||||
|
|
||||||
|
Calcule de l'intensité lumineuse en tout point de l'écran en se basant sur la différence de marche.
|
||||||
|
|||||||
@ -47,27 +47,23 @@ void main() {
|
|||||||
float relX = (pixelX - center.x) * zoom;
|
float relX = (pixelX - center.x) * zoom;
|
||||||
float relY = (pixelY - center.y) * zoom;
|
float relY = (pixelY - center.y) * zoom;
|
||||||
|
|
||||||
|
|
||||||
// r^2
|
// r^2
|
||||||
float radiusSq = relX * relX + relY * relY;
|
float radiusSq = relX * relX + relY * relY;
|
||||||
|
|
||||||
// Diff de marche lamme d'air 2 * e cos(i) mais petits angles => cos(i) ~ 1 - i^2/2 mais i ~ r/f et r^2 = x^2 + y^2
|
|
||||||
float ringFactorBase = radiusSq * 0.065;
|
|
||||||
|
|
||||||
// Diff de marche du au coin d'air
|
// Diff de marche du au coin d'air
|
||||||
float wDelta = (relX * angleM1 + relY * angleM1_Y) * 200.0;
|
float wDelta = (relX * angleM1 + relY * angleM1_Y) * 200.0;
|
||||||
|
|
||||||
float currDeltaBase = deltaLnm + wDelta;
|
float cosFactor = 1.0 - (radiusSq * 0.000004);
|
||||||
|
|
||||||
float currDelta = deltaLnm - ringFactorBase + wDelta;
|
float currDelta = (deltaLnm * cosFactor) + wDelta;
|
||||||
|
|
||||||
vec3 accumColor = vec3(0.0);
|
vec3 accumColor = vec3(0.0);
|
||||||
|
|
||||||
for(int i = 0; i < 10; i++) {
|
for(int i = 0; i < 10; i++) {
|
||||||
if (i >= lambdasCount) break;
|
if (i >= lambdasCount) break;
|
||||||
float l = lambdas[i];
|
float l = lambdas[i];
|
||||||
|
if (l < 1.0) l = 550.0;
|
||||||
vec3 baseColorVec = WavelengthToRGB(l);
|
vec3 baseColorVec = WavelengthToRGB(l);
|
||||||
float currDelta = currDeltaBase - ringFactorBase;
|
|
||||||
float K = PI / l;
|
float K = PI / l;
|
||||||
float phase = currDelta * K;
|
float phase = currDelta * K;
|
||||||
float intensity = cos(phase);
|
float intensity = cos(phase);
|
||||||
|
|||||||
@ -45,9 +45,12 @@ void main() {
|
|||||||
float relY = (pixelY - center.y) * zoom;
|
float relY = (pixelY - center.y) * zoom;
|
||||||
|
|
||||||
float radiusSq = relX * relX + relY * relY;
|
float radiusSq = relX * relX + relY * relY;
|
||||||
float ringFactorBase = radiusSq * 0.065;
|
|
||||||
float wDelta = (relX * angleM1 + relY * angleM1_Y) * 200.0;
|
float wDelta = (relX * angleM1 + relY * angleM1_Y) * 200.0;
|
||||||
float currDeltaBase = deltaLnm + wDelta;
|
|
||||||
|
float cosFactor = 1.0 - (radiusSq * 0.000004);
|
||||||
|
|
||||||
|
float currDelta = (deltaLnm * cosFactor) + wDelta;
|
||||||
|
|
||||||
vec3 accumColor = vec3(0.0);
|
vec3 accumColor = vec3(0.0);
|
||||||
|
|
||||||
@ -55,15 +58,16 @@ void main() {
|
|||||||
if (i >= lambdasCount) break;
|
if (i >= lambdasCount) break;
|
||||||
|
|
||||||
float l = lambdas[i];
|
float l = lambdas[i];
|
||||||
|
|
||||||
if (l < 1.0) l = 550.0;
|
if (l < 1.0) l = 550.0;
|
||||||
|
|
||||||
vec3 baseColorVec = WavelengthToRGB(l);
|
vec3 baseColorVec = WavelengthToRGB(l);
|
||||||
float currDelta = currDeltaBase - ringFactorBase;
|
|
||||||
float K = PI / l;
|
float K = PI / l;
|
||||||
float phase = currDelta * K;
|
float phase = currDelta * K;
|
||||||
|
|
||||||
float intensity = cos(phase);
|
float intensity = cos(phase);
|
||||||
intensity = intensity * intensity;
|
intensity = intensity * intensity;
|
||||||
|
|
||||||
accumColor += baseColorVec * intensity;
|
accumColor += baseColorVec * intensity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
BIN
img/screenshot.png
Normal file
BIN
img/screenshot.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 179 KiB |
18
main.c
18
main.c
@ -377,20 +377,24 @@ void DrawControlPanel(Michelson *mic) {
|
|||||||
int rows = (mic->lambdasCount + cols - 1) / cols;
|
int rows = (mic->lambdasCount + cols - 1) / cols;
|
||||||
startY += (rows * (btnH + 5)) + 20;
|
startY += (rows * (btnH + 5)) + 20;
|
||||||
|
|
||||||
|
// Pos M1 M2 (d1 - d2)
|
||||||
// Pos M1
|
|
||||||
startY += 0;
|
startY += 0;
|
||||||
DrawText(TextFormat("Position M1 : %.2f um", mic->d1), startX, startY, 20, ORANGE);
|
float currentDiff = mic->d1 - mic->d2;
|
||||||
|
DrawText(TextFormat("Distance M1 - M2: %.2f um", currentDiff), startX, startY, 20, ORANGE);
|
||||||
|
|
||||||
// Pas des + et -
|
// Pas des + et -
|
||||||
float stepD1 = speedMode ? 0.05f : 0.006f;
|
float stepD1 = speedMode ? 0.05f : 0.006f;
|
||||||
|
|
||||||
if (GuiButtonRepeat((Rectangle){startX, startY + 30, btnSize, 25}, "-", shouldRepeat)) mic->d1 -= stepD1;
|
if (GuiButtonRepeat((Rectangle){startX, startY + 30, btnSize, 25}, "-", shouldRepeat)) mic->d1 -= stepD1;
|
||||||
GuiSlider((Rectangle){startX + btnSize + 5, startY + 30, sliderWidth - 75, 25}, NULL, NULL, &mic->d1, 100, 600);
|
|
||||||
|
float sliderVal = currentDiff;
|
||||||
|
GuiSlider((Rectangle){startX + btnSize + 5, startY + 30, sliderWidth - 75, 25}, NULL, NULL, &sliderVal, -100.0f, 100.0f);
|
||||||
|
mic->d1 = mic->d2 + sliderVal;
|
||||||
|
|
||||||
|
if (GuiButtonRepeat((Rectangle){startX, startY + 30, btnSize, 25}, "-", shouldRepeat)) mic->d1 -= stepD1;
|
||||||
if (GuiButtonRepeat((Rectangle){startX + btnSize + sliderWidth - 65, startY + 30, btnSize, 25}, "+", shouldRepeat)) mic->d1 += stepD1;
|
if (GuiButtonRepeat((Rectangle){startX + btnSize + sliderWidth - 65, startY + 30, btnSize, 25}, "+", shouldRepeat)) mic->d1 += stepD1;
|
||||||
if (GuiButton((Rectangle){startX + contentWidth - 60, startY + 30, 60, 25}, "Egal")) mic->d1 = mic->d2;
|
if (GuiButton((Rectangle){startX + contentWidth - 60, startY + 30, 60, 25}, "Egal")) mic->d1 = mic->d2;
|
||||||
|
|
||||||
|
|
||||||
// Angle M1 X
|
// Angle M1 X
|
||||||
startY += 90;
|
startY += 90;
|
||||||
DrawText(TextFormat("Inclinaison M1: %.3f deg", mic->angleM1), startX, startY, 20, ORANGE);
|
DrawText(TextFormat("Inclinaison M1: %.3f deg", mic->angleM1), startX, startY, 20, ORANGE);
|
||||||
@ -444,7 +448,7 @@ void DrawControlPanel(Michelson *mic) {
|
|||||||
|
|
||||||
float refLambda = mic->lambdas[mic->selectedLambdaIndex];
|
float refLambda = mic->lambdas[mic->selectedLambdaIndex];
|
||||||
float p = (delta * 1000.0f) / refLambda;
|
float p = (delta * 1000.0f) / refLambda;
|
||||||
DrawText(TextFormat("Ordre p (sel) = %.2f", p), startX, startY + 65, 20, WHITE);
|
DrawText(TextFormat("Ordre p = %.2f", p), startX, startY + 65, 20, WHITE);
|
||||||
|
|
||||||
// FPS
|
// FPS
|
||||||
int bottomY = GetScreenHeight() - 40;
|
int bottomY = GetScreenHeight() - 40;
|
||||||
@ -571,7 +575,7 @@ int main () {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
mic.center = (Vector2){ UI_WIDTH + (1920 - UI_WIDTH) / 2.0f - 100, 1080 / 2.0f };
|
mic.center = (Vector2){ UI_WIDTH + (1920 - UI_WIDTH) / 2.0f - 100, 1080 / 2.0f };
|
||||||
mic.d1 = 250.0f;
|
mic.d1 = 265.0f;
|
||||||
mic.d2 = 250.0f;
|
mic.d2 = 250.0f;
|
||||||
mic.lambdas[0] = 550.0f;
|
mic.lambdas[0] = 550.0f;
|
||||||
mic.lambdasCount = 1;
|
mic.lambdasCount = 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user