Sign in to follow this  
eskimo456

point to plane equation possible rearranging required?

Recommended Posts

Hi

I am using a bounding box as an initial quick test once this has collided, I am them attempting to use a point to plane test with a barycentric traingle to get precise collision with a wall.

I have a formula that seems to work on paper but when I use it in the computer it looks as though it is the wrong way around.

My formula is..
s = (p-a).N;
c.x = p.x-s*N.x
c.y = p.y,s*N.y
c.z = p.z,s*N.z


p is point of interest, a is point on plane, and n is normalised normal.

I get an answer of 0 initially but if I move my character into a wall I then get an answer of 50. The point to plane test gives a distance of 50.

I need the boat to be of distance 50, and as I move to the wall for it to decrease to 0. Then do an if(distance<0) statement for collision.

Am I accidnetly calculating the character position?

Should I rearrange it to something like p.x-s*n.x-c.x? to give me the distance away from the wall?

Many thanks

Share this post


Link to post
Share on other sites
Off the top of my head: you don't say, but if your vector c is supposed to be the closest point in the plane to p, then c = p - s, s being a vector from the closest point in the plane to point p.

For your calc, c.x = p.x-s.x, etc.

Therefore, the distance from the point p to the plane is the magnitude of s.

if dot(s,N) > 0 (s and N pointing the same direction), then point p is on the "positive" side of the plane.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this