inclinaison Y de M1
This commit is contained in:
74
main.c
74
main.c
@ -15,6 +15,7 @@ typedef struct {
|
|||||||
float d2;
|
float d2;
|
||||||
float lambda;
|
float lambda;
|
||||||
float angleM1;
|
float angleM1;
|
||||||
|
float angleM1_Y;
|
||||||
Vector2 center;
|
Vector2 center;
|
||||||
bool gaz;
|
bool gaz;
|
||||||
float nGaz;
|
float nGaz;
|
||||||
@ -49,65 +50,6 @@ bool GuiButtonRepeat(Rectangle bounds, const char* text, bool shouldRepeat) {
|
|||||||
return clicked || held;
|
return clicked || held;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
void DrawInterferenceViewCPU(Michelson *mic, Rectangle rec) {
|
|
||||||
DrawRectangleRec((Rectangle){rec.x - 4, rec.y - 30, rec.width + 8, rec.height + 34}, COLOR_PANEL);
|
|
||||||
DrawText("ECRAN", rec.x, rec.y - 26, 20, COLOR_TEXT_DIM);
|
|
||||||
|
|
||||||
DrawRectangleRec(rec, BLACK);
|
|
||||||
DrawRectangleLinesEx(rec, 1, Fade(COLOR_ACCENT, 0.3f));
|
|
||||||
|
|
||||||
Color baseColor = WavelengthToColor(mic->lambda);
|
|
||||||
|
|
||||||
float extraPath = 0.0f;
|
|
||||||
if (mic->gaz)
|
|
||||||
extraPath = 2.0f * 100.0f * (mic->nGaz - 1.0f);
|
|
||||||
|
|
||||||
float d2_effective = mic->d2 + (extraPath / 2.0f);
|
|
||||||
|
|
||||||
// Diff de marche du à l'axe (2 * e) + micro -> nano
|
|
||||||
float deltaLnm = 2.0f * (mic->d1 - d2_effective) * 1000.0f;
|
|
||||||
|
|
||||||
int cx = rec.x + rec.width / 2;
|
|
||||||
int cy = rec.y + rec.height / 2;
|
|
||||||
|
|
||||||
float K = PI / mic->lambda;
|
|
||||||
|
|
||||||
// Dessin pixel par pixel lent... => faire avec gpu
|
|
||||||
for (int y = rec.y; y < rec.y + rec.height; y++) {
|
|
||||||
for (int x = rec.x; x < rec.x + rec.width; x++) {
|
|
||||||
float relX = (float)(x - cx);
|
|
||||||
float relY = (float)(y - cy);
|
|
||||||
float radiusSq = relX * relX + relY * relY;
|
|
||||||
|
|
||||||
//if (radiusSq > (rec.width / 2.0f - 5) * (rec.width / 2.0f - 5)) continue;
|
|
||||||
|
|
||||||
// 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 ringFactor = radiusSq * 0.065f;
|
|
||||||
// Diff de marche dut au coin d'air
|
|
||||||
float wDelta = relX * mic->angleM1 * 200.0f;
|
|
||||||
|
|
||||||
float currDelta = deltaLnm - ringFactor + wDelta;
|
|
||||||
|
|
||||||
// Formule de Fresnel : I = I_0 * cos^2(phi)
|
|
||||||
float phase = currDelta * K;
|
|
||||||
float intensity = cosf(phase);
|
|
||||||
intensity = intensity * intensity;
|
|
||||||
|
|
||||||
Color pixColor = {(unsigned char)(baseColor.r * intensity), (unsigned char)(baseColor.g * intensity), (unsigned char)(baseColor.b * intensity), 255 };
|
|
||||||
|
|
||||||
DrawPixel(x, y, pixColor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DrawRectangleLinesEx(rec, 2, COLOR_PANEL);
|
|
||||||
|
|
||||||
// croix centre
|
|
||||||
DrawLine(cx - 10, cy, cx + 10, cy, Fade(WHITE, 0.5f));
|
|
||||||
DrawLine(cx, cy - 10, cx, cy + 10, Fade(WHITE, 0.5f));
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
void DrawInterferenceViewGPU(Michelson *mic, Rectangle rec, Shader shader, bool *isFullscreen) {
|
void DrawInterferenceViewGPU(Michelson *mic, Rectangle rec, Shader shader, bool *isFullscreen) {
|
||||||
|
|
||||||
DrawRectangleRec((Rectangle){rec.x - 4, rec.y - 30, rec.width + 8, rec.height + 34}, COLOR_PANEL);
|
DrawRectangleRec((Rectangle){rec.x - 4, rec.y - 30, rec.width + 8, rec.height + 34}, COLOR_PANEL);
|
||||||
@ -141,6 +83,7 @@ void DrawInterferenceViewGPU(Michelson *mic, Rectangle rec, Shader shader, bool
|
|||||||
SetShaderValue(shader, GetShaderLocation(shader, "d2"), &d2_effective, SHADER_UNIFORM_FLOAT);
|
SetShaderValue(shader, GetShaderLocation(shader, "d2"), &d2_effective, SHADER_UNIFORM_FLOAT);
|
||||||
SetShaderValue(shader, GetShaderLocation(shader, "lambda"), &mic->lambda, SHADER_UNIFORM_FLOAT);
|
SetShaderValue(shader, GetShaderLocation(shader, "lambda"), &mic->lambda, SHADER_UNIFORM_FLOAT);
|
||||||
SetShaderValue(shader, GetShaderLocation(shader, "angleM1"), &mic->angleM1, SHADER_UNIFORM_FLOAT);
|
SetShaderValue(shader, GetShaderLocation(shader, "angleM1"), &mic->angleM1, SHADER_UNIFORM_FLOAT);
|
||||||
|
SetShaderValue(shader, GetShaderLocation(shader, "angleM1_Y"), &mic->angleM1_Y, SHADER_UNIFORM_FLOAT);
|
||||||
SetShaderValue(shader, GetShaderLocation(shader, "zoom"), &zoom, SHADER_UNIFORM_FLOAT);
|
SetShaderValue(shader, GetShaderLocation(shader, "zoom"), &zoom, SHADER_UNIFORM_FLOAT);
|
||||||
|
|
||||||
// GPU
|
// GPU
|
||||||
@ -292,7 +235,7 @@ void DrawControlPanel(Michelson *mic) {
|
|||||||
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
|
// 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);
|
||||||
float stepAngle = speedMode ? 0.05f : 0.001f;
|
float stepAngle = speedMode ? 0.05f : 0.001f;
|
||||||
@ -301,6 +244,14 @@ void DrawControlPanel(Michelson *mic) {
|
|||||||
if (GuiButtonRepeat((Rectangle){startX + btnSize + sliderWidth - 65, startY + 30, btnSize, 25}, "+", shouldRepeat)) mic->angleM1 += stepAngle;
|
if (GuiButtonRepeat((Rectangle){startX + btnSize + sliderWidth - 65, startY + 30, btnSize, 25}, "+", shouldRepeat)) mic->angleM1 += stepAngle;
|
||||||
if (GuiButton((Rectangle){startX + contentWidth - 60, startY + 30, 60, 25}, "Zero")) mic->angleM1 = 0.0f;
|
if (GuiButton((Rectangle){startX + contentWidth - 60, startY + 30, 60, 25}, "Zero")) mic->angleM1 = 0.0f;
|
||||||
|
|
||||||
|
// Angles M1 Y
|
||||||
|
startY += 90;
|
||||||
|
DrawText(TextFormat("Inclinaison Y: %.3f deg", mic->angleM1_Y), startX, startY, 20, ORANGE);
|
||||||
|
if (GuiButtonRepeat((Rectangle){startX, startY + 30, btnSize, 25}, "-", shouldRepeat)) mic->angleM1_Y -= stepAngle;
|
||||||
|
GuiSlider((Rectangle){startX + btnSize + 5, startY + 30, sliderWidth - 75, 25}, 0, 0, &mic->angleM1_Y, -1.0f, 1.0f);
|
||||||
|
if (GuiButtonRepeat((Rectangle){startX + btnSize + sliderWidth - 65, startY + 30, btnSize, 25}, "+", shouldRepeat)) mic->angleM1_Y += stepAngle;
|
||||||
|
if (GuiButton((Rectangle){startX + contentWidth - 60, startY + 30, 60, 25}, "Zero")) mic->angleM1_Y = 0.0f;
|
||||||
|
|
||||||
// Status
|
// Status
|
||||||
startY += 70;
|
startY += 70;
|
||||||
bool isLameAir = (fabs(mic->angleM1) < 0.001f);
|
bool isLameAir = (fabs(mic->angleM1) < 0.001f);
|
||||||
@ -359,6 +310,9 @@ int main () {
|
|||||||
mic.d2 = 250.0f;
|
mic.d2 = 250.0f;
|
||||||
mic.lambda = 550.0f;
|
mic.lambda = 550.0f;
|
||||||
mic.angleM1 = 0.0f;
|
mic.angleM1 = 0.0f;
|
||||||
|
mic.angleM1_Y = 0.0f;
|
||||||
|
mic.nGaz = 1.0f;
|
||||||
|
mic.gaz = false;
|
||||||
|
|
||||||
bool isFullscreen = false;
|
bool isFullscreen = false;
|
||||||
|
|
||||||
|
|||||||
@ -13,6 +13,7 @@ uniform float d1;
|
|||||||
uniform float d2;
|
uniform float d2;
|
||||||
uniform float lambda;
|
uniform float lambda;
|
||||||
uniform float angleM1;
|
uniform float angleM1;
|
||||||
|
uniform float angleM1_Y;
|
||||||
uniform float zoom;
|
uniform float zoom;
|
||||||
|
|
||||||
const float PI = 3.14159265359;
|
const float PI = 3.14159265359;
|
||||||
@ -53,7 +54,7 @@ void main() {
|
|||||||
float ringFactor = radiusSq * 0.065;
|
float ringFactor = radiusSq * 0.065;
|
||||||
|
|
||||||
// Diff de marche du au coin d'air
|
// Diff de marche du au coin d'air
|
||||||
float wDelta = relX * angleM1 * 200.0;
|
float wDelta = (relX * angleM1 + relY * angleM1_Y) * 200.0f;
|
||||||
|
|
||||||
float currDelta = deltaLnm - ringFactor + wDelta;
|
float currDelta = deltaLnm - ringFactor + wDelta;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user