1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

I Ray transformation of a 3d lens?

  1. May 30, 2016 #1

    I'm working on a raytracer, and got stuck with trying to model a lens analytically.

    Given is a thin lens at position p with the axis n, radius r and a focal distance f, a ray hits it at position p1 going in the direction d.
    Which way would the ray be going on the other side of the lens?

    The problem is, pretty much all i could google up assumes a rotational symmetry of the lens and talks in terms of an image of an object and similar 2D reduction.

    But in 3D the rays mostly hit the lens not in plane with it's axis (the ray vector and lens' normal vector are not coplanar), and for that case i can't find a single mention anywhere.

    The closest thing to a solution i can think of is to brute force it - drop the thin lens assumption, determine the glass-to-ray angle, do a refraction, find the intersect on the other side, do another refraction, get the answer.

    Is there any simpler way to do this?
  2. jcsd
  3. May 30, 2016 #2
    It's not clear to me what you are trying to do. In ray tracing, you have a series of surfaces and, you find where the ray encounters each surface and calculate the new ray direction. A general 3-d ray tracer is quite complex.

    Maybe you could explain a bit more what you are trying to do. By the way, what is the "axis n" of the lens? And a lens doesn't have a "radius," a surface does.
    Last edited: May 30, 2016
  4. May 30, 2016 #3
    Imagine a lens in front of you, on a table you're sitting at. It's at an angle to you.
    Look at it's center.
    Now shift that line of sight to the side.
    You will get a ray that passes through a lens, and yet it's not coplanar with the axis of the lens (the line that is perpendicular to the plane of the lens and goes through it's center).

    How would you calculate where this ray would get diverted after it passes through the lens?

    I'm trying to make a lens as a primitive object (instead of a mesh for it, or some sort of a sphere transformation computed explicitly).
  5. May 30, 2016 #4
    Rays that aren't coplanar with the axis of the lens are known as skew rays. I edited my post - when I asked what you meant by "axis" it's because you described it with a single parameter, n, which wasn't clear to me what you meant. I know what a lens axis is.

    I'm still trying to understand the scope of what you are trying to do - something relatively casual or a full-fledged ray trace program for an arbitrary set of surfaces. Ray tracing of skew rays is not easy.
  6. May 31, 2016 #5


    User Avatar
    Science Advisor

    The initial ray direction and the surface normal define a plane. Within that plane you have the usual 2D refraction.
  7. May 31, 2016 #6


    User Avatar
    Science Advisor
    Gold Member
    2017 Award

    For a simple case, why not just apply Snell's Law to the each ray at each surface of the lens? That would take the ray through both surfaces correctly. You wouldn't actually need to approximate the lens surfaces to a mesh - all you need is the radii of curvature and the direction of the principle axis.
    It's the sort of thing that would be best approached with a 2D model.
    But Ray Tracing has had such a lot of work on it in the last few years that you will have a lot of trouble working it out for yourself. to the level that's used these days. There will have been so many algorithms invented, to improve on efficiency and speed that you'd probably be best to approach the topic by studying what's been done already, rather than inventing it for yourself. There will be so many blind alleys for the beginner. . . . . .
  8. May 31, 2016 #7
    That's true of course, but the difficulty is calculating the location of that plane, especially for a skew ray.

    OP: if you are just beginning to learn ray tracing, I'd suggest you start with a paraxial ray trace - you define the system as a set of surfaces, indices of refraction and separations and apply simple equations at each surface.

    Otherwise, the section titled Vector Form at the following link is what you are looking for. It shows how to calculate the reflected and refracted rays knowing the ray direction and the direction of the normal at the surface, as A.T. suggested: https://en.wikipedia.org/wiki/Snell%27s_law[ [Broken]
    Last edited by a moderator: May 7, 2017
  9. May 31, 2016 #8

    Andy Resnick

    User Avatar
    Science Advisor
    Education Advisor

    Tracing skew rays is not fun. The MIL-HBDK-141 reference lays it out in detail, but in the end it is a brute-force method:

    http://fp.optics.arizona.edu/OT/MIL%20HDBK/ch05.pdf [Broken]

    (after a lot of information, an example trace is presented in Table 5.2)

    What raytracer are you currently using?
    Last edited by a moderator: May 7, 2017
  10. May 31, 2016 #9
    Ah. Skew rays was the googleable term i was looking for.

    I'm just exploring what can be done with raytracing, making one myself. Since it's not for anything important or for profit, i find it more valuable to (re-)invent things myself rather than look at things already done and figured out.

    In this particular case i wanted to propagate light from the sources until it hits the camera, which requires a working optical model of the said camera - at minimum one lens. Looks like the simplest way would be to preserve the generality and explicitly define the model in the scene.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted