Skip to main content
gamedev.net
🔒 Locked

classify point

Started by soggie Mar 3, 2004 at 3:57 AM 2 replies 1.9k views
Original Post
soggie
soggie
ok here''s what my plane class has [class plane] member variables: vector3 normal float intercept member function: int classifyPoint(vector3 p) begin float distance = (p.x * normal.x) + (p.y * normal.y) + p.z * normal.z) + intercept if (distance > 0.01f) return POINT_IN_FRONT_OF_PLANE; else if(distance < -0.01f) return POINT_BEHIND_PLANE; else return POINT_ON_PLANE; end is this the correct way to classify a point?
"Darkness cannot drive out darkness, only Light can do that. Hate cannot drive out hate, only Love can do that."
Zipster
Zipster
Depends on how you calculated the intercept, and whether you already negated it or not. Usually, if you just took the dot product between the normal and a point on the plane to find it, you would subtract later on, but if you negated it already then you add. Experiment a bit to see which one gives you the right direction.

Also, 0.01 might be a tad big for an epsilon value. You might also try tweaking that if you get too many points on the plane.
Fantasio
Fantasio


[edited by - Fantasio on March 4, 2004 11:23:34 AM]
raydog
raydog
Determining if a point is visible to a plane comes from the plane equation:

Ax + By + Cz + D = 0
P.N + D = 0
D = -P.N

So, D is the negative DotProduct of your test point and the plane's normal.

Did you grab that example from some demo source code, like Pauls Project's? He has a function like that uses the word 'intercept':


void CalculateIntercept(const VECTOR3D & pointOnPlane) { intercept=-normal.DotProduct(pointOnPlane); }

int
PLANE::ClassifyPoint(const VECTOR3D & point) const
{
float distance=point.x*normal.x + point.y*normal.y + point.z*normal.z + intercept;

if(distance>EPSILON) //==0.0f is too exact, give a bit of room
return POINT_IN_FRONT_OF_PLANE;

if(distance<-EPSILON)
return POINT_BEHIND_PLANE;

return POINT_ON_PLANE; //otherwise
}



[edited by - raydog on March 5, 2004 4:58:15 PM]

Topic Locked

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

Sign in to reply to this topic.