# Ray Collider problem

• THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 29/05/2009 at 02:03, xxxxxxxx wrote:

User Information:
Cinema 4D Version:   11
Platform:   Windows  ;   Mac OSX  ;
Language(s) :     C++  ;

---------
I need to control that the points of an object are inside to another polygon!
The only way that I found to do this, is to verify the 6 directions for every points (X,-X,Y,-Y,Z,-Z) if there is a collision in every direction the point is inside!
This is my code, the strange thing is that seems that some points (that are inside perfectly) failed the collider procedure (usually in one direction).
I tried this with 2 simple polygons, HEXA outside and Sphere inside!
I don't understand why? Where I make mistake?

Bool find_ext_pts(BaseObject *objin,BaseObject *objout,BaseSelect* Asel)
{
AutoAlloc<GeRayCollider> Objcollider;
Objcollider->Init(objout,FALSE);
Matrix mo2c=!objin->GetMg()*objout->GetMg();

const Vector* padr = ToPoint(objin)->GetPointR();
LONG pcnt = ToPoint(objin)->GetPointCount();
if (!pcnt) return FALSE;
Vector v,vdir;
LONG i,k;
Bool Res=FALSE;
for (i=0;i<pcnt;i++)
{
v=mo2c*padr _;//fit outsideobj coordinate
for (k=0;k<6;k++)//six tests
{
switch (k)
{
case 0:
{ vdir=Vector(1,0,0);
break;
}
case 1:
{ vdir=Vector(-1,0,0);
break;
}
case 2:
{ vdir=Vector(0,1,0);
break;
}
case 3:
{ vdir=Vector(0,-1,0);
break;
}
case 4:
{ vdir=Vector(0,0,1);
break;
}
case 5:
{ vdir=Vector(0,0,-1);
break;
}

}
if(!Objcollider->Intersect(v,vdir,100000,TRUE))
{
Asel->Select(i);
Res=TRUE;
break;
}
}
}
return Res;

}

• THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 29/05/2009 at 08:52, xxxxxxxx wrote:

Hi,

the problem is with precission of
Intersect() and 100000 !
You should keep max_distance as smalls as possible, preferable only diameter of bounding sphere of you object.

> <code>
> //something like this
> Real ray_length = Len(objin->GetRad()*2.01);
> //...
> if(!Objcollider->Intersect(v,vdir,ray_length,TRUE))
> //...
> </code>

Remo

• THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 29/05/2009 at 08:57, xxxxxxxx wrote:

Start with a bounding volume test (a spherical center-radius calculated from the points of the object). This will be a VERY quick first test for point containment: any point whose distance from the center is greater than the radius is not contained in the object. You can also use an AABB but the spherical test is faster.

After that, there are many methods out there, but mostly dealing with polyhedra (closed, convex surfaces). BSP tress and Convex hulls are two ways for more generalized determination. Your method seems close to the Jordan Curve Theorem method. The best that I can do is suggest this link for ideas:

http://www.tar.hu/gamealgorithms/ch22lev1sec1.html

• THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 29/05/2009 at 09:29, xxxxxxxx wrote:

Thank's Remo verymuch!
I tried it and seems work well now!
I didn't know this, I was thinking that was a problem of C4d collision library!

Thank again!

• THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 29/05/2009 at 09:36, xxxxxxxx wrote:

Thank's kuroyume0161,
The link is very interesting,
I'll read it carefully!