Sign in to follow this  
rajesh_nest

Tetrahedron - plane intersection

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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[i],Plane,PointaboveorBelow[i]);
}


// 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[i] == true)&& (PointaboveorBelow[j] == false))
{
//so PointaboveorBelow[i] and PointaboveorBelow[j] form a edge
vec3 point = PlaneEdgeIntersection(PointaboveorBelow[i],PointaboveorBelow[j],Plane);
intersectionpoint.insert(point);
}
}
}
}





Is this right?

[Edited by - rajesh_nest on November 11, 2010 6:43:00 AM]

Share this post


Link to post
Share on other sites
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?

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