Particle Plane Collision

Am writing a function to detect particle collision on a given plane, with the help of the normal of each point on the plane. I wanted to know how i can calculate the normal for each point on the plane.

My plane rendering code is,

/* Draw the floor. */
glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
glColor3f(0.3, 0.3, 0.3);
glBegin(GL_QUADS);
glVertex3f(-12, -6.5, -12);
glVertex3f(12, -6.5, -12);
glVertex3f(12, -6.5, 12);
glVertex3f(-12, -6.5, 12);

Am really stuck, i would really appreciate the help.
Thank you

A plane has the same normal everywhere, so the normal at each point is equal to “the plane’s normal”.

Or is your question how to compute the normal of a plane given four points on it?

Yeah how would i compute the normal given the above points.

And how do i generate every single point on that plane with the above co-ordinates, as i need to substitute it in the given formula. (X-P).N, given X the position of the particle, P the position of a point on the plane and N the normal.

Take the cross product of two linear independent vectors in the plane.
If p0, p1, p2, p3 are the points you use to visualize the plane, two suitable vectors are p1-p0 and p2-p0.

There are an infinite number of points on a plane, you can not enumerate them.

If i cannot generate the points, how do i use the above formula for calculating a collision since i need to process the point on the plane, or would it be the same if the value of P in the formula (X-P).N be equal to the same vector value, say the center, (0,-6.5,0)??

void CalculatePlaneNormal(){
tVector3 vert1(-12,-6.5,-12);
tVector3 vert2(12,-6.5,-12);
tVector3 vert3(12,-6.5,12);
tVector3 vert4(-12,-6.5,12);
float Qx,Qy,Qz,Px,Py,Pz;;

Qx = vert2.x - vert1.x;
Qy = vert2.y - vert1.y;
Qz = vert2.z - vert1.z;
Px = vert3.x - vert1.x;
Py = vert3.y - vert1.y;
Pz = vert3.z - vert1.z;

Nx = Py*Qz - Pz*Qy;
Ny = Pz*Qx - Px*Qz;
Nz = Px*Qy - Py*Qx;

float length = sqrt(Nx*Nx + Ny * Ny + Nz * Nz);
Nx /= length;
Ny /= length;
Nz /= length;

}

Would this be an accurate method of finding the normal of a plane?

Please use [ code]/[ /code] (without space after ‘[’) around code snippets, also please read the forum posting guidelines.

The code looks like it should do the right thing, but why does it not make use of tVector3 for Q, P and N? Do you have some functions/user defined operators that compute difference, cross product, length of a tVector3 that would make this easier/more readable? If not, why not? :wink:

This does all look awfully like a homework assignment…

A particle collides with the plane if it’s movement for the current time step takes it from one side of the plane to the other. In other words if it is on one side in this time step and would be on the other side in the next time step.
So in order to detect collisions you need to test which side of a plane the particle is on.

Just for my sake i have done it that way, i find it easier to manipulate the data like that. How do i find out which side of the plane the particle is on??

Yes this is an assignment its the last part of my physics project, so for sake of quickness could you please tell me how you would do it, in code or pseudo code.

Thank you.

Yes this is an assignment its the last part of my physics project, so for sake of quickness could you please tell me how you would do it, in code or pseudo code.

So you want someone to do your homework for you.

Not really, I just needed a little bit of help, a push you might say. Am sure when you were in your earlier stages you needed someone to help. So don’t put your two penny’s worth if you are not interested in doing a deed, if so move alone pal, nobody wants to listen to your self righteous crap. You don’t even know me, so why would would you give a ****.

Anyway, i figured it out coz guess what you may have experience, but i got the brains. Shove it where it don’t shine.

I have not gone through all posts, but I guess you are using a normal form of euation for a plane i.e dot(N,p) + k = 0

So you can use your point, under consideration and plug in above formula to check whether point touches plane or not ( if right hand side is 0 => point touches), if right hand side is < 0 it means point is on opposite direction to plan normal and vice -versa.