• Advertisement
Sign in to follow this  

Tetrahedron - plane intersection

This topic is 2657 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
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,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]

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
Sign in to follow this  

  • Advertisement