# Cube plane intersections points

Hi everybody,

Does anybody know o algorithm to compute the intersections points between a plane and geometric cube?

Thanks,

``````    public IntersectionType Intersects(AAIntBox box)
{
float3 vector;
float3 vector2;
vector2.X = (Normal.X &gt;= 0f) ? box.MinCorner.X : box.MaxCorner.X;
vector2.Y = (Normal.Y &gt;= 0f) ? box.MinCorner.Y : box.MaxCorner.Y;
vector2.Z = (Normal.Z &gt;= 0f) ? box.MinCorner.Z : box.MaxCorner.Z;
vector.X = (Normal.X &gt;= 0f) ? box.MaxCorner.X : box.MinCorner.X;
vector.Y = (Normal.Y &gt;= 0f) ? box.MaxCorner.Y : box.MinCorner.Y;
vector.Z = (Normal.Z &gt;= 0f) ? box.MaxCorner.Z : box.MinCorner.Z;
float num = ((Normal.X * vector2.X) + (Normal.Y * vector2.Y)) + (Normal.Z * vector2.Z);
if (num + D &gt; 0f)
{
return IntersectionType.Front;
}
num = ((Normal.X * vector.X) + (Normal.Y * vector.Y)) + (Normal.Z * vector.Z);
return num + D &lt; 0f ? IntersectionType.Back : IntersectionType.Intersecting;
}
``````

its written in C#, but it shouldn’t be hard to port.

EDIT:

If you haven’t guessed, a “float3” is a vector of 3 floats