Given a plane and a cube, I'd like to know whether they intersect. If they do, I'd also like to know:
do their intersection form a triangle, a parallelogram or an hexagon
- or a point, or a segment in the degenerated cases
what are the coordinates of the vertices of the intersection
2.1. in the standard frame of reference
2.2. in the cube's frame of reference
Note:
- The cube is a
new THREE.BoxGeometry(1, 1, 1)which has undergone translation and rotation throughapplyMatrix4of a translation and rotation matrix - The plane is an arbitrary
new THREE.Plane()
Looking through the Three.js documentation, I found the following:
Planehas a methodintersectBoxwhich tells whether or not the plane intersect with a givenBox3.Planehas a methodintersectLinewhich tells where a given Line3 intersect the plane.ConvexHullwhich builds a convex polyhedron from a set of vertices:So a possible approach to the problem would be to:
I ended up not using the convex hull approach. I just create all the possible faces thanks to a triple nested loop over the intersection points.