1
$\begingroup$

I have a plane equation given by a point and a normal vector, for example. This plane has to lay between $xyz$ limits, $300<x<2700$, $150<y<1350$, $130<z<1370$. I want to know the intersection between the plane and the cube formed by the limits, so that I can divide every side of the ramaining figure with a given number of points.

$\endgroup$
  • $\begingroup$ A plane can intersect a cube in several kinds of figures. At one extreme there could be an empty intersection or a single point (vertex of the "cube"). The intersection will be a convex polygon if it contains more than just an edge, and such polygons will have between three and six sides. It would help to know what you have in mind when dividing "every side of the [remaining] figure with a given number of points." $\endgroup$ – hardmath Feb 11 at 15:11
  • $\begingroup$ Normally I will have a rectangle but I want to do it as flexible as possible, I`ve doing research and found algorithms such us cohen sutherland, but i wanted to know how to do it in this case. Thank you $\endgroup$ – ibabinaca Feb 11 at 15:18
  • $\begingroup$ One approach is to check for intersections between the plane and the edges of the "cube" (actually a rectangular prism or "cuboid" in your example). The plane-cuboid intersection will be the convex hull of those plane-edge intersections, if any. Again, it is unclear what you intend to do with the intersection once found, so it's hard to say what representation of an intersection will be most convenient. $\endgroup$ – hardmath Feb 11 at 15:27
0
$\begingroup$

It is especially easy to find the points at which edges of your (axis-parallel) cuboid intersect a given plane. Then the intersection of the cuboid and the plane, if not empty, is the convex hull of these points (where edges intersect the plane).

The reason is that along each edge of axis-parallel cuboid two of the coordinates are constant. Indeed the cuboid has twelve edges, and for each pair of coordinate variables there are four edges along which those two coordinates are unchanging.

To use your example, there are four pairs of vertices which have $x,y$ coordinates that are shared. Take $x=300$ and $y=150$, for example, with endpoints $z=130,1370$. These two points determine an edge parallel to the $z$-axis.

Your equation of the plane "given by a point" $(x_p,y_p,z_p)$ "and a normal vector" $(c_x,c_y,c_z)$ is:

$$ c_x x + c_y y + c_z z = c_x x_p + c_y y_p + c_z z_p $$

If we plug in $x=300$ and $y=150$ to this equation, we find out whether the edge determined by the two vertices sharing those coordinates intersects the plane corresponding to that equation. If $c_z = 0$, then either the plane does not intersect the edge at all, or else the plane contains the edge in its entirety. If $c_z \neq 0$, then the line through the two vertices does intersect the plane in one point, but that point will either have a $z$-coordinate between the limits $z=130,1370$ (hence a point of intersection on the edge), or the point where the line intersects the plane will be outside the specified edge.

There are a number of cases that could result:

(1) The plane does not intersect any edge, which is equivalent to the plane not intersecting the cuboid.

(2) The plane intersects edges only at one vertex of the cuboid, which is equivalent to the plane intersecting the cuboid only in one point.

(3) The plane intersects the cuboid only in the entirety of one and only one edge, which is equivalent to the plane intersecting the cuboid in a line segment.

(4) Otherwise the plane intersects the cuboid in a polygon having between three and six sides. (There are various subcases of this to consider, naturally, but as already stated, the polygon is the convex hull of the collection of intersections of the plane and the various edges.)

Depending on what you intend to do with such a polygon (subdividing its sides?), some additional processing of the corners of the polygon may be necessary, e.g. ordering the corner points as a path around the polygon and computing the lengths of the polygon's sides.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.