POV-Ray : Newsgroups : povray.general : the trace function and toroidal objects Server Time
4 Nov 2024 17:33:11 EST (-0500)
  the trace function and toroidal objects (Message 1 to 7 of 7)  
From: melundbe
Subject: the trace function and toroidal objects
Date: 30 Sep 2003 13:33:02
Message: <oprwbppd0lmulnlm@localhost>
I'm trying to slap randomly distributed objects onto an isosurface in the 
shape of a lumpy torus.  The only tool that I've found to help is the 
trace(OBJECT_IDENTIFIER, A, B, [VECTOR_IDENTIFIER]) function.  
Unfortunately, it only returns points on the "outside" part of the torus 
(ie. not inside the donut hole).  Is there any way I can make it trace to 
the entire torus?  Is there another function or macro that will do the 
job?

I can put the objects in a regular torus through some inventive vector 
math, but conquering the lumpiness is beyond my abilities, it seems.


Post a reply to this message

From: Christopher James Huff
Subject: Re: the trace function and toroidal objects
Date: 30 Sep 2003 16:47:07
Message: <cjameshuff-670827.16463330092003@netplex.aussie.org>
In article <oprwbppd0lmulnlm@localhost>, melundbe@mtu.edu wrote:

> I'm trying to slap randomly distributed objects onto an isosurface in the 
> shape of a lumpy torus.  The only tool that I've found to help is the 
> trace(OBJECT_IDENTIFIER, A, B, [VECTOR_IDENTIFIER]) function.  
> Unfortunately, it only returns points on the "outside" part of the torus 
> (ie. not inside the donut hole).  Is there any way I can make it trace to 
> the entire torus?  Is there another function or macro that will do the 
> job?

All you have to do is point it at part of the surface inside the hole. 
The trace() function will return the first intersection with the 
specified ray, no matter where on the surface it is. Given your 
description, I'm guessing you are shooting at the center of the torus 
from random positions outside of it...this obviously won't hit anything 
inside the torus.


> I can put the objects in a regular torus through some inventive vector 
> math, but conquering the lumpiness is beyond my abilities, it seems.

Not sure what lumpiness you mean. The distribution will not be even, but 
that's nothing I'd describe as lumpy.

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

From: melundbe
Subject: Re: the trace function and toroidal objects
Date: 1 Oct 2003 00:40:19
Message: <oprwckljrimulnlm@localhost>
I did some experiments and have reached the unambiguous conclusion that 
the trace function will not hit the inside of the torus.  If anyone can 
claim they're sure it works for them, I don't know what to say.  I'm using 
MegaPOV 1.0, by the way.


Post a reply to this message

From: Mike Williams
Subject: Re: the trace function and toroidal objects
Date: 1 Oct 2003 01:32:36
Message: <mwgFSCAFame$EwSJ@econym.demon.co.uk>
Wasn't it  who wrote:
>I did some experiments and have reached the unambiguous conclusion that 
>the trace function will not hit the inside of the torus.  If anyone can 
>claim they're sure it works for them, I don't know what to say.  I'm using 
>MegaPOV 1.0, by the way.

I came very close to agreeing with you (except that I was using POV 3.5)
My mistake was using  "trace(Shape,Q,P)" in the following code instead
of "trace(Shape,Q,P-Q)". Perhaps you're doing something simlar.

#include "functions.inc"

global_settings {assumed_gamma 1.0}

camera { location  <-1, 3, -4> look_at <0, 0, 0> angle 27}

background {rgb <0.5,0.6,0.7>}

light_source {<-100,200,-100> colour rgb 1}

#declare F_bozo=function{
  pigment{bozo
     colour_map {[0 rgb 0][1 rgb 1]}
     scale 0.2
  }
}

#declare Shape=
isosurface {
  function { f_torus(x,y,z,0.7,0.5) + F_bozo(x,y,z).grey*0.3}
        max_gradient 2
        contained_by{sphere {0,1.3}}
        pigment {rgb 0.1}
        finish {phong 0.5 phong_size 10}
}

object {Shape}

#declare A=0;
#while (A<360)
  #declare B=0;
  #while (B<360)
    #declare P = vrotate(vrotate(<0,0.5,0>,A*z) + x*0.7, B*y);
    #declare Q = vrotate(x*0.7, B*y);
    #declare T = trace(Shape,Q,P-Q);
    sphere {T,0.03 pigment {rgb 1}}
    #declare B=B+8;
  #end
  #declare A=A+15;
#end


Post a reply to this message

From: Christopher James Huff
Subject: Re: the trace function and toroidal objects
Date: 1 Oct 2003 08:59:50
Message: <cjameshuff-43D5C7.08583901102003@netplex.aussie.org>
In article <oprwckljrimulnlm@localhost>, melundbe@mtu.edu wrote:

> NOpe, I have objects both inside and outside the toroid, and the trace 
> simply ignores the intersections with the inside.  At least I'm pretty 
> confident that it is.  I'll check again.

Now I have no idea what you're describing. The trace() function has 
nothing to do with object-object intersections, and any objects not 
passed to trace() simply do not exist, as far as it is concerned.


> The lumpiness is a function that combines a bozo colormap and some others 
> with the f_torus, giving the torus a hilly landscape, or lumps.  This is 
> the reason I'm not simply constructing a torus through other means.

So you are tracing against an isosurface...should have paid more 
attention. Could be problems with max_gradient, or something with the 
locations you're tracing from confusing the isosurface solver.
As for vector math, you could pretty easily build it out of a mesh, like 
the height field macros in shapes.inc, and do something similar to 
project points onto its surface. The trace() function would still be the 
simplest way to find a point on the surface, though.


> I did some experiments and have reached the unambiguous conclusion that 
> the trace function will not hit the inside of the torus.  If anyone can 
> claim they're sure it works for them, I don't know what to say.  I'm using 
> MegaPOV 1.0, by the way.

Your conclusion is simply wrong. The trace() function, when used 
properly, will hit any part of the surface of an object. There is 
nothing special about these surfaces, except for the fact that the 
object is relatively inaccurate.

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

From: melundbe
Subject: Re: the trace function and toroidal objects
Date: 1 Oct 2003 09:39:47
Message: <oprwc9kks7mulnlm@localhost>
Funky! It worked!  Thank you Mike!

*reads documentation on trace() one more time*

Oh, so that's what it said.


> I came very close to agreeing with you (except that I was using POV 3.5)
> My mistake was using  "trace(Shape,Q,P)" in the following code instead
> of "trace(Shape,Q,P-Q)". Perhaps you're doing something simlar.
>
> #include "functions.inc"
>
> global_settings {assumed_gamma 1.0}
>
> camera { location  <-1, 3, -4> look_at <0, 0, 0> angle 27}
>
> background {rgb <0.5,0.6,0.7>}
>
> light_source {<-100,200,-100> colour rgb 1}
>
> #declare F_bozo=function{
>   pigment{bozo
>      colour_map {[0 rgb 0][1 rgb 1]}
>      scale 0.2
>   }
> }
>
> #declare Shape=
> isosurface {
>   function { f_torus(x,y,z,0.7,0.5) + F_bozo(x,y,z).grey*0.3}
>         max_gradient 2
>         contained_by{sphere {0,1.3}}
>         pigment {rgb 0.1}
>         finish {phong 0.5 phong_size 10}
> }
>
> object {Shape}
>
> #declare A=0;
> #while (A<360)
>   #declare B=0;
>   #while (B<360)
>     #declare P = vrotate(vrotate(<0,0.5,0>,A*z) + x*0.7, B*y);
>     #declare Q = vrotate(x*0.7, B*y);
>     #declare T = trace(Shape,Q,P-Q);
>     sphere {T,0.03 pigment {rgb 1}}
>     #declare B=B+8;
>   #end
>   #declare A=A+15;
> #end


Post a reply to this message

From: Dave Matthews
Subject: Re: the trace function and toroidal objects
Date: 1 Oct 2003 12:25:00
Message: <web.3f7aff2c137049fc10dd5cfd0@news.povray.org>
Mike Williams wrote:
>I came very close to agreeing with you (except that I was using POV 3.5)
>My mistake was using  "trace(Shape,Q,P)" in the following code instead
>of "trace(Shape,Q,P-Q)".

Actually, I think, if you replace:

>    #declare P = vrotate(vrotate(<0,0.5,0>,A*z) + x*0.7, B*y);

with:

#declare P = vrotate(vrotate(<0,0.5,0>,A*z), B*y);

and then replace:

>    #declare T = trace(Shape,Q,P-Q);

with:

#declare T = trace(Shape,Q,P);

you don't need to subtract vectors. . . . (I think. . . .)

(By the way, thanks for this example.  Thanks to it, I believe that I
finally figured out how "trace" works.  It's funny how with certain
examples a light bulb goes on, and with others, well, I just sit in the
dark and stare at the code -- kind of hard to read that way. )

Dave Matthews


Post a reply to this message

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