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$>
References: <ir62ul$31b$> <ir7245$1ca$> <ir8rqu$hkl$> <ir8vbe$ppj$>
Reply-To: <HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: 1306008122 11718 (21 May 2011 20:02:02 GMT)
NNTP-Posting-Date: Sat, 21 May 2011 20:02:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: comp.soft-sys.matlab:728000

"Mahsa " <> wrote in message <ir8vbe$ppj$>...
> "Roger Stafford" wrote in message <ir8rqu$hkl$>...
> > > "Mahsa " <> wrote in message <ir62ul$31b$>...
> > > > ...... 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