From: "Mahsa " <>
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: Tue, 24 May 2011 07:40:19 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 52
Message-ID: <irfnd3$1g7$>
References: <ir62ul$31b$> <ir7245$1ca$> <ir8rqu$hkl$> <ir8vbe$ppj$> <ir95nq$be6$> <ir9mcc$kmm$> <irbt3g$8el$> <irc5p0$t0t$> <irdsal$jjq$> <ire089$34u$>
Reply-To: "Mahsa " <>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: 1306222819 1543 (24 May 2011 07:40:19 GMT)
NNTP-Posting-Date: Tue, 24 May 2011 07:40:19 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2882983
Xref: comp.soft-sys.matlab:728388

"Roger Stafford" wrote in message <ire089$34u$>...
> "Mahsa " <> wrote in message <irdsal$jjq$>...
> > Dear Roger,
> > 
> > Thanks for the elaboration. I can only use this formula for when the ray is traveling inside the bubble and reaches the interface of bubble and liquid to enter the liquid(r<1).
> > I put the two criteria, but I get a different formula, I don't know maybe am doing something different:
> > Q=aP+bN
> > a=r 
> > t1=r*dot(P,N)    & t2=(1-r^2)*dot(P,P)
> > norm(Q)=norm(P) ==> dot(Q,Q)=dot(P,P)
> > dot(Q,Q)=r^2*dot(P,P)+b^2*dot(N,N)+2*b*r*dot(P,N) ==>
> > (1-r^2)*dot(P,P)=b^2*dot(N,N)+2*b*r*dot(P,N)
> > t2=b^2*dot(N,N)+2*b*t1
> > t2/dot(N,N)=(b^2+2*b*t1/dot(N,N))
> > b^2+2*b*t1/dot(N,N)+(t1/dot(N,N))^2-(t1/dot(N,N))^2=t2/dot(N,N)
> > (b+t1/dot(N,N))^2-(t1/dot(N,N))^2=t2/dot(N,N)
> > (b+t1/dot(N,N))^2=t2/dot(N,N)+(t1/dot(N,N))^2=(t2*dot(N,N)+t1^2)/(dot(N,N))^2
> > ==>b+t1/dot(N,N)=1/dot(N,N)*sqrt(t1^2+t2*dot(N,N))
> > b=1/dot(N,N)*(-t1+sqrt(t1^2+t2*dot(N,N))          
> > which is a bit different than your formula of: b=t2/(sqrt(t1^2+t2*dot(N,N))+t1)
> > I do not need to rationalize the denominator, as have no sqrt in there, Am I making a mistake somewhere? 
> > Thanks,
> > Regards,
> > Mahsa.
> - - - - - - - - -
>   You haven't made any mistakes, Mahsa, but yours and my expressions for b are identically equal.  Multiply and divide your expression for b by
>  sqrt(t1^2+t2*dot(N,N))+t1,
> which wouldn't change its value, and you will get my expression for b.  To see that, first do the multiplication:
>  1/dot(N,N)*(-t1+sqrt(t1^2+t2*dot(N,N))*(sqrt(t1^2+t2*dot(N,N))+t1) =
>  1/dot(N,N)*(sqrt(t1^2+t2*dot(N,N))-t1)*(sqrt(t1^2+t2*dot(N,N))+t1) =
>  1/dot(N,N)*(t1^2+t2*dot(N,N)-t1^2) = 1/dot(N,N)*t2*dot(N,N) = t2
> Now divide by the same quantity and get
>  t2/(sqrt(t1^2+t2*dot(N,N))+t1)
> which is my expression for b.  They are exactly the same quantity.
>   To settle any lingering doubts on this score try entering random vectors in the two expressions to see that the results are always equal (except for round off errors.)
>   The above is a standard method of removing (rationalizing) the square root from the numerator (not denominator!) of expressions.  The advantage of doing so in this case is that when r is very close to 1, your expression for b requires subtracting two sizable quantities which are nearly equal, which can created large round off errors, whereas in the other expression the round off error tends to be smaller.
>   I stand by my statement that the same formula is valid for cases when r is greater than 1 as well those in which r is less than or equal to 1.  Of course as I said before, when r is greater than 1 you need to cancel the refractive ray and use only reflection in situations where t1^2+t2*dot(N,N) becomes negative.
> Roger Stafford
Thanks. I guess I misread the previous email (numerator vs. denominator). It is indeed correct. The rationale behind derivation is valid for refraction with any r, I agree with you. I put a condition of if dot(P,N)/[norm(P)*norm(N)]<theta_critical to avoid getting negative value under sqrt and avoid calculation for when total reflection occurs. 

You have been very helpful. Thanks again.