My Math Forum  

Go Back   My Math Forum > High School Math Forum > Algebra

Algebra Pre-Algebra and Basic Algebra Math Forum


Reply
 
LinkBack Thread Tools Display Modes
May 8th, 2010, 08:13 AM   #1
Newbie
 
Joined: May 2010

Posts: 12
Thanks: 0

Ray tracing problem

Hi,

I'm writing a simple ray-tracing program, but it's a good while since my high school vector maths classes and I'm stuck on a problem. I hope someone may be able to help.

Essentially I am trying to determine the point of intersection X of a ray of light from light source L to point P inside a transparent sphere. The centre of the sphere is C and its radius r. The refractive indices of the media outside and inside the sphere are given by k1 and k2 respectively. Position vector representations of L, P and C are known, as are the scalars r, k1 and k2.

Unit direction vectors for the incident light ray d, refracted ray t and the normal to the sphere's surface n are given by:
d = (X-L) / |X-L|
t = (P-X) / |P-X|
n = (X-C) / |X-C| = (X-C) / r

These three vectors are co-planar, so:
t = an + bd

They are also unit vectors, so:
cos(theta1) = -n.d
cos(theta2) = -n.t

Snell's law of refraction states:
k1 sin(theta1) = k2 sin(theta2)
so using cross-products:
k1(d x n) = k2(t x n)

The only unknown here is X, but for the life of me I can't come up with a solution!

Any pointers to the solution, or errors in my thinking, would be much appreciated.

Richard
rms189 is offline  
 
May 10th, 2010, 10:20 AM   #2
Global Moderator
 
Joined: Dec 2006

Posts: 20,467
Thanks: 2038

If you knew X, but didn't know P, would you be able to find P?
skipjack is offline  
May 10th, 2010, 10:57 AM   #3
Newbie
 
Joined: May 2010

Posts: 12
Thanks: 0

Re: Ray tracing problem

Since the vectors are co-planar: t = an + bd

Firstly: t x n = a(n x n) + b(d x n)
So: t x n = b(d x n)
Given k1(d x n) = k2(t x n)
Therefore: b = k1 / k2

Secondly: t.t = (an + bd).(an + bd)
So: a^2 + 2ab(n.d) + b^2 - 1 = 0
Since a is the only unknown use the quadratic formula to determine its value

Now we have a, n, b and d, so t follows
X and t allow calculation of the intersection with the line through C, i.e. point P

I'm trying to rearrange this process, but keep hitting the problem of X appearing in the definitions of d, t and n and being unable to come up with a form that allows one of these to be determined. Once I have one of the three the rest fall into place, and I feel that n is the one to work on...
rms189 is offline  
May 10th, 2010, 04:36 PM   #4
Global Moderator
 
Joined: Dec 2006

Posts: 20,467
Thanks: 2038

Do you mean rearrange to go from knowing P to find X?
skipjack is offline  
May 11th, 2010, 12:22 PM   #5
Newbie
 
Joined: May 2010

Posts: 12
Thanks: 0

Re: Ray tracing problem

I'm probably not using the correct mathematical terminology, but yes that's the essence of the problem.

The problem would be trivial for refraction at a plane, since the normal to the plane is known at every point on the plane. The difference for a sphere is that the normal changes over the sphere's surface. The difficulty is that X, n, d and t all depend on one another. Without one you can't know any of the others, but as soon as you do know one all of the others fall into place. So I need to find a way of calculating one of them that does not require knowledge of any of the other three, using the known values for position vectors P, L and C, the corresponding direction vectors between them, the radius of the sphere and the relationship between theta1 and theta2 given in Snell's law.

The problem can be solved iteratively to "home in" on the answer, but a mathematical solution would be computationally more efficient and intellectually more elegant. Is there one?
rms189 is offline  
May 11th, 2010, 05:52 PM   #6
Global Moderator
 
Joined: Dec 2006

Posts: 20,467
Thanks: 2038

If you can express P in terms of X, you can study that formula to see whether you can rearrange it to express X in terms of P.
skipjack is offline  
May 12th, 2010, 12:19 PM   #7
Newbie
 
Joined: May 2010

Posts: 12
Thanks: 0

Re: Ray tracing problem

That's exactly what I have tried and failed to do. If you run the steps of the algorithm to find P knowing X backwards given above you'll see that to get X from P you need to know t. t depends on n and d, and n and d depend on knowing X. It's completely circular. As I said I need to find one of X, n, d or t which does not require any of the other three terms, and so far I have been unable to find the solution.

It may be that this problem has no solution, but I'm not a good enough mathematician to be sure. Has anyone out there had a crack at this and made progress?
rms189 is offline  
Reply

  My Math Forum > High School Math Forum > Algebra

Tags
problem, ray, tracing



Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Tracing a graph jomagam Applied Math 4 October 8th, 2013 01:53 PM
integral calculus ....... curve tracing rimi Calculus 2 July 3rd, 2013 05:08 PM
curve tracing philosopher Complex Analysis 3 December 15th, 2012 09:33 AM
Need help with curve tracing nirmal19 Real Analysis 3 November 23rd, 2010 06:36 AM





Copyright © 2019 My Math Forum. All rights reserved.