Tetrahedron - plane intersection

Started by
4 comments, last by Zakwayda 13 years, 5 months ago


How to comput plane - tetrahedron plane intersection?
Advertisement
Boolean only? Or do you need some sort of contact information?


I need intersection points.

The intersection will generally be a region, not a point. The basic method is to find which vertices of the tetrahedron are above the plane, and which are below the plane. Then, for each edge of the tetrahedron connecting an above point with a below point (discounting degenerate cases, there will be 0, 3, or 4 of these) find the intersection of that edge with the plane. The resulting points will be the vertices of the intersection polygon.
So, if my understanding is correct, algorithm ( in C style pseuod code) is as follows

struct vec3{    float x,y,z;    };struct Plane{  vec3 pointontheplane;  vec3 normal;};vec3 PlaneEdgeIntersection(vec3& PointBelow,vec3& PointAbove,Plane* plane){//Line formed by PointBelow and PointAbove:  P = PointBelow + u *(PointAbove - PointBelow)            float u  = (Dot(Plane->normal,(plane->pointontheplane - PointBelow))/Dot(Plane->normal,(PointAbove - PointBelow));            vec3 intersectionpoint = PointBelow + u * (PointAbove - PointBelow);        return intersectionpoint;} void WhichsideofthePlane(vec3& tetrahronvertex, Plane* plane,PointaboveorBelow){			bool value = dot(plane->normal,tetrahedronvertex);	if(value > 0)	     PointaboveorBelow = true;	else	     PointaboveorBelow = false; }	point* PlaneTetrahedronIntersection(vector<vec3> tetrahedronvertex, Plane* plane){	//True if it lies above and false if it lies below	bool PointaboveorBelow[4];         // Vector of intersection points.          std::vector<vec3> intersectionpoint;	//Find which vertices are above  and below the plane. 	for(int i=0;i<4;i++)	{		   WhichsideofthePlane(tetrahedronvertex,Plane,PointaboveorBelow);	}			// Edge Formation  	// and finding the intersection between edge and plane. 	for(int i=0;i<4;i++)	{	   for(int j=0;j<4;j++)	   {			if((PointaboveorBelow == true)&& (PointaboveorBelow[j] == false))			{				  //so PointaboveorBelow and PointaboveorBelow[j] form a edge				 vec3 point = PlaneEdgeIntersection(PointaboveorBelow,PointaboveorBelow[j],Plane);                                   intersectionpoint.insert(point);			}	   }	}}


Is this right?

[Edited by - rajesh_nest on November 11, 2010 6:43:00 AM]
I didn't proof your code, but does it seem to be working? If you visualize it (e.g. with a fixed plane and a tetrahedron that you can move around), do the intersection points appear to be correct?

This topic is closed to new replies.

Advertisement