Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: How to rotate a (3-D) line in a plane by an angle of theta about the point of origin ?
Date: Sat, 21 May 2011 20:02:02 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 22
Message-ID: <ir95nq$be6$1@newscl01ah.mathworks.com>
References: <ir62ul$31b$1@newscl01ah.mathworks.com> <ir7245$1ca$1@newscl01ah.mathworks.com> <ir8rqu$hkl$1@newscl01ah.mathworks.com> <ir8vbe$ppj$1@newscl01ah.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: www-02-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1306008122 11718 172.30.248.47 (21 May 2011 20:02:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sat, 21 May 2011 20:02:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: news.mathworks.com comp.soft-sys.matlab:728000

"Mahsa " <newsreader@mathworks.com> wrote in message <ir8vbe$ppj$1@newscl01ah.mathworks.com>...
> "Roger Stafford" wrote in message <ir8rqu$hkl$1@newscl01ah.mathworks.com>...
> > > "Mahsa " <newsreader@mathworks.com> wrote in message <ir62ul$31b$1@newscl01ah.mathworks.com>...
> > > > ...... the direction of rays changes by an angle theta with respect to the normal ....
> > - - - - - - - - - 
> >   By the way, if your question was about refraction, when you said, "the direction of rays changes by an angle theta with respect to the normal", by Snell's Law of refraction that angle theta would depend on the angle of incidence of the ray, and therefore you would need to calculate that angle from the direction of the incoming ray with respect to the surface normal.
> > 
> > Roger Stafford
> 
> Dear Mr. Stafford,
> Thanks a lot for the advice. I was indeed talking about simple reflection and refraction in ray tracing. I have bubbles in a liquid containing particles. The very tiny particles have a phase function indicating the new direction of flight which I have implemented. Therefore, I have the direction of incidence, I try to solve the equation of line(ray) with sphere to calculate the point of incidence. Then I can have the equation of normal to the surface of sphere that passes through the center of bubble and the incidence point. Then simple with a dot product I calculate the angle of incidence(theta1). It is a Monte Carlo scheme, so the ray is either reflected or refracted, and I need to define the new direction of flight and this direction (as you know) must be in the same plane as the incidence ray and the normal to the sphere surface. With Snell's law I calculate the angle of refraction 

> ....... Then basically the new ray will make theta2 with normal .......
- - - - - - - - - - -
  Yes I misunderstood what angle you meant by theta.  As I understand it now, if we again regard the normal N as pointing inward from the surface, the angle theta is to be measured from this normal toward, and in the same plane as, the incident ray P.  In that case the refracted vector Q would be:

 Q = cross(P,N);
 Q = (cos(theta)*N + sin(theta)*cross(N,Q/norm(Q)))/norm(N);

which is a very different formula.

Roger Stafford