POV-Ray : Newsgroups : povray.general : Collision Detection Server Time
3 Aug 2024 16:19:11 EDT (-0400)
  Collision Detection (Message 1 to 2 of 2)  
From: Andrew McKay
Subject: Collision Detection
Date: 10 Dec 2003 00:53:26
Message: <3fd6b4d6@news.povray.org>
I'm working on some collision detection routines for a physics module I am
writing for POV.  Right now I'm writing a coarse collision detection routine
that basicall finds the bounding box for the objects, and sees if the
bounding boxes are intersecting.  ie.
        #local bounding_box1 = phylib_get_bounding_box(obj1)
       #local bounding_box2 = phylib_get_bounding_box(obj2)
       #local overlap = intersection{ object{bounding_box1}
object{bounding_box2} }

When the boxes are overlaping, I get an object returned, otherwise there is
shouldn't be an object.  How can I check if the variable 'overlap' actually
contains an object or not.  If I find the bounding_box for the 'overlap'
object when the boxes don't intersect, I get a box with corners at:
<-10000000000.0, -10000000000.0, -10000000000.0> and <10000000000.0,
10000000000.0, 10000000000.0>, otherwise I get a much smaller bounding box.

Will this be true for all objects that don't intersect?  Or is there another
way for me to check if the boxes are intersecting.  I could always write a
my own macro that took in the bounding boxes and checked to see if they were
intersecting instead of relying on the object returned by the intersection.


Post a reply to this message

From: Mike Williams
Subject: Re: Collision Detection
Date: 10 Dec 2003 03:47:57
Message: <+jW3EAAMSt1$Ew5b@econym.demon.co.uk>
Wasn't it Andrew McKay who wrote:
>I'm working on some collision detection routines for a physics module I am
>writing for POV.  Right now I'm writing a coarse collision detection routine
>that basicall finds the bounding box for the objects, and sees if the
>bounding boxes are intersecting.  ie.
>        #local bounding_box1 = phylib_get_bounding_box(obj1)
>       #local bounding_box2 = phylib_get_bounding_box(obj2)
>       #local overlap = intersection{ object{bounding_box1}
>object{bounding_box2} }
>
>When the boxes are overlaping, I get an object returned, otherwise there is
>shouldn't be an object.  How can I check if the variable 'overlap' actually
>contains an object or not.  If I find the bounding_box for the 'overlap'
>object when the boxes don't intersect, I get a box with corners at:
><-10000000000.0, -10000000000.0, -10000000000.0> and <10000000000.0,
>10000000000.0, 10000000000.0>, otherwise I get a much smaller bounding box.
>
>Will this be true for all objects that don't intersect?  Or is there another
>way for me to check if the boxes are intersecting.  I could always write a
>my own macro that took in the bounding boxes and checked to see if they were
>intersecting instead of relying on the object returned by the intersection.

To check for overlap of two bounding boxes you can do this:

#macro Collision(A,B)
  (#if (min_extent(A).x <= max_extent(B).x 
      & min_extent(B).x <= max_extent(A).x
      & min_extent(A).y <= max_extent(B).y
      & min_extent(B).y <= max_extent(A).y
      & min_extent(A).z <= max_extent(B).z
      & min_extent(B).z <= max_extent(A).z)
       1
  #else
       0
  #end)
#end

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

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