Skip to main content
GameDev.net gamedev.net
🔒 Locked

help with light problem

Started by lomateron Oct 2, 2013 at 10:37 PM 9 replies 2.4k views
Original Post
lomateron
lomateron

yO9DtBP.png

"n" are the refraction index lets say n1=1 n2=1.3

"d" the distance lets say 0.024

I have to find the equation of the curvature that makes all those rays intersect on that point

if you give me the equation I can test it immediately

its not x=y^2

fDzIdJO.png

neither x=sqrt(1-y^2)

RwMyDgi.png

marksan
marksan
Try a hyperbolic equation, something like x=a*sqrt(y^2 + b^2)
JohnnyCode
JohnnyCode

the ray is line that is orthogonal to the derivation(tangent) of the curve in the point it crosses the curve. so function of your curve f(x) has a derivation f'(x) . the derivation function value at any x is tan(alfa) where alfa is angle of tangent to the curve in the x,f(x) point with the x axis. now, if you travel from a point [x,f(x)] in the direction that is orthogonal to that tangenting line, you should reach your point.

To rewrite the whole problem, your point is P ([d,0] in your case).

Following is defined:

P - [x,f(x)] is a vector orthogonal to derivation at point x for all x.

thus dot product of P-[x,f(x)] vector and [x,f'(x)*x] vector is always 1.0, if those vectors are normalized (length is one)

this yealds parametric equation

1.0= (d-x)*x + (0-f(x))*f'(x)*x for all x

pick your function f, find its derivation f', and from there, if possible, create a system of linear equations for 2 or 3 random x values, to compute d.

JohnnyCode
JohnnyCode

and now it is quite clear to me that such a point does not exist for any function and any short definition interval of the function, unless the definition interval and the function follow a circle tendence.

alvaro
alvaro

I didn't quite follow JohnyCode's argument, but I was trying to derive a differential equation myself and it looks nothing like his. How does the ratio n1/n2 enter the formulation of the problem? Because the answer certainly depends on it...

I'll try to post what I think the differential equation is tonight or tomorrow. I have something on a piece of paper in front of me, but it's a bit tricky and I don't want to post misinformation before I am reasonably convinced that I got it right (that is, I can write a program that approximates a solution and does a good job).

lomateron
lomateron

"the ray is line that is orthogonal to the derivation(tangent) of the curve in the point it crosses the curve"

no, because of the refractive index

lomateron
lomateron

"Try a hyperbolic equation, something like x=a*sqrt(y^2 + b^2) "

that worked

downlad the 3 files and put tham in same folder location

https://mega.co.nz/#!jMsgwBCK!VeVH53jwksOQiHOybOVX8S6bYWltK7WT5k9FXR6BgAU

https://mega.co.nz/#!mIlDgKyA!c044tS595735q6rzhznv1jmmkxhxB_luunWxXvVZyEg

https://mega.co.nz/#!WQ8wnZaZ!MXxKd01cCUIYDV1vO3RpRB3uo1R5xJ-gER8bTilR04I

run exe

then connect two mouse to your computer

mouse1 x-axis is the direction of rays before entering

mouse1 y-axis is "b^2" of the hyperbolic equation

mouse2 x-axis is "n2" refractive index

mouse2 y-axis is "a" of the hyperbolic equation

move them until the rays adjust to a point

I still want to know how to get that curve equation

and that hyperbolic equation still doesn't has the curve I am looking for because the curve I want will always make the rays intersect in one point when the ray incidence direction changes(the point of intersection must change location, but the rays have to intersect in the same point)

macnihilist
macnihilist

I'm not sure this is right, but I would attack the problem with simple geometry.

[attachment=18236:light.png]

- For the (originally parallel) rays to meet they have to have the same optical path length after crossing the h-axis (Fermat's principle). So you have

a*n1 + b*n2 = f*n2 (upper ray = lower ray)

- Pythagoras for the triangle gives

b^2 = (f-a)^2 + h^2

- Putting both together gives

a = ( sqrt(f^2*n2^2*(2*n2-2*n1)^2+4*h^2*n2^2*(n1^2-n2^2)) - f*n2*(2*n2-2*n1) ) / (2*(n1^2-n2^2))

[ If I have entered it correctly into Wolfram alpha ;) ]

I have to say the solution seems suspiciously complicated, but I'm pretty sure the basic idea is correct.

alvaro
alvaro

Hmmm... I am not sure Fermat's principle implies the two paths have the same optical length [EDIT: Yes, it does!]. But if it does, it does give you a much easier solution than what I was trying.

I'm sorry I didn't produce a solution over the weekend. My laptop's screen stopped working. I'll continue when it's fixed.

alvaro
alvaro

Repeating [by hand] what macnihilist did and defining n:=sqrt(1+(n2/n1)^2), I get

(n*x-f/n)^2 + y^2 = (f/n)^2

This is the equation of an ellipse.

[I renamed a and b to the more familiar x and y.]

lomateron
lomateron

the application that I posted is wrong and the way I show in my first post how a parabola refracts light is wrong too

now I corrected the application and I am pretty sure it now refracts light correctly and the ellipse works.

ODgeraX.png

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.