Skip to main content
GameDev.net gamedev.net
🔒 Locked

Point to Plane Classification

Started by Gammastrahler May 23, 2003 at 4:47 AM 0 replies 1.6k views
Original Post
Gammastrahler
Gammastrahler
Hi, i can classify a point to a plane this way: float dist = DotProduct(myPoint, myPlane.normal) + myPlane.d; if dist > EPSILON then point is in front of plane if dist < EPSILON then point is behind plane else point is on plane the problem is, this method works on any code, but not for my triangle splitting / bsp trees! to get my splitter / bsp working, i must use this code to classify a point to a plane:
  
vector3 myPointOnPlane = myPlane.Normal;
myPointOnPlane.Scale(-myPlane.d);
vector3 myVec = myPointOnPlane - myPoint;
float dist = DotProduct(myVec, myPlane.normal);

if dist > EPSILON then point is in front of plane
if dist > EPSILON then point is behind plane
else point is on plane
  
Can someone tell me why i only works with the second method in some cases? In either case, i only test points to a plane-it has nothing to do with flipping the greater/less, that was verified already. thanks Gammastrahler
v71
v71
Check your signs , actually you are performing the same operation

if dist > EPSILON then point is in front of plane
if dist > EPSILON then point is behind plane

change the last in

if dist < EPSILON then point is behind plane

not that this works only for a vertex, another kind of problem is
to classify an entire triangle
that a look at this piece of code



int VTree::ClassifyTriangle( float x1,float y1,float z1,
float x2,float y2,float z2,
float x3,float y3,float z3,
float px0,float py0,float pz0,
float a,float b,float c)
{

double t,denom,num;
int front,back,on;

front=0;
back=0;
on=0;

Vec3f p,v;

p.set(a,b,c);
denom=p.length();

if ( denom==0.0f ) denom+=BSPEPSILON;

v.set(x1-px0,y1-py0,z1-pz0);
num=dot(p,v);
t=num/denom;

if (t > BSPEPSILON)
front++;
else if (t < -BSPEPSILON )
back++;
else
{
front++;
back++;
on++;
}

v.set(x2-px0,y2-py0,z2-pz0);
num=dot(p,v);
t=num/denom;

if (t > BSPEPSILON)
front++;
else if (t < -BSPEPSILON )
back++;
else
{
front++;
back++;
on++;
}

v.set(x3-px0,y3-py0,z3-pz0);
num=dot(p,v);
t=num/denom;

if (t > BSPEPSILON)
front++;
else if (t < -BSPEPSILON )
back++;
else
{
front++;
back++;
on++;
}

if (on == 3)
return _COPLANAR;
else if (front == 3)
return _INSIDE ;
else if (back == 3 )
return _OUTSIDE;

return _DO_INTERSECT;

}

byez

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.