POV-Ray : Newsgroups : povray.general : Trace(): help required Server Time
12 Oct 2026 13:01:47 EDT (-0400)
  Trace(): help required (Message 1 to 20 of 20)  
From: Sven Littkowski
Subject: Trace(): help required
Date: 18 May 2006 15:52:36
Message: <446cd084@news.povray.org>
Greetings.

I was reading about the Trace() feature inside the POV-Ray documentation, 
but to be honest, I just cannot work it out. Who can help me understanding 
it entirely? There are so many YXZ coordinates.

Maybe a small very simple sample scene could help me, with some truly 
explaining words.

Thanks,

Sven


Post a reply to this message

From: Warp
Subject: Re: Trace(): help required
Date: 18 May 2006 16:17:42
Message: <446cd665@news.povray.org>
Sven Littkowski <sve### [at] jamaica-focuscom> wrote:
> Maybe a small very simple sample scene could help me, with some truly 
> explaining words.

// Declare an object you want to trace:
#declare AnObject =
  torus { 1, .5 pigment { rgb x } finish { specular .5 } };

// Let's "drop" cylinders on this object from above.
// First let's define the area inside which to "drop" cylinders
// (this covers the entire torus above viewed from above):
#declare MinX = -1.5;
#declare MaxX = 1.5;
#declare MinZ = -1.5;
#declare MaxZ = 1.5;
#declare DropHeight = 2;
#declare CylinderRadius = .015;
#declare NormalScale = .1;

// Now let's loop through all that area using regular steps:
#declare Normal = <0,0,0>;
#declare Step = .1;
#declare IndX = MinX;
#while(IndX <= MaxX)
  #declare IndZ = MinZ;
  #while(IndZ <= MaxZ)

    // Now let's "drop" a cylinder onto the torus:
    #declare Intersection =
      trace(AnObject, <IndX, DropHeight, IndZ>, -y, Normal);
    // The first parameter is the object to trace (ie. our torus).
    // The second parameter is the starting point for the trace
    // (like the point from which we "drop" our cylinder).
    // The third parameter is the direction towards which we trace
    // (ie. the direction towards which we "drop" the cyliner)
    // The last parameter is the normal vector at the intersection point
    // (this has two uses, as seen below).

    // Now, a normal vector <0,0,0> is invalid and thus trace() uses that
    // value to indicate that it did not intersect the object at all.
    // Thus we have to check that it is not <0,0,0> before we crate the
    // cylinder:
    #if(vlength(Normal) > 0)
      // Now we can create the cylinder at the intersection point.
      // To keep things interesting, let's orientate the cylinder in
      // the direction of the normal vector:
      cylinder
      { Intersection, Intersection+Normal*NormalScale, CylinderRadius
        pigment { rgb y }
        finish { specular .5 }
      }
    #end

    #declare IndZ = IndZ + Step;
  #end
  #declare IndX = IndX + Step;
#end


camera { location <0, 5, -5> look_at 0 angle 35 }
light_source { <100, 200, 0>, 1 }
object { AnObject }


Post a reply to this message

From: Mr Seb
Subject: Re: Trace(): help required
Date: 18 May 2006 16:20:47
Message: <446cd71f@news.povray.org>
An easy example :

you have an object, called Object...and you want to put another object at
the top of it, at the vertical of a <X,?,Z> point.
You can call it :

#declare coord=trace (Object,<X,100000,Z>,<0,-1,0>)

<X,1000,Z> is a point at the vertical of your object (take 100000 as high as
you wish, it must be higher than the heigh of your object)
<0,-1,0> is the down direction.
So Trace will shoot a ray from <X,10000,Y> downside and look if it hits your
object. If it does, it returns the intersection point. This point is the
coord where you want to put your new object.

For the 4 vectors version :
use as follows :
#declare coord=trace(Object,<X,100000,Z>,<0,-1,0>,norm)
it returns in coord the same vector than in the first example. It also
return the normal vector at this point in "norm"


Post a reply to this message

From: Sven Littkowski
Subject: Re: Trace(): help required
Date: 18 May 2006 20:39:59
Message: <446d13df$1@news.povray.org>
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



"Mr Seb" <ban### [at] wanadoofr> schrieb im Newsbeitrag 
news:446cd71f@news.povray.org...
> For the 4 vectors version :
> use as follows :
> #declare coord=trace(Object,<X,100000,Z>,<0,-1,0>,norm)
> it returns in coord the same vector than in the first example. It also
> return the normal vector at this point in "norm"
>
>


Post a reply to this message

From: Sven Littkowski
Subject: Re: Trace(): help required
Date: 18 May 2006 20:41:43
Message: <446d1447$1@news.povray.org>
Thanks for your answer, Wrap.

I rendered your example but just get the torus. But nevertheless, with your 
help and the help of Seb I do now understand a bit more of that trace 
feature. Still not very sure about it. I have to make some tests now.

Thanks a lot!

Sven


Post a reply to this message

From: Warp
Subject: Re: Trace(): help required
Date: 18 May 2006 21:15:09
Message: <446d1c1c@news.povray.org>
Sven Littkowski <sve### [at] jamaica-focuscom> wrote:
> I rendered your example but just get the torus.

  I can't even begin to fathom how that is possible.

-- 
                                                          - Warp


Post a reply to this message

From: Sven Littkowski
Subject: Re: Trace(): help required
Date: 18 May 2006 22:39:03
Message: <446d2fc7$1@news.povray.org>
Hi Warp,

hmm, not sure how to work your "comment" out...   :-)

Let me just give you the scene as I got it from you. Remember, I am an 
absolute beginner if it comes to the trace function.

Best greetings,

Sven


"Warp" <war### [at] tagpovrayorg> schrieb im Newsbeitrag 
news:446d1c1c@news.povray.org...
> Sven Littkowski <sve### [at] jamaica-focuscom> wrote:
>> I rendered your example but just get the torus.
>
>  I can't even begin to fathom how that is possible.
>
> -- 
>                                                          - Warp


#version 3.5;

// Declare an object you want to trace:
#declare AnObject = torus
{
 1.0, 0.5
 pigment { rgb x }
 finish { specular 0.5 }
}

// Let's "drop" cylinders on this object from above.
// First let's define the area inside which to "drop" cylinders
// (this covers the entire torus above viewed from above):
#declare MinX = -1.5;
#declare MaxX = 1.5;
#declare MinZ = -1.5;
#declare MaxZ = 1.5;
#declare DropHeight = 2;
#declare CylinderRadius = .015;
#declare NormalScale = .1;

// Now let's loop through all that area using regular steps:
#declare Normal = < 0.0, 0.0, 0.0 >;
#declare Step = 0.1;
#declare IndX = MinX;

#while(IndX <= MaxX)
 #declare IndZ = MinZ;
 #while(IndZ <= MaxZ)

  // Now let's "drop" a cylinder onto the torus:
  #declare Intersection = trace(AnObject < IndX, DropHeight, IndZ > -y, 
Normal);
  // The first parameter is the object to trace (ie. our torus).
  // The second parameter is the starting point for the trace
  // (like the point from which we "drop" our cylinder).
  // The third parameter is the direction towards which we trace
  // (ie. the direction towards which we "drop" the cyliner)
  // The last parameter is the normal vector at the intersection point
  // (this has two uses, as seen below).

  // Now, a normal vector <0,0,0> is invalid and thus trace() uses that
  // value to indicate that it did not intersect the object at all.
  // Thus we have to check that it is not <0,0,0> before we crate the
  // cylinder:
  #if(vlength(Normal) > 0)
   // Now we can create the cylinder at the intersection point.
   // To keep things interesting, let's orientate the cylinder in
   // the direction of the normal vector:
   cylinder
   {
    Intersection, Intersection+Normal*NormalScale, CylinderRadius
    pigment { rgb y }
    finish { specular .5 }
   }
  #end

  #declare IndZ = IndZ + Step;
 #end
 #declare IndX = IndX + Step;
#end


camera { location < 0.0, 5.0, -5.0 > look_at 0.0 angle 35 }

light_source { <100.0, 200.0, 0>, 1.0 }

object { AnObject }


Post a reply to this message

From: POVMAN
Subject: Re: Trace(): help required
Date: 19 May 2006 05:00:14
Message: <446d891e$1@news.povray.org>
> But what is a 4 vectors version? What is the NORM doing and about?
>
> Sven

The NORM is a Vector that represents the angle at which the ray being used 
in the trace function hits the object.

-- 
#####-----#####-----#####
POV Tips and Hints at ...
http://povman.blogspot.com/


Post a reply to this message

From: Warp
Subject: Re: Trace(): help required
Date: 19 May 2006 05:18:39
Message: <446d8d6d@news.povray.org>
Sven Littkowski <sve### [at] jamaica-focuscom> wrote:
> hmm, not sure how to work your "comment" out...   :-)

  It means: I don't understand how it is possible that you are getting
just a torus. The scene creates a big bunch of cylinders besides the
torus so I cannot understand how it is possible.
  Which version of POV-Ray are you using?

> Let me just give you the scene as I got it from you. Remember, I am an 
> absolute beginner if it comes to the trace function.

> #version 3.5;

  This wasn't in my scene.

>   #declare Intersection = trace(AnObject < IndX, DropHeight, IndZ > -y, 

  There are missing commas there. Why did you remove them?

-- 
                                                          - Warp


Post a reply to this message

From: Sven Littkowski
Subject: Re: Trace(): help required
Date: 19 May 2006 06:36:44
Message: <446d9fbc$1@news.povray.org>
Warp,

I am in shame! My life lost any sense, and my soul is now condemned for 
10,000 eons! You was right, actually!

I have a habit: whe ever I see the source code of scenes written by others, 
I at first transform it into my own way of writing (setting spaces aka 
blanks, just a kind of re-formatting). Now, what happened: I changed the 
formatting, and - you are so right - I removed commas. I usually don't use 
commas often, but made the experience that this was not giving any trouble. 
But here, it was leading to a somewhat different interpretion of the scene! 
Not an error message, just a scene without cylinders (which is, as a result, 
quite interesting).

I use for extensive testing the beta 12a version of POV-Ray.

I just replaced my formatting with your original, and it works! Sorry again, 
Warp. And also: deep thanks for having taken so much time and good intention 
to help! Please go on with that!   :-)

Greetings,

Sven


Post a reply to this message

From: Sven Littkowski
Subject: Re: Trace(): help required
Date: 19 May 2006 06:42:21
Message: <446da10d$1@news.povray.org>
Well, NOW I understand. Thanks, Povman!

That means, the norm function actually could be used like a rotate < x, y, z 
 > command? And if so, where would be the point of rotation - would that 
point be the point where the placable object hits via the trace command the 
surface of the traced object, or would it be the placable objects natural 
postion from its own X,Y,Z coordinates (as usual, otherwise)?

Hmmm, I guess, I have to look deeply into the given examples again. But I 
also would appreciate easy answers...

Thanks a lot, Povman,

Sven




"POVMAN" <s### [at] acom> schrieb im Newsbeitrag news:446d891e$1@news.povray.org...
> The NORM is a Vector that represents the angle at which the ray being used 
> in the trace function hits the object.


Post a reply to this message

From: Warp
Subject: Re: Trace(): help required
Date: 19 May 2006 08:27:27
Message: <446db9ae@news.povray.org>
Sven Littkowski <sve### [at] jamaica-focuscom> wrote:
> Now, what happened: I changed the 
> formatting, and - you are so right - I removed commas. I usually don't use 
> commas often, but made the experience that this was not giving any trouble. 

  You shouldn't remove commas because sometimes they are crucial.

  "a -b" is *not* the same thing as "a, -b".

-- 
                                                          - Warp


Post a reply to this message

From: Sven Littkowski
Subject: Re: Trace(): help required
Date: 19 May 2006 08:59:57
Message: <446dc14d@news.povray.org>
Yes, exactly that I found out. The error was caused just in the trace 
function. And because it is flexible with the amount of parameters. That 
was, what broke my neck!

:-)

Sven


"Warp" <war### [at] tagpovrayorg> schrieb im Newsbeitrag 
news:446db9ae@news.povray.org...
>  You shouldn't remove commas because sometimes they are crucial.
>  "a -b" is *not* the same thing as "a, -b".


Post a reply to this message

From: Sven Littkowski
Subject: Re: Trace(): help required
Date: 19 May 2006 09:15:32
Message: <446dc4f4$1@news.povray.org>
Hmmm, I still don't succeed. I want to randomly place a number of green 
cylinders onto the blob, just above and below the horizontal rectangular cut 
in the blob (lower edge of the picture).

What exactly do I do wrong? Please see below a simplified scene code.

Sven


#version 3.5;
#include "colors.inc"

#declare MittelRumpf=blob 
// 4er Frontgebilde
{
 threshold 0.3
 sphere { < 0.0, 0.0, 400.0 > 300.0, 1.5 }
 cylinder { < -450.0, 0.0, 400.0 > < 450.0, 0.0, 400.0 > 300.0, 1.0 scale < 
1.0, 1.0, 1.0 > } 
// Großes Bugsegment
 sphere { < 0.0, 0.0, 500.0 > 200.0, 1.0 }
 cylinder { < -50.0, 0.0, 500.0 > < 50.0, 0.0, 500.0 > 600.0, 1.0 scale < 
0.12, 1.0, 0.5 > } 
// Großes Bugsegment
 sphere { < 0.0, 0.0, 800.0 > 280.0, 1.0 scale < 1.0, 1.43, 1.0 > }
 cylinder { < 0.0, -50.0, 500.0 > < 0.0, 50.00, 500.0 > 300.0, 1.0 }
 scale < 1.0, 0.7, 1.0 >
}


#declare MitteFront=difference
{
 object { MittelRumpf }
 box { < -60.0, -400.0, -400.0 > < 60.0, 400.0, 1000.0 > } // 
........................................................................... 
Wegfall der vorderen Rumpfmitte
 box { < -400.0, -400.0, 250.0 > < 400.0, 400.0, 550.0 > } // 
........................................................................... 
Wegfall der Mitte quer
 box { < -200.0, -400.0, 400.0 > < 200.0, 400.0, 1000.0 > } // 
.......................................................................... 
Wegfall der Mitte bis nach hinten
 pigment { Red }
}

#declare MitteSeite=difference
{
 object { MittelRumpf }
 box { < -400.0, -400.0, -400.0 > < 400.0, 400.0, 650.0 > } // 
.......................................................................... 
Wegfall der Mitte und von Vorne
 box { < -150.0, -400.0, 400.0 > < 150.0, 400.0, 1000.0 > } // 
.......................................................................... 
Wegfall der Mitte bis nach hinten
 box { < 200.0, -400.0, 400.0 > < 400.0, 400.0, 1000.0 > } // 
........................................................................... 
Wegfall der hinteren Seite
 box { < -400.0, -400.0, 400.0 > < -200.0, 400.0, 1000.0 > } // 
......................................................................... 
Wegfall der hinteren Seite
 pigment { Red }
}

#declare MitteOben=difference
{
 object { MittelRumpf }
 box { < -400.0, -400.0, -400.0 > < -60.0, 400.0, 250.0 > }
 box { < 60.0, -400.0, -400.0 > < 400.0, 400.0, 250.0 > }
 box { < -400.0, -400.0, 550.0 > < -200.0, 400.0, 1000.0 > }
 box { < 200.0, -400.0, 550.0 > < 400.0, 400.0, 1000.0 > }
 box { < -400.0, -400.0, 650.0 > < -150.0, 400.0, 1000.0 > }
 box { < 150.0, -400.0, 650.0 > < 400.0, 400.0, 1000.0 > }
 pigment { Red }
}

#declare Basisrumpf=union
{
 object { MitteFront }
 object { MitteSeite }
 object { MitteOben }
}

#declare SechseckSensor=cylinder
{
 < 0.0, 0.0, 0.0 > < 0.0, 0.0, -5.0 > 5.0
 pigment { Green }
}

#declare Mittelsegment=difference
{
  union
  {
   object { Basisrumpf }  //
   #declare Runde=200;
   #declare Next=seed(60);
   #while(Runde<360)
    #declare MyNext=rand(Next);
    #declare Normal=< 0.0, 0.0, 0.0 >;
    #declare MySurface=trace( Basisrumpf, < Runde, 40, 2000.0 >, < Runde, 
40.0, 0.0 >, Normal );
    #if(vlength(Normal)>0)
     object { SechseckSensor scale < 1.0, 1.0, -1.0 > translate MySurface 
scale < 1.0, 1.0, 1.0 > }
     object { SechseckSensor scale < 1.0, 1.0, -1.0 > translate MySurface 
scale < -1.0, 1.0, 1.0 > }
     object { SechseckSensor scale < 1.0, 1.0, -1.0 > translate MySurface 
scale < 1.0, -1.0, 1.0 > }
     object { SechseckSensor scale < 1.0, 1.0, -1.0 > translate MySurface 
scale < -1.0, -1.0, 1.0 > }
    #end
    #declare Runde=Runde+5+(10*MyNext);
   #end
  }
  box { < -400.0, -400.0, 750.0 > < 400.0, 400.0, 1000.0 > pigment { Red } }
  box { < -460.0, -20.0, 0.0 > < 460.0, 20.0, 800.0 > pigment { Red } }
}

camera
{
 location < -400.0, 500.0, -1300.0 >
 look_at < -500.0, 300.0, -500.0 >
}

light_source
{
 < -1000000.0, -1000000.0, -5000.0 >
 color rgb < 0.99, 0.80, 0.47 > *4
}

light_source
{
 < -1000000.0, 1000000.0, 1000000.0 >
 color rgb < 0.2, 0.2, 0.3 > *4
}

 object { Mittelsegment rotate < 0.0, 180.0, 0.0 > }


Post a reply to this message

From: Warp
Subject: Re: Trace(): help required
Date: 19 May 2006 11:03:52
Message: <446dde57@news.povray.org>
Sven Littkowski <sve### [at] jamaica-focuscom> wrote:
> trace( Basisrumpf, < Runde, 40, 2000.0 >, < Runde, 40.0, 0.0 >, Normal );

  Are you sure you read my example scene carefully?

  More precisely, do you understand the difference between a point and
a direction vector?

-- 
                                                          - Warp


Post a reply to this message

From: Sven Littkowski
Subject: Re: Trace(): help required
Date: 19 May 2006 13:44:57
Message: <446e0419@news.povray.org>
Yes, usually I do. But to be honest, the trace thing is new, I easily could 
misunderstand, truly. If you look to the various "SF: Preview: Imperial 
Carrier" postings inside´the "povray.binaries.images" newsgroup, you can see 
what objects I do out of my mind (without any 3D editor).

But with your question you actually give me a hint, and I am looking now 
again into the scene, in hope to discover that thinking error. Sometimes you 
are so frustrated in finding out things, that you don't see the forest 
because of the many trees.

Thanks, greetings,

Sven





"Warp" <war### [at] tagpovrayorg> schrieb im Newsbeitrag 
news:446dde57@news.povray.org...
> Sven Littkowski <sve### [at] jamaica-focuscom> wrote:
>> trace( Basisrumpf, < Runde, 40, 2000.0 >, < Runde, 40.0, 0.0 >, Normal );
>
>  Are you sure you read my example scene carefully?
>
>  More precisely, do you understand the difference between a point and
> a direction vector?
>
> -- 
>                                                          - Warp


Post a reply to this message

From: Sven Littkowski
Subject: Re: Trace(): help required
Date: 19 May 2006 14:04:04
Message: <446e0894$1@news.povray.org>
Hello Warp,

I got now (finally) your point. I thought I could define the location of the 
ray more exactly to which location that ray is pointing to. I replaced it 
now with a simple "-z" and it works. Thanks, Warp,

Sven

>  More precisely, do you understand the difference between a point and
> a direction vector?


Post a reply to this message

From: Kenneth
Subject: Re: Trace(): help required
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

From: Kenneth
Subject: Re: Trace(): help required
Date: 22 May 2006 01:55:00
Message: <web.447150ec501983a81bc008390@news.povray.org>
"Kenneth" <kdw### [at] earthlinknet> wrote:
> The idea behind #if (vlength my_norm !=0) ...

Sorry, that should have been #if (vlength (my_norm) !=0)

BTW, you could instead use #if (vlength (my_norm) = 0) and simply rearrange
the parts in your #if......#else block to get the same results.

Ken


Post a reply to this message

From: Kenneth
Subject: Re: Trace(): help required
Date: 22 May 2006 02:45:00
Message: <web.44715ba0501983a81bc008390@news.povray.org>
"Sven Littkowski" <sve### [at] jamaica-focuscom> wrote:

> That means, the norm function actually could be used like a rotate < x, y, z
>  > command? And if so, where would be the point of rotation - would that
> point be the point where the placable object hits via the trace command the
> surface of the traced object, or would it be the placable objects natural
> postion from its own X,Y,Z coordinates (as usual, otherwise)?

Using the normal to try and rotate other already-created objects is not an
easy thing to accomplish.  True, it can be used quite well the way Warp has
shown, when actually CREATING an object at the traced intersection point.
But the results of doing something like, say,

object{my_small_object
 rotate my_norm*90 // to try and re-orient your small placed
                  // object according to the
                  // normal of the surface
 translate traced_intersection_point // putting each small object onto the
                                     // bigger traced object
            }

doesn't work out the way you might think. It *looks* like it works, sort of,
but the rotational results are not correct. I personally tried all sorts of
trigonometric trickery with the normal, and finally found a way to do this
(see below.)  But then I discovered the Point_At_Trans macro in
transforms.inc. With it, you can take any pre-created object -- made at the
origin--and rotate it using the my_norm vector. (It takes the +y vector
there and rotates it--and the object-- around to the my_norm vector.) Very
handy!!

My other way of doing it is this (using "dot notation" to pull out
individual vector values):
#declare x_degrees_reorient = degrees (atan2 (my_norm.y, my_norm.z));
#declare y_degrees_reorient = degrees (atan2 (my_norm.y, my_norm.x));

then rotate your pre-created object , while it's still at the origin, like
this:
rotate <90 - x_degrees_reorient, 0, z_degrees_reorient - 90)

then translate it to the traced location.

I can't guarantee that it has the EXACT same results as Point_At_Trans, but
it looks identical to me.

Ken W.


Post a reply to this message

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