POV-Ray : Newsgroups : povray.newusers : Trace function for dummies? [POVray version 3.6.2] Server Time
24 Nov 2024 06:39:01 EST (-0500)
  Trace function for dummies? [POVray version 3.6.2] (Message 1 to 6 of 6)  
From: Amazon warrior
Subject: Trace function for dummies? [POVray version 3.6.2]
Date: 15 Sep 2009 14:30:00
Message: <web.4aafdc0ae494cb18458bbea60@news.povray.org>
Hello!  While I'm not exactly a new user of POVray, this has been bugging me on
and off almost since I started raytracing.  I just *cannot* wrap my head round
the trace function!  My usual approach of taking the example and changing it to
see what happens is not working here, for some reason.  It's very irritating
because I feel I'm missing something small and crucial, but I find the tut in
the POVray help file rather scanty and most of the examples I've found online
are a lot more complex than I want, which makes breaking them down into
comprehensible bits for easy digestion a challenge.  It probably doesn't help
that I've had no formal progamming training.

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!

At the moment, what I would like to do is place some objects on the following
isosurface.  Some of them will be individual, others I would like in rows or
groups and they should ideally conform to the shape of the surface.

#declare fn_Pigm_01 = function {
 pigment {
  bozo
  turbulence 0.5
  colour_map {
   [0 colour rgb 0]
   [1 colour rgb 1]
  }
  scale 0.5
  rotate y*-64
  translate <0.3,0,0>
 }
}

#declare Map = union {
 isosurface {
  function { y-fn_Pigm_01(x/1.5,y/3,z/2).gray*0.7 }
  pigment { Yellow }
 }
}

[I have the y-axis vertical and the x-axis parallel to the plane of the screen,
if it matters.]

Thank you once again for reading this and for any help or comments, and sorry
for being so dense!


Post a reply to this message

From: Warp
Subject: Re: Trace function for dummies? [POVray version 3.6.2]
Date: 15 Sep 2009 16:14:25
Message: <4aaff5a1@news.povray.org>
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

From: Amazon warrior
Subject: Re: Trace function for dummies? [POVray version 3.6.2]
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

From: Christian Froeschlin
Subject: Re: Trace function for dummies? [POVray version 3.6.2]
Date: 15 Sep 2009 19:22:26
Message: <4ab021b2$1@news.povray.org>
Amazon_warrior wrote:

> 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?

It requires a significant amount of parse time ... basically you use
trace to place your first object, then bombard it with a lot of traces
in a loop to find the lowest point (with some probability), place the
second object and so on. Gets a lot worse if your objects have
irregular shape and you want them to touch but not intersect.


Post a reply to this message

From: Amazon warrior
Subject: Re: Trace function for dummies? [POVray version 3.6.2]
Date: 16 Sep 2009 03:40:01
Message: <web.4ab095e4d1eccc14e2ea8efe0@news.povray.org>
Christian Froeschlin <chr### [at] chrfrde> wrote:
> Amazon_warrior wrote:
>
> > 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?
>
> It requires a significant amount of parse time ... basically you use
> trace to place your first object, then bombard it with a lot of traces
> in a loop to find the lowest point (with some probability), place the
> second object and so on. Gets a lot worse if your objects have
> irregular shape and you want them to touch but not intersect.

Ok, I suspected it might.  It's probably somewhat ambitious for someone who's
barely mastered the basics of the trace function, too.  Happily, I have found a
handwavy solution for what I wanted to do.  Thanks for your help!


Post a reply to this message

From: Bald Eagle
Subject: Re: Trace function for dummies? [POVray version 3.6.2]
Date: 29 Jul 2013 04:05:02
Message: <web.51f62145d1eccc1473fc9ebb0@news.povray.org>
I wrote a tutorial on the trace function that shows how it works.

http://news.povray.org/web.51f61e827603294573fc9ebb0%40news.povray.org

Hope this helps people.


Post a reply to this message

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