Path: news.mathworks.com!not-for-mail
From: "Mahsa " <newsreader@mathworks.com>
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$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> <ir95nq$be6$1@newscl01ah.mathworks.com> <ir9mcc$kmm$1@newscl01ah.mathworks.com> <irbt3g$8el$1@newscl01ah.mathworks.com> <irc5p0$t0t$1@newscl01ah.mathworks.com> <irdsal$jjq$1@newscl01ah.mathworks.com> <ire089$34u$1@newscl01ah.mathworks.com>
Reply-To: "Mahsa " <newsreader@mathworks.com>
NNTP-Posting-Host: www-01-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1306222819 1543 172.30.248.46 (24 May 2011 07:40:19 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 24 May 2011 07:40:19 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2882983
Xref: news.mathworks.com comp.soft-sys.matlab:728388

"Roger Stafford" wrote in message <ire089$34u$1@newscl01ah.mathworks.com>...
> "Mahsa " <newsreader@mathworks.com> wrote in message <irdsal$jjq$1@newscl01ah.mathworks.com>...
> > 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
Hi,
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.