|
![](/i/fill.gif) |
Ronald L. Parker wrote:
>
> On Fri, 01 Jan 1999 22:30:24 -0500, John VanSickle
> <van### [at] erols com> wrote:
>
> >Ronald L. Parker wrote:
> >>
> >> 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.
Yep, I misunderstood how the last two lines work together, but now that
I do, 2*par*nN-R is wrong by a factor of -1.
>
> 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,
Which is wrong, because the original ray is supposed to be *incoming*
(see the original post).
And it doesn't matter if the direction is reversed on the N vector;
multiplying N by <-1,-1,-1> causes par to be negated, which undoes the
negative scaling of N when par and nN are multiplied together.
Regards,
John
Post a reply to this message
|
![](/i/fill.gif) |