[Gllug] Algorithm question

salsaman salsaman at xs4all.nl
Wed Feb 28 14:51:53 UTC 2007


Adrian McMenamin wrote:

>I need to find an algorithm that will determine whether a cartesian
>point is inside a cube. Happy to look on google for such a thing, but I
>don't even know what it is called ... can anyone help (if you can find
>me a CAPAN module that does this even better, but I doubt whether one
>exists as I have been looking for some time now)
>
>  
>
You might want to look into the Open Dynamics Engine. I've not used it 
myself, but have heard good things about it:

http://www.ode.org/

I think Blender also uses it for object modelling. It might be overkill 
for what you want though. It can calculate collision geometries for 
multiple objects.

You could create a box class and a sphere class with radius of 1, and 
then position them and see if they collide using:

dContactGeom contact;

if (dCollide(o1,o2,1,&contact,sizeof(dContactGeom))) {
  // sphere o1 is inside box o2
}
else {
 // sphere o1 is outside box o2
}

...



Gabriel.
http://lives.sourceforge.net

-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list