POV-Ray : Newsgroups : povray.newusers : Reflection vector : Re: Reflection vector Server Time
30 Jul 2024 12:28:56 EDT (-0400)
  Re: Reflection vector  
From: Christopher James Huff
Date: 29 Mar 2004 13:10:43
Message: <cjameshuff-DACA7D.13110929032004@news.povray.org>
In article <Xns94BBCAC843AF8raf256com@203.29.75.35>,
 "Rafal 'Raf256' Maj" <spa### [at] raf256com> wrote:

> Ray coming from point A is intersecting with a plane in point P, with 
> normal N. How count Q that vector NQ would be direction of light bounced of  
> plane?

It doesn't work that way. If Q is a scalar, N*Q would differ from N only 
in magnitude. If it's a vector, the dot product of N and Q would be a 
scalar, and the cross product would be perpendicular to both of them, 
which would not be the case for a reflected ray.

Here's working code from my own raytracer, which should be pretty clear:

    const Vect3D & dir = isect.ray.direction;
    const Vect3D & norm = isect.normal;

    Vect3D reflDir = dir - (norm*dir.dot(norm)*2);
    reflDir.normalize();

A quick Google for "reflected ray" will turn up more information.

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: <chr### [at] tagpovrayorg>
http://tag.povray.org/


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.