POV-Ray : Newsgroups : povray.general : Trace(): help required : Re: Trace(): help required Server Time
1 Aug 2024 08:21:42 EDT (-0400)
  Re: Trace(): help required  
From: Kenneth
Date: 22 May 2006 01:20:01
Message: <web.447148d7501983a81bc008390@news.povray.org>
"Sven Littkowski" <sve### [at] jamaica-focuscom> wrote:
> Hi Seb,
>
> many thanks and my appreciation for your answer. I understand now the 3
> vectors version.
>
> But what is a 4 vectors version? What is the NORM doing and about?
>
> Sven

Hi, Sven!  I feel your pain--it took me awhile to understand trace( ) as
well. But it's certainly one of the *coolest* features of POV.

It may not be clear from the discussions so far that the 4th parameter--the
normal of the surface found at the traced intersection point--is optional.
You can leave it out.  But if you do use it, you first have to #declare a
"dummy" value for it, the usual way being #declare my_norm = <0,0,0>.  But
it could have any three vector values to begin with, because the trace
operation will "fill" it each time with its own found value. It took me
awhile to understand that myself. That is, unlike the values you SUPPLY to
the first three parameters, the 4th parameter actually GIVES BACK a vector
value for each trace "ray" shot, which can be used for other things.  And
like Warp says, the found normal is VERY useful in finding out IF a trace
ray has actually hit your main object.. The idea behind #if (vlength
my_norm !=0) --that is, "not equal to zero"--is that, if a trace ray
doesn't hit your main object, trace returns a location of <0,0,0> AND
automatically fills the 4th parameter with <0,0,0>.The vlength (vector
length) of such a "vector" is zero. You can then make a simple #if...#else
block to keep your code from creating an object in such a case. (All such
objects would otherwise be placed one on top of the other, all at location
<0,0,0>.)

Ken W.


Post a reply to this message

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