POV-Ray : Newsgroups : povray.general : Trace()? Server Time
20 Nov 2024 04:18:23 EST (-0500)
  Trace()? (Message 1 to 10 of 31)  
Goto Latest 10 Messages Next 10 Messages >>>
From: Mahalis
Subject: Trace()?
Date: 12 Nov 2001 19:08:47
Message: <3bf0648f$1@news.povray.org>
Could anyone explain to me exactly how one uses the trace() function to
detect object collisions? The docs say that 'trace() can be used to detect
the exact point a ray intersects a surface' and then gives a perfectly
incomprehensible (to me at least) example.

--

//Mahalis
camera{location<0,0.25,-2> look_at 0.5*y} #declare T=texture{pigment{crackle
scale 0.5 rotate 90 turbulence 0.75 color_map{[0 rgb 1][0.05 rgb 1][0.1
rgb<1,0.25,1>][0.25 rgbf 1][1 rgbf 1]}} finish{ambient 1}} #declare
c=difference{torus{0.5,0.1 rotate -90*x}box{<0.7,0,0.2>,<-0.7,-0.7,-0.2>}}
merge{object{c translate<0.5,0.5,0>} object{c translate<-0.5,0.5,0>}
cylinder{<1,0.5,0>,<1,0,0>,0.1} cylinder{<-1,0.5,0>,<-1,0,0>,0.1}
cylinder{0.5*y,0,0.1} texture{T}}
--


Post a reply to this message

From: Christoph Hormann
Subject: Re: Trace()?
Date: 13 Nov 2001 01:52:02
Message: <3BF0C313.DE3D24B8@gmx.de>
Mahalis wrote:
> 
> Could anyone explain to me exactly how one uses the trace() function to
> detect object collisions? The docs say that 'trace() can be used to detect
> the exact point a ray intersects a surface' and then gives a perfectly
> incomprehensible (to me at least) example.
> 

You will find une in the insert menu:

// trace function tests for intersection with a specified object

#declare Obj = sphere { 0, 1 }
#declare Norm = <0, 0, 0>;
#declare Start = <0.5, 0.5, 1>;
#declare Pos = trace (
                  Obj,             // object to test
                  Start,           // starting point
                  -z,              // direction
                  Norm );          // normal

// if intersection is found, normal differs from 0
#if (Norm.x != 0 | Norm.y != 0 | Norm.z != 0)
 //...
#end

Christoph

-- 
Christoph Hormann <chr### [at] gmxde>
IsoWood include, radiosity tutorial, TransSkin and other 
things on: http://www.schunter.etc.tu-bs.de/~chris/


Post a reply to this message

From: Warp
Subject: Re: Trace()?
Date: 13 Nov 2001 03:23:48
Message: <3bf0d894@news.povray.org>
Mahalis <don### [at] fakeycom> wrote:
: Could anyone explain to me exactly how one uses the trace() function to
: detect object collisions?

  If you mean that you want to detect if an object collided with another
object, regardless of shape, then that's one of the most difficult things
to do. Tracing can help a bit, but that's only perhaps 0.1% of everything you
need for that.

-- 
#macro N(D,I)#if(I<6)cylinder{M()#local D[I]=div(D[I],104);M().5,2pigment{
rgb M()}}N(D,(D[I]>99?I:I+1))#end#end#macro M()<mod(D[I],13)-6,mod(div(D[I
],13),8)-3,10>#end blob{N(array[6]{11117333955,
7382340,3358,3900569407,970,4254934330},0)}//                     - Warp -


Post a reply to this message

From:
Subject: Re: Trace()?
Date: 13 Nov 2001 03:48:17
Message: <ucn1vt8lo1a1ebi08ehvjgv93g1u6r4dvf@4ax.com>
On Mon, 12 Nov 2001 19:10:25 -0500, "Mahalis" <don### [at] fakeycom> wrote:

> Could anyone explain to me exactly how one uses the trace() function to
> detect object collisions? The docs say that 'trace() can be used to detect
> the exact point a ray intersects a surface' and then gives a perfectly
> incomprehensible (to me at least) example.

You are talking about 3.5, right? Check trace.pov and trace2.pov in
POV3.5/scenes/language/ directory.

ABX
--
#declare _=function(a,b,x){((a^2)+(b^2))^.5-x}#default {pigment{color rgb 1}}
union{plane{y,-3}plane{-x,-3}finish{reflection 1 ambient 0}}isosurface{ //ABX
function{_(x-2,y,1)|_((x+y)*.7,z,.1)|_((x+y+2)*.7,z,.1)|_(x/2+y*.8+1.5,z,.1)}
contained_by{box{<0,-3,-.1>,<3,0,.1>}}translate z*15finish{ambient 1}}//POV35


Post a reply to this message

From: Mahalis
Subject: Re: Trace()?
Date: 13 Nov 2001 18:11:55
Message: <3bf1a8bb$1@news.povray.org>
I didn't exactly mean 'colliding' as in 'running into'; I meant 'colliding'
as in 'intersecting'.

--

//Mahalis
camera{location<0,0.25,-2> look_at 0.5*y} #declare T=texture{pigment{crackle
scale 0.5 rotate 90 turbulence 0.75 color_map{[0 rgb 1][0.05 rgb 1][0.1
rgb<1,0.25,1>][0.25 rgbf 1][1 rgbf 1]}} finish{ambient 1}} #declare
c=difference{torus{0.5,0.1 rotate -90*x}box{<0.7,0,0.2>,<-0.7,-0.7,-0.2>}}
merge{object{c translate<0.5,0.5,0>} object{c translate<-0.5,0.5,0>}
cylinder{<1,0.5,0>,<1,0,0>,0.1} cylinder{<-1,0.5,0>,<-1,0,0>,0.1}
cylinder{0.5*y,0,0.1} texture{T}}
--


"Warp" <war### [at] tagpovrayorg> wrote in message
news:3bf0d894@news.povray.org...
> Mahalis <don### [at] fakeycom> wrote:
> : Could anyone explain to me exactly how one uses the trace() function to
> : detect object collisions?
>
>   If you mean that you want to detect if an object collided with another
> object, regardless of shape, then that's one of the most difficult things
> to do. Tracing can help a bit, but that's only perhaps 0.1% of everything
you
> need for that.
>
> --
> #macro N(D,I)#if(I<6)cylinder{M()#local D[I]=div(D[I],104);M().5,2pigment{
> rgb M()}}N(D,(D[I]>99?I:I+1))#end#end#macro M()<mod(D[I],13)-6,mod(div(D[I
> ],13),8)-3,10>#end blob{N(array[6]{11117333955,
> 7382340,3358,3900569407,970,4254934330},0)}//                     - Warp -


Post a reply to this message

From: Redbeard
Subject: Re: Trace()?
Date: 13 Nov 2001 23:07:06
Message: <3bf1edea$1@news.povray.org>
"Warp" <war### [at] tagpovrayorg> wrote in message news:3bf0d894@news.povray.org...
> Mahalis <don### [at] fakeycom> wrote:
> : Could anyone explain to me exactly how one uses the trace() function to
> : detect object collisions?
>
>   If you mean that you want to detect if an object collided with another
> object, regardless of shape, then that's one of the most difficult things
> to do. Tracing can help a bit, but that's only perhaps 0.1% of everything you
> need for that.
>
This reminds me, I just thought of something for my 4.0 wishlist.  A function
like inside that works for objects instead of vectors, as in:

    #declare A = sphere { 0, 1 }
    #declare B = sphere { 0.5*x,1 }
    #if (intersect(A,B)) #debug "A intersects B\n" #end

That would make collision detection *much* easier.

Hmmm... is this always guaranteed to work?
    #include "stdinc.inc"
    #include "shapes.inc"

    #declare A = sphere { 0, 1 }
    #declare B = box { 2, 3 }
    #declare Min = x*0;
    #declare Max = x*0;
    Extents(intersection { object { A } object { B } }, Min, Max)
    #if (!VEq(Max,<10000000000,10000000000,10000000000>)) #debug "A intersects
B\n"
    #else #debug "A does not intersect B\n"
    #end

    #debug concat(VStr(Min), "  ", VStr(Max))

I would suppose it depends on what POV-Ray assigns as the Min/Max for a
degenerate bounding box.  And if the DBB is always possible to detect.

It appears to work with primatives and small CSGs... but I could be wrong.
Haven't tested it much.

Any thoughts?

Michael

--
#macro M(D)#local J=strlen(D);#local _=""#while(J>0)#local _=concat(_,substr(D
,J,1))#local J=J-1;#end _#end sphere{z*9,5pigment{rgb x}}#macro N(D,J)text{ttf
"timrom.ttf"M(D)1,0 translate-J}#end#macro O(E,K)#local _=N(E,K)light_source{-
z*9rgb 1projected_through{_}}#end O("leahciM"<1.6,-.3.9>)O("nosnhoJ"<1.6.9.9>)


Post a reply to this message

From: Warp
Subject: Re: Trace()?
Date: 14 Nov 2001 01:33:29
Message: <3bf21039@news.povray.org>
Mahalis <don### [at] fakeycom> wrote:
: I didn't exactly mean 'colliding' as in 'running into'; I meant 'colliding'
: as in 'intersecting'.

  The problem is still exactly the same and exactly as difficult.

-- 
#macro N(D,I)#if(I<6)cylinder{M()#local D[I]=div(D[I],104);M().5,2pigment{
rgb M()}}N(D,(D[I]>99?I:I+1))#end#end#macro M()<mod(D[I],13)-6,mod(div(D[I
],13),8)-3,10>#end blob{N(array[6]{11117333955,
7382340,3358,3900569407,970,4254934330},0)}//                     - Warp -


Post a reply to this message

From: Warp
Subject: Re: Trace()?
Date: 14 Nov 2001 01:36:41
Message: <3bf210f9@news.povray.org>
Redbeard <red### [at] wvadelphianet> wrote:
: This reminds me, I just thought of something for my 4.0 wishlist.  A function
: like inside that works for objects instead of vectors, as in:

:     #declare A = sphere { 0, 1 }
:     #declare B = sphere { 0.5*x,1 }
:     #if (intersect(A,B)) #debug "A intersects B\n" #end

  As I said, that's extremely difficult to implement for any given object.
Of course it's trivial for spheres, but if you want to support any object,
you are approximating the impossible.

:     Extents(intersection { object { A } object { B } }, Min, Max)

  Note that even if the bounding boxes of the objects intersect, that doesn't
mean that the objects themselves do.

: It appears to work with primatives

  Again that word...

-- 
#macro N(D,I)#if(I<6)cylinder{M()#local D[I]=div(D[I],104);M().5,2pigment{
rgb M()}}N(D,(D[I]>99?I:I+1))#end#end#macro M()<mod(D[I],13)-6,mod(div(D[I
],13),8)-3,10>#end blob{N(array[6]{11117333955,
7382340,3358,3900569407,970,4254934330},0)}//                     - Warp -


Post a reply to this message

From: Ken
Subject: Re: Trace()?
Date: 14 Nov 2001 01:47:48
Message: <3BF213CD.3CBDBBC7@pacbell.net>
Warp wrote:

> : It appears to work with primatives
> 
>   Again that word...

I'll teach them to stop using "that" word if you stop using "drastical" :)

-- 
Ken Tyler


Post a reply to this message

From: Warp
Subject: Re: Trace()?
Date: 14 Nov 2001 02:00:58
Message: <3bf216a9@news.povray.org>
Ken <tyl### [at] pacbellnet> wrote:
: I'll teach them to stop using "that" word if you stop using "drastical" :)

  Some english words confuse me a lot.
  The word "drastically" exists. By logic, it would come from the word
"drastical" (drastical + ly = drastically).
  But no, it comes from the word "drastic".
  By reverse logic, it would mean that drastic + ly = drasticly.
  But no, it's drastic + ly = drasticALly.
  It makes no sense.

-- 
#macro N(D,I)#if(I<6)cylinder{M()#local D[I]=div(D[I],104);M().5,2pigment{
rgb M()}}N(D,(D[I]>99?I:I+1))#end#end#macro M()<mod(D[I],13)-6,mod(div(D[I
],13),8)-3,10>#end blob{N(array[6]{11117333955,
7382340,3358,3900569407,970,4254934330},0)}//                     - Warp -


Post a reply to this message

Goto Latest 10 Messages Next 10 Messages >>>

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