# Thread: Particle Plane Collision

1. ## 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);
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

2. ## Re: Particle Plane Collision

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?

3. ## Re: Particle Plane Collision

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

4. ## Re: Particle Plane Collision

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.

5. ## Re: Particle Plane Collision

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.

6. ## Re: Particle Plane Collision

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

7. ## Re: Particle Plane Collision

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)??

8. ## Re: Particle Plane Collision

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?

9. ## Re: Particle Plane Collision

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?

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.

10. ## Re: Particle Plane Collision

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.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•