algorithmlanguage-agnosticgeometry4d

Calculate 3D cross section of 4D shape (tesseract)


So far I have read the following on calculating the points of the 3D intersect for a 4D object:

Simple implementation of 4D cross-section

How do I get a 3D cross section of a 4D mesh?

However, I am really confused on whats going on. I understand that I need to calculate the point at which each edge of the 4D object (in my case a tesseract) intersects the 3D space and then join the points that were calculated, however I am not sure how the calculation of the intersects would be done.

It would be nice if someone could explain how they would go about calculating the full 3D cross section, however I will be satisfied with how to calculate the intersect of 1 4D edge, as in the intersection between two 4D points.

(Unlike what was shown in the first link I found, I want to be able to do this at any w coordinate on the 4th axis, so a way of calculating that keeps the position of the 3D space along the w axis in mind, along with the position and orientation of the tesseract itself)

Thanks


Solution

  • I did in here (Your first link is its duplicate)

    You will find there more than just cross-section and also C++ 4D tesseract example with cross-section rendering (without too).

    Now what you are asking is how to compute intersection between edge of geometry and axis alligned 4D hyperplane w = constant ? That is easy as edge is line in really defined by two points p0,p1 so you can use linear interpolation for this:

    p(t) = p0 + (p1-p0)*t
    

    this will give you any point in the line while t = <0,1> is scalar linear parameter defining where on the line p(t) is.

    p(0) = p0
    p(1) = p1
    p(0.5) = mid point between p0,p1
    

    Now you just want to solve t so the w is equal to your constant let call it w_cut as cutting plane.

    p(t).w = w_cut
    p0.w + (p1.w-p0.w)*t = w_cut
    t = (w_cut-p0.w) / (p1.w-p0.w)
    

    if t is inside <0,1> interval the edge intersect your plane. if (p1.w-p0.w)=0 entire edge is in the plane.

    Now as mentioned in the linked answer this does not deal with topology so you would obtain points and edges but not inter-connection info on how to construct 3D geometry from them and thorough analysis is needed to do so. So much better is organize your mesh in a form of tetrahedrons and inspecting intersection of its triangles instead of edges alone.

    So you inspect 3 edges of each triangle of tetrahedron. Each triangle will convert after intersection to:

    1. nothing - ignore

    2. single point - remember it

    3. single edge - remember its 2 points

    4. whole triangle - remember its 3 points

    Remove duplicate points and after that you should have a list of points (0,3 or 4 points) of the tetrahedron after intersection so:

    1. 0 points - ignore

    2. 3 points - render triangle

    3. 4 points - render tetrahedron

    there is also a possibility for 1 and 2 points but you can ignore them unless you want to render also infinitely thin lines and points in which case render them. For more info inspect this function in the link above:

    void mesh4D::draw_cut(double w_cut)
    

    it does exactly as I described here. The only problem with this is that we lose the polygon winding. But that can be repaired by doing dot between the normal_of_triangle and vector center_of_triangle - center_of_tetrahedron if the sign is negative the normal is pointing inward. So if yo know which way you want to point reverse order of triangle points if wrong direction is present.