From ce3628d2973888dfc9cbc3365f9c405212f511a9 Mon Sep 17 00:00:00 2001 From: monman53 Date: Sat, 15 Jun 2024 21:47:07 +0900 Subject: [PATCH] Fix refraction calculation of real lens --- src/Canvas.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Canvas.vue b/src/Canvas.vue index 0570722..a20369c 100644 --- a/src/Canvas.vue +++ b/src/Canvas.vue @@ -41,7 +41,7 @@ const drawRay = (image: Vec, light: any, s: Vec, v: Vec, sensorDataTmp: any[]) = s = drawSegment(s, v, v.length()) // Refraction (inner lens rays) - const phi1 = crossAngle(Vec.sub(v, c), Vec.sub(vec(light.x, light.y), p)); + const phi1 = crossAngle(Vec.sub(p, c), Vec.sub(vec(light.x, light.y), p)); const phi2 = Math.asin(Math.sin(phi1) / lens.value.n); const theta = Math.atan2(p.y - c.y, p.x - c.x) + Math.PI + phi2; v = vec(Math.cos(theta), Math.sin(theta))