POV-Ray : Newsgroups : povray.general : Help Trace (easy) Server Time
7 Nov 2024 00:18:56 EST (-0500)
  Help Trace (easy) (Message 1 to 6 of 6)  
From: Jettero Heller
Subject: Help Trace (easy)
Date: 16 Feb 2004 12:49:26
Message: <slrnc320l5.acv.povfan@corky.voltar-confed.org>
I've been searching for this for a while, so either I don't know
how to search for it, or it's not asked as often as I'd think.

I have a very round object made up of the intersection/union of
several toruses and spheres.  I wish to find it's maximum
diameter in the XZ plane...

It strikes me that that should be very easy to do, but I can't
seem to wrap my mind around "Calculating the closest
intersection" from the pov docs.

http://www.povray.org/documentation/view/117/

Is there an easy way to find the diameter by shooting the object
with a couple rays?  Or am I better off trying to figure out the
complicated geometry of the thing?

-- 
If riding in an airplane is flying, then riding in a boat is swimming.
50 jumps, 15.0 minutes of freefall, 31.3 ff vertical miles.


Post a reply to this message

From: Ken
Subject: Re: Help Trace (easy)
Date: 16 Feb 2004 20:42:48
Message: <40317219.F8136F89@pacbell.net>
Jettero Heller wrote:

> I have a very round object made up of the intersection/union of
> several toruses and spheres.  I wish to find it's maximum
> diameter in the XZ plane...

max_extent and min_extent should get you close -
http://www.povray.org/documentation/view/138/

-- 
Ken Tyler


Post a reply to this message

From: Mike Williams
Subject: Re: Help Trace (easy)
Date: 17 Feb 2004 01:03:11
Message: <d0mPBIAqzaMAFwbs@econym.demon.co.uk>
Wasn't it Ken who wrote:
>
>
>Jettero Heller wrote:
>
>> I have a very round object made up of the intersection/union of
>> several toruses and spheres.  I wish to find it's maximum
>> diameter in the XZ plane...
>
>max_extent and min_extent should get you close -
>http://www.povray.org/documentation/view/138/

That only gives you the size of the bounding box that POV generates. In
the case of intersections, I believe that POV uses the intersection of
the bounding boxes of the components. This can be a very loose fit in
some circumstances. 

For example, consider this:

camera {location  <0.45,2,0.45> look_at <0.45,0,0.45>}
background {rgb 1}
light_source {<-30, 100, -30> color rgb 1}

#declare THING = 
intersection {
  torus {1,0.22 translate <0.9,0,0>}
  torus {1,0.22 translate <0,0,0.9>}
  torus {1,0.22}
  pigment {rgb 1}
}

object {THING}

box {min_extent(THING),max_extent(THING)
  pigment {rgbt <1,0,0,0.9>}
}

The pink box shows the min_extent and max_extent size, but the actual
intersection object is very much smaller. 

It would be tricky to use trace() on this object unless you already had
a clue about where the tori intersect. If you just trace() rays through
the centre of the bounding box, then most such rays miss the object
completely.

I tried writing some code that did a horizontal scan, using trace to
find the greatest diameter in the x direction, then rotated around the
centre point of that diameter, tracing for the greatest diameter in any
direction. In this particular case, such a scan miserably fails to find
the overall maximum diameter.

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: Jettero Heller
Subject: Re: Help Trace (easy)
Date: 17 Feb 2004 07:00:31
Message: <slrnc340iu.gad.povfan@corky.voltar-confed.org>
In article <d0m### [at] econymdemoncouk>, Mike Williams wrote:
> box {min_extent(THING),max_extent(THING)
>   pigment {rgbt <1,0,0,0.9>}
> }

I've never heard of these extents... They got me fairly close.
http://www.voltar.org/tmp/goban2.snaps/extents.png

> It would be tricky to use trace() on this object unless you ...

The shape isn't very irregular, so it shouldn't be difficult to
tune the trace -- if I had any idea how to use it.  I don't
understand how to use trace at all.  I would really appreciate an
example.

I just re-read the trace section and didn't really even turn up a
hint as to how to call/use the macro.

-- 
If riding in an airplane is flying, then riding in a boat is swimming.
50 jumps, 15.0 minutes of freefall, 31.3 ff vertical miles.


Post a reply to this message

From: Tom Melly
Subject: Re: Help Trace (easy)
Date: 17 Feb 2004 08:03:16
Message: <40321114$1@news.povray.org>
"Jettero Heller" <pov### [at] voltar-confedorg> wrote in message
news:slr### [at] corkyvoltar-confedorg...

> I just re-read the trace section and didn't really even turn up a
> hint as to how to call/use the macro.

Really? (6.1.4.5)

Here's an example that returns the Max and Min values for Z for a sphere
centered at 0 when traced from a negative z direction
(as you would expect, the max value is a little less than 0, since the trace
cannot hit the other side of the sphere where z would be a positive value).

#declare Thing = sphere{0,1} //an object to perform the trace on
#declare MyX = -10; // start x position for trace
#declare MinZ = 100;    // a silly value
#declare MaxZ = -100; // another silly value
#declare StepX = 0.001; // how much to increase the x position by on each trace
#declare Towards = <0,0,1>; // direction to trace towards
#declare MyNormal = <0,0,0>; // a vector to hold the returned normal
#while(MyX < 10) // a while loop
  #declare From = <MyX, 0, -10>; // set the initial vector for the trace
  #declare MyTrace = trace(Thing, From, Towards, MyNormal); // do the trace
  #if(vlength(MyNormal)!=0)  // check that the normal isn't <0,0,0> (which would
mean that we missed the object)
    #debug concat("Z=", str(MyTrace.z, 0,5), "\n") //output the current z value
    #if(MyTrace.z < MinZ) #declare MinZ = MyTrace.z; #end // record a new min if
appropriate
    #if(MyTrace.z > MaxZ) #declare MaxZ = MyTrace.z; #end // recored a new max
if appropriate
  #end
  #declare MyX = MyX+StepX; // increment the x-trace position for the next pass
#end

#debug concat("Min Z = ", str(MinZ, 0, 5), "\n") // output the min value for z
that was found
#debug concat("Max Z = ", str(MaxZ, 0, 5), "\n") // output the max value for z
that was found


Post a reply to this message

From: Jettero Heller
Subject: Re: Help Trace (easy)
Date: 17 Feb 2004 08:30:33
Message: <slrnc345rn.9np.povfan@corky.voltar-confed.org>
In article <40321114$1@news.povray.org>, Tom Melly wrote:
>> I just re-read the trace section and didn't really even turn up a
>> hint as to how to call/use the macro.
> 
> Really? (6.1.4.5)

No, 4.2.8.  6.1.4.5 is awesome.  I miss the old documentation
search, I was awesome at it.  The new google one is less
pov-specific.  6.1.4.5 couldn't be any clearer, thanks.



I also found a way to use min and max_extent to find the edges.
    http://www.voltar.org/tmp/goban2.snaps/extents2.png


So now I have two solutions,
    Thanks everyone.

-- 
If riding in an airplane is flying, then riding in a boat is swimming.
50 jumps, 15.0 minutes of freefall, 31.3 ff vertical miles.


Post a reply to this message

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