Closed petermarkley closed 3 weeks ago
This is fixed with 2ba2f8d3fd8298ae29b309efe0f2c34eb20bd06d now, thanks to BlitzPhD! :partying_face:
He said:
You need to make sure that your trajectory step size and your index of refraction vertical step size are compatible.
So if your step is x, you need to figure out how far the ray would travel "vertically" if you kept it straight in that direction, and then use that vertical distance as your sampling distance.
So if it would go up at a 45 degree angle for x units, your vertical step should be plus and minus x/2sqrt(2).
Basically, compute how the light ray would see the refractive index changing over one step as if it weren't bending.
So if it was just angling up a tiny bit, your vertical step size should be small. If it was angling up a lot, it should be big.
Basically, by not accounting for this, you're giving small angles a much larger refractive change than they should have had.
Once I cleaned up a few bugs, I found a more subtle issue: the refraction in the simulation seems WAY stronger than it should be. I can't figure out why, AFAIK I'm following the physical model as closely as possible using Snell's Law.
The sight line almost acts like a projectile falling due to gravity or something, the observer would have to actually look almost 3.5 deg ABOVE eye level to see the horizon. (So the optics would be completely reversing the convexity of earth and making it appear concave.)
One of the original issues I fixed (in 154d4395105c639401ee662f5c800f287dcb01ce) was a unit conversion issue in the actual Snell's Law formula. Maybe there's another silly mistake lurking in there somewhere?
Having trouble thinking of a good troubleshooting approach ...