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


i have polychoron represented four-dimensional mesh, stored face-vertex method. faces triangles. how can three-dimensional cross-section of figure?

the closest thing i've found this question, it's 1 dimension short.

working 4 dimensions bit difficult.

the way solve problem finding dimensional analogies.

let's start 2d

a convex 2d polygon has convex 1d sides: line segments.

the cross-section of filled convex polygon line segment.

calculate intersection points of poligons edges intersecting line, you'll 2 intersections convex polygon, , cross section line segment.

to transform coordinates cross section on y axis of coordinate system. 2 points of edge , b. coordinates a1, a2 , b1, b2.

if signs of a1 , b1 same, (aka a1*b1 > 0) edge won't intersect y axis.

otherwise calculate k = a1/(a1-b1).

then coordinate of intersection point be: (0; (1-k)*a2+k*b2)

as said convex polygons you'll 2 intersection points, connect 2 point 1d cross section.

now let's generalize 3d

a convex 3d mesh has convex 2d sides: triangles.

again, transform coordinates make operation easier. let's cross section of mesh on y-z plane, x coordinates 0 again.

get cross sections of triangles. using algorithm above each edge of them. since have 3 dimensions endpoints of edge have coordinates a1, a2, a3 , b1, b2, b3. if a1*b1<0 have intersection point. so

let k = a1 / (a1 - b1)

the coordinate of intersection point (0; (1-k)*a2+k*b2; (1-k)*a3+k*b3). store coordinate, store index of , b points of mesh (the edge index). it'll useful later.

for each triangle yield line segment.

now you'll need connect these cross section line segments polygon. that's why stored edge indexes along intersection points. have set of lines , can match endpoints stored edge index, can connect them polygon.

now let's generalize 4d

a convex 4d mesh has convex 3d "sides": tetrahedrons. (note face-vertex representation incorrect)

again, transform coordinates make operation easier. let's cross section of mesh on y-z-w hyperplane, x coordinates 0 again.

get cross sections of tetrahedrons. using algorithm above each face of them. since have 4 dimensions endpoints of edge have coordinates a1, a2, a3, a4 , b1, b2, b3, b4. if a1*b1<0 have intersection point. so

let k = a1 / (a1 - b1)

the coordinate of intersection point (0; (1-k)*a2+k*b2; (1-k)*a3+k*b3; (1-k)*a4+k*b4).

for each triangle of tetrahedron yield line segment. each tetrahedron yield triangle. each edge of these triangles store index of a, b , c points of triangle of 3d mesh (the face index) line segment originates from. it'll useful later.

now you'll need connect these cross section triangles 3d mesh. that's why stored face indexes along intersection edges. have set of triangles , can match edges stored face index, can connect them triangle mesh.

for concave 4d meshes may have multiple 3d meshes.


hope see analogy.

the concrete implementation bit diffcult, you'll need take care of corner cases (division 0 cases, floating point errors, etc).


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -