Skip to content

Commit

Permalink
Fix refraction calculation of real lens
Browse files Browse the repository at this point in the history
  • Loading branch information
monman53 committed Jun 15, 2024
1 parent bbbfd8d commit ce3628d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Canvas.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit ce3628d

Please sign in to comment.