Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compute the Cross Section of a Cube

As is indicated in the following images, the cross section of a cube can be:

  1. Triangle
  2. Rectangle
  3. Pentagon (NOT DREW)
  4. Hexagon

Assume that we are getting a hexagon. We can get the intersection points of the cross plane with each side of the cube and get the hexagon ABCDEF. The question is: how do we sort the intersection points so that the hexagon ABCDEF can be divided into 4 triangles ABC, ACD, ADE and AEF.

enter image description here


Notice that the order of the points is very important because if I get the order wrong, I won't be able to draw it out. I want to divide them into triangles because I want to visualized them in OpenGL.


Thanks so much for @HugoRune's answer. Here some result that I want to share with you guys. Left image is the cross section of a 3D volume (from an arbitrary angle). Right image is the result of maximum intensity projection of the 3D volume. Cross Section of A Box (Real Data)

like image 868
Yuchen Avatar asked Dec 04 '13 22:12

Yuchen


1 Answers

the intersection is a convex polygon, so any sorting that works for convex polygons will work here as well.

In particular:

  • calculate the centroid Z = (A+B+C+...) / numPoints
  • calculate the normal n = AB cross BC
  • get the Vector from the centroid to the first point: ZA
  • order all points P by the signed angle ZA to ZP with normal n
    (signed angle == angle(ZA,ZP) * sign (n dot (ZA cross ZP) )
like image 176
HugoRune Avatar answered Oct 18 '22 00:10

HugoRune