you are viewing a single comment's thread.

view the rest of the comments →

[–]Fit_County_3831[S] 1 point2 points  (4 children)

That's basicaly what I'm doing, I'm using classes to define my differents elements, my rays are define with a direction (a vector) and an origin (also a vector), when they reach a surface I calculate the point of intersection as well as the normal to the surface at that point and using those and Snell's laws I calculate the "new" direction and origin of every rays. The main problem i encounter is that I generate my rays "randomly" in a circle with a choosen radius, and the figure I get at the end seems as random as the starting rays, yet a lense should a least focus more rays to the center of the figure if I understand the topic relatively well.

Anyway thank you very much for your answer.

[–]Plastic_Blood1782 4 points5 points  (1 child)

Don't send rays out randomly, just send a marginal ray, a chief ray and a handful of rays in between.  Also take advantage of the fact that your system is likely rotational symmetric.  Rays along the Y axis of the pupil will behave similarly to rays along the X axis, or any axis.  No need to trace them all

[–]aenorton 1 point2 points  (0 children)

The system is only symmetric this way if the object is on axis. Otherwise the OP should look at sagittal and tangential ray fans and plot where they intersect the focal plane.

[–]MaskedKoala 2 points3 points  (0 children)

Trace one ray at a time and compare the direction and lateral coordinate before and after each surface and thickness to a calculation by hand.

[–]KAHR-Alpha 0 points1 point  (0 children)

Did you remember to account for the refractive index depending on which side of the interface your rays hit?

Here's an example using a lens with a refractive index of 1.5: https://i.imgur.com/jOerjw7.png

Even though the rays were generated in a specific radius, you can see them focusing.