Results 1 to 7 of 7

Math Help - can't get ellipse to focus rays onto other focus

  1. #1
    Newbie
    Joined
    May 2010
    Posts
    4

    can't get ellipse to focus rays onto other focus

    Greetings. I'm trying to do an optical simulation and wrote a ray, ellipsoid intersection function for Matlab/Octave. I fire a bundle of rays from 1 focus, and reflect them off the ellipse (see pictures).

    In ellipse2.png, I choose the focus to be (0, -sqrt(1.2^2 - 1)) as it should be. I compute |hit - foci0| + |hit - foci1| and they're a constant 2.4 as expected, but the rays don't converge.

    In ellipse1.png, I set the focus to (0, -.46). The rays now converge, but |hit - foci0| + |hit - foci1| no longer seem to be constant.

    So I'm guessing the problem is with my intersection routine. Can anyone point out what's wrong?

    (my code is a 2D version of the 3D case (YZ plane), so theta = 0 means straight up, instead of left)

    1. First I find ray, ellipse intersection by expressing the ray as parametric equations (simple quadratic formula)

    2. Find theta parameter associated with intersection: parametric form of ellipse is: y = b * sin(theta) z = c * cos(theta)
    theta = atan2(hit.y, hit.z)

    3. compute tangent vector dp_dtheta = [b * cos(theta), -c * sin(theta)]

    4. rotate tangent vector -90 degrees to get surface normal at intersection

    5. reflect the incident vector about the normal vector:
    generate a rotation matrix with vector perpendicular to both incident & normal vector as axis. apply the rotation matrix to the incident vector to get the outgoing vector.

    My main uncertainty is #3. I do this based on my knowledge of the PBRT raytracer. They compute the surface normal as CrossProduct(dp_du, dp_dv), where u & v, the surface parametization is in [0, 1].


    update:

    I've estimated the surface tangent by evaluating P(theta + 0.001) - P(theta). The estimated tangent vector matches the 1 computed above to 3 figures.
    So now it's really a mystery. Is the reflection incorrect or am I using the wrong ellipse focus formula?
    Attached Thumbnails Attached Thumbnails can't get ellipse to focus rays onto other focus-ellipse1.png   can't get ellipse to focus rays onto other focus-ellipse2.png  
    Attached Files Attached Files
    Last edited by UncleJoe; May 31st 2010 at 05:41 PM. Reason: more info
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Newbie
    Joined
    May 2010
    Posts
    4
    OK, I've found what's wrong - the theta = atan2(y, z) parametization is wrong. I plotted the tangent vectors and they weren't tangent to the ellipse, so I saw that the geometric angle the hit point makes with the z axis isn't the same as the theta I want.

    It turns out. y / z = b sin(theta) / c cos(theta) = (b/c)tan(theta)

    so theta = atan2((c / b) y, z)
    Last edited by UncleJoe; May 31st 2010 at 03:26 AM.
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Member
    Joined
    Oct 2008
    Posts
    206
    Hi Unclejoe.

    Actually I am doing on a research on this too. I was trying to run your code but realised that the function

    (solveQuadratic)

    is missing from your code. Will greatly appreciate if you can upload it too. Thanks
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Newbie
    Joined
    May 2010
    Posts
    4
    Here they are. I didn't expect anyone to want to run the program. I've included my 3D ellipsoid version as well. I only wrote the 2D ellipse version for debugging my problem. The wrong theta problem has been fixed for both.

    testing.m (3D ellipsoid & hyperboloid)

    test2d (2D ellipse)


    What do you want to use it for?

    I'm trying to find the feasibility of building a certain head mounted display described @ http://research.engineering.wustl.ed...l/nagahara.pdf

    I only recently picked up Matlab from my job at 3M (image processing) and only wrote the program to debug my actual PBRT raytracer code. Much more convenient than C++.
    Attached Files Attached Files
    Follow Math Help Forum on Facebook and Google+

  5. #5
    Member
    Joined
    Oct 2008
    Posts
    206
    Hi tks for the upload.

    Actually I am currently doing my internship and was tasked to work on ray tracing which is not really my field of study. I am also very unsure of matlab manipulation.

    I saw your entry and think that this could be helpful to my work. In particularly in solving the some questions which I posted previously.
    [HTML]http://www.mathhelpforum.com/math-help/geometry/146420-finding-coordinates-when-light-hit-surface.html[/HTML]

    So I was thinking maybe this code can assist me to achieve a better understanding on ray tracing in an ellipse
    Follow Math Help Forum on Facebook and Google+

  6. #6
    MHF Contributor undefined's Avatar
    Joined
    Mar 2010
    From
    Chicago
    Posts
    2,340
    Awards
    1
    Quote Originally Posted by noob mathematician View Post
    Hi tks for the upload.

    Actually I am currently doing my internship and was tasked to work on ray tracing which is not really my field of study. I am also very unsure of matlab manipulation.

    I saw your entry and think that this could be helpful to my work. In particularly in solving the some questions which I posted previously.
    [html]http://www.mathhelpforum.com/math-help/geometry/146420-finding-coordinates-when-light-hit-surface.html[/html]So I was thinking maybe this code can assist me to achieve a better understanding on ray tracing in an ellipse
    (Largely in regards to the other thread linked to above)

    Oh you're doing this for an internship? Haha, why didn't you mention that. I thought your physics friend just gave you the problem as a random challenge. Since it counts for work, I'd say that's different. I will PM you.

    Sorry to mods if this response fits better in the other thread. It seemed to kind of fit here, at the time I posted, but in retrospect maybe not. Ah well, they're related enough that it shouldn't matter.
    Follow Math Help Forum on Facebook and Google+

  7. #7
    Newbie
    Joined
    May 2010
    Posts
    4
    I saw your entry and think that this could be helpful to my work
    So, have you solved the ray, ellipse reflection problem using the code?
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Focus of parabola
    Posted in the Pre-Calculus Forum
    Replies: 3
    Last Post: December 20th 2011, 10:46 AM
  2. Focus and Directrix
    Posted in the Pre-Calculus Forum
    Replies: 1
    Last Post: December 6th 2009, 12:57 PM
  3. Ellipse centered at a focus
    Posted in the Calculus Forum
    Replies: 5
    Last Post: October 3rd 2009, 02:05 AM
  4. [SOLVED] Ellipse - Focus and Directrix
    Posted in the Pre-Calculus Forum
    Replies: 4
    Last Post: February 25th 2008, 05:09 AM
  5. Parabola's focus
    Posted in the Pre-Calculus Forum
    Replies: 2
    Last Post: May 9th 2007, 04:07 PM

Search Tags


/mathhelpforum @mathhelpforum