POV-Ray : Newsgroups : povray.newusers : Trace function for dummies? [POVray version 3.6.2] : Re: Trace function for dummies? [POVray version 3.6.2] Server Time
5 Oct 2024 16:19:59 EDT (-0400)
  Re: Trace function for dummies? [POVray version 3.6.2]  
From: Amazon warrior
Date: 15 Sep 2009 18:15:00
Message: <web.4ab011cdd1eccc14458bbea60@news.povray.org>
Ah!  Turns out I had it bass ackwards and upside down.  It all makes more sense
now.  Thank you so much for your help!  :)

A vaguely related question:  Is it possible to get POVray place an object, then
analyse the surface immediately around that point and place the next object at
a new point with specific properties (such as the highest or lowest)?  If it is
possible, how would one go about doing it?  Would something like this require a
ridiculous amount of render time?

Warp <war### [at] tagpovrayorg> wrote:
> Amazon_warrior <nomail@nomail> wrote:
> > If someone could break down (preferably in words of one syllable!) the component
> > parts of the trace function; such as the purpose, suggested parameters, what's
> > essential and what's not, etc., I would be embarassingly grateful!
>
>   The first parameter to the trace() function is, rather obviously, the
> object being traced. Thus you have to #declare an object, and then use this
> #declared identifier as the first parameter.
>
>   The second parameter specifies the starting point of the ray to be traced.
> Normally this starting point should be somewhere outside the object, at the
> direction from which the ray should be traced. For example, if your object
> was a sphere of radius 1 located at the origin, and you wanted to trace a
> ray directly from above, the starting point of this ray could be, for example,
> <0, 2, 0> (or anything else above <0, 1, 0>).
>   The exact location of the starting point depends on what is it exactly
> that you want to do. You'll have to figure out that first (ie. what is it
> exactly that you want to do) before you can come up with the starting points.
>
>   The third parameter specifies the direction towards which the ray should
> be traced. This is a direction vector, not a point in space. Thus, in the
> example above, if you want to trace the ray directly downwards, this parameter
> would be <0, -1, 0> (ie. a vector pointing towards the negative y axis).
> As this is a direction vector, it doesn't matter what the starting point is,
> the ray will always be traced directly downwards from that starting point.
>
>   The fourth parameter, if specified, should be the name of a vector
> identifier. The normal vector of the object being traced at the intersection
> point will be stored there. This normal vector can be useful for many things
> (such as reorienting objects so that they are perpendicular to the surface
> of the traced object). Most importantly, this normal vector can be used to
> determine whether the ray hit the object or not. If the length of the
> normal vector is 0, then the traced ray did not hit the object (you can
> check this by using the vlength() function).
>
>   trace() returns the hit point, or <0,0,0> if the object was not hit
> (as mentioned, the only way to make sure whether it hit the object or not
> is to check the normal vector; it's possible for the hit point to be
> exactly at <0,0,0>, so the checking has to be done with the normal vector).
>
> --
>                                                           - Warp


Post a reply to this message

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