TODAY ok optik sim we have a huge image -- seriously, this thing is almost 5k by 5k, and i rendered this at half of full res just to make uploading less painful.
1. i set up a standard set of test cases for testing lenses: there are objects at 3 different distances, and 3 different angles relative to the camera, making for 9 objects. i focus the lens to the same 3 different distances, which gives me 27 triplets of (angle, distance, focus point).
2. i wrote code to plot all of this nonsense. i also added code to plot a coarser version of the light (visible in the big 3 subplots on the left), since i think it's useful to be able to see exactly how the rays travel through the system.
3. i fixed some numerical problems with the ray tracing math
interpreting the plot:
first, mentally break down the plot into 3 chunks on the vertical axis, with each chunk containing a big plot of the entire system and 9 small plots on the right.
the 3 chunks correspond to the 3 focus distances: in the first vertical chunk, the camera is focused to the closest object (0.5 m), in the second vertical chunk, 5m, and the third, 100m.
for each focus distance, i simulate how light from all 9 objects travel through the lens. however, in order to keep the figure readable, in the left subplots, i visualize only the 3 lights which are located at the same distance which the lens is focused on.
ON the right 9 subplots, i do visualize how all 9 objects look like as they hit the sensor. each COLUMN of the 9 subplots corresponds to a different distance: the 3 objects at 0.5m, the 3 at 5m, the 3 at 100m. each ROW of the 9 subplots corresponds to a different angle.
so to make this clear: in the first chunk, i would expect the middle row of the first col to be the sharpest, because that's what i'm focusing on. i would still hope that the other rows of the first col are pretty sharp. finally, i don't expect the second and third cols (objects at 5 and 100m away) to be sharp. likewise, in the second chunk, i would expect the middle row of the Second col to be sharp, etc.
each of the 9 small subplots covers an area of 1mm x 1mm. on a typical camera, there are probably somewhere in the ballpark of 50 pixels / mm. so you can see this made up lens is pretty shit because even the best focused points of light (i call them objects but they're really point light sources), are spread out over like 10px
anyway i feel like almost all of the setup is now complete and i can start designing lenses soon
-----
ALSO if you're wondering why the right plots have color but the left rays are white, it's because on the left, you're zoomed out enough that the R, G, and B rays blend together into white!, however if you zoom in enough, even on the left you can see slight chromatic aberrations leading to colors