creating thick gyroid using python (sheet-network, solid-network)

117 views Asked by At

I need to create sheet-networks and solid-networks of gyroid using marching cube algorithm in python.

import numpy as np
import mcubes

# Define the gyroid function
def gyroid(x, y, z):
    return np.sin(2 * np.pi * x) * np.cos(2 * np.pi * y) + np.sin(2 * np.pi * y) * np.cos(2 * np.pi * z) + np.sin(2 * np.pi * z) * np.cos(2 * np.pi * x)

# Create a data volume (100 x 100 x 100)
X, Y, Z = np.mgrid[:100, :100, :100]
binary_space = abs(gyroid(X / 100, Y / 100, Z / 100)) <= 0.1

# Extract the 0-isosurface
smoothed_gyroid = mcubes.smooth(binary_space)
vertices, triangles = mcubes.marching_cubes(smoothed_gyroid, -0.5)

#export to an OBJ file
mcubes.export_obj(vertices, triangles, 'sheet_network.obj')

but it became like this:

How can I make this?

0

There are 0 answers