Mesh Isolines (3D)
Distance Mapping:
f(v) = ‖v - P_attractor‖. 3. Concentric Slicing: Generating contours on this scalar field yields spherical rings around the attractor on the mesh.1def assign_vertex_scalars(mesh, attractor_point):2 scalars = {}3 for v in mesh.vertices:4 # Compute Euclidean distance to 3D attractor point5 dx = v.x - attractor_point.x6 dy = v.y - attractor_point.y7 dz = v.z - attractor_point.z8 scalars[v.id] = math.sqrt(dx*dx + dy*dy + dz*dz)9 return scalars
Instead of simple vertical height slicing, we can compute scalar values relative to a dynamic 3D attractor point. The distance from each mesh vertex to the attractor creates a spherical scalar field.
Intersection Cases:
1def slice_mesh_triangle(v0, v1, v2, s0, s1, s2, isovalue):2 # Track intersection coordinates3 points = []45 # Check Edge 0-16 if (s0 <= isovalue <= s1) or (s1 <= isovalue <= s0) and s0 != s1:7 t = (isovalue - s0) / (s1 - s0)8 points.append(v0 + t * (v1 - v0))910 # Check Edge 1-211 if (s1 <= isovalue <= s2) or (s2 <= isovalue <= s1) and s1 != s2:12 t = (isovalue - s1) / (s2 - s1)13 points.append(v1 + t * (v2 - v1))1415 # Check Edge 2-016 if (s2 <= isovalue <= s0) or (s0 <= isovalue <= s2) and s2 != s0:17 t = (isovalue - s2) / (s0 - s2)18 points.append(v2 + t * (v0 - v2))1920 return points if len(points) == 2 else None
To generate the full isoline path, the algorithm processes each mesh triangle individually. We inspect the scalar values at the three corners, determine which edges cross the threshold, and compute linear intersections.
Distance Contours:
1def generate_distance_isolines(mesh, attractor_pt, levels):2 all_contours = []3 for isovalue in levels:4 segments = []5 for face in mesh.faces:6 # 1. Compute distance to attractor for each vertex7 s0 = distance(face.v0.position, attractor_pt)8 s1 = distance(face.v1.position, attractor_pt)9 s2 = distance(face.v2.position, attractor_pt)1011 # 2. Slice the triangle using these distance scalars12 pts = slice_mesh_triangle(13 face.v0, face.v1, face.v2,14 s0, s1, s2,15 isovalue16 )17 if pts:18 segments.append(pts)19 all_contours.append(segments)20 return all_contours
By calculating the Euclidean distance from every vertex to a dynamic 3D attractor, we obtain a distance field. Slicing the mesh at specific distance thresholds (isovalues) draws continuous concentric isolines representing equal-distance bands on the surface.
Related Concepts
3D Grids and Marching Cubes.
Uniform 3D lattice discretization, coordinate quantization, Morton/prime spatial hashing, and voxel rasterization.
8-bit voxel corner classification, 256-entry lookup tables, linear edge zero-crossing interpolation, and isosurface extraction.