|
![](/i/fill.gif) |
On Fri, 01 Jan 1999 22:30:24 -0500, John VanSickle
<van### [at] erols com> wrote:
>Ronald L. Parker wrote:
>>
>> On Thu, 31 Dec 1998 23:07:01 +0200, Margus Ramst <mar### [at] peak edu ee>
>> wrote:
>>
>> >Hi all, I'm once again having math trouble :(
>> >A macro I'm writing needs to calculate reflected vectors (it simulates
>> >reflected caustics in Superpatch, I'll probably post it soon...)
>> >However, the function I use to calculate the reflected vectors has 2
>> >shortcomings:
>>
>> Why not determine the component of the ray that does not lie along the
>>
>> normal vector, negate it, and add it back to the componenent that does
>> lie along the normal? something like this (untested) code:
>>
>> #macro mirror( R, N )
>> #local nN = vnormalize( N );
>> #local par = vdot( R, nN );
>> #local perp = R-par*nN;
>> par*nN-perp
>> #end
>
>The par*nN term needs to be doubled. I posted the correct code earlier.
If you don't mind my asking... um... which one, and why? The doubling
you seek is there, I think, in that if you put the last two lines
together you get par*nN-(R-par*nN) = 2*par*nN-R . I was just trying
to make it look a little less like magic and a little more like simple
math.
Or perhaps the difference can best be illuminated (heh) by some bad
ASCII art:
A
\ |
\ |
\ |
\|
N---*
/|\
/ | \
/ | \
/ | \
R P B
Assuming all the vectors are pointing away from the * at the center,
and the line marked with a P is of course the reflecting surface, I
was trying to provide the equation for the ray marked 'A'. I assume
you're assuming that R is pointing inward, in which case your answer
is correct for A. With my assumptions (admittedly chosen to make my
job easier) and your equation, one would get B. That's why I made
sure to make my assumptions about the parameters known:
>// This assumes that R is relative to the intersection point and
>// points AWAY from the intersection point. This is probably not
>// the way you have it set up if you're using the SuperPatch.
Post a reply to this message
|
![](/i/fill.gif) |