• Advertisement

Archived

This topic is now archived and is closed to further replies.

normal problem

This topic is 5470 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

is there anyway to see if a point is infront of or behind a normal? ei the point is behind a wall or infront of it. [edited by - hello_there on January 27, 2003 12:04:20 AM]

Share this post


Link to post
Share on other sites
Advertisement
Get dot product of normal vector and your''s vertex vector. If it > 0 then it ahead, otherwise behind.

Vector n = GetMyNormal();
Vector v = GetMyVertex();
if (dp(n, v) > 0) {
// Ahead
...
}
else {
// Behind
...
}

Share this post


Link to post
Share on other sites
Yes.
Say you have a point p and a normal n. Let f be a fixed point on the plane you want to test for in front/behind (usually defined by a triangle so use any one of the vertices).

Then

p - f == vector from f to p

dot product this with n, the plane normal. If this is positive then (p-f) and n are facing in the same direction, i.e. you are "in front" of the plane. If it's negative, (p-f) and n are facing in the opposite direction, i.e. you are on the 'tother side. If it's zero, you are incident to the plane.

The dot product result also gives you the perpendicular distance from the point to the plane (since n is normalised).

Bingo.

EDIT: nail85 was quicker but got the answer a bit wrong (only works for planes thru the origin).

"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley

[edited by - Paradigm Shifter on January 28, 2003 6:48:18 AM]

Share this post


Link to post
Share on other sites

  • Advertisement