3D Voxels

Gear Wheel Voxels

Mechanical gear with teeth around the circumference in lime-yellow gradient.

Output
Gear Wheel Voxels
Python
import matplotlib.pyplot as plt
import numpy as np

n = 15
x, y, z = np.indices((n, n, n))
cx, cy = n // 2, n // 2

# Hexagonal cross-section approximation
r = 5
angles = [0, np.pi/3, 2*np.pi/3, np.pi, 4*np.pi/3, 5*np.pi/3]
hex_mask = np.ones((n, n), dtype=bool)

for angle in angles:
    nx_dir = np.cos(angle)
    ny_dir = np.sin(angle)
    hex_mask &= (nx_dir * (np.indices((n, n))[0] - cx) + 
                 ny_dir * (np.indices((n, n))[1] - cy)) <= r

# Extend to 3D prism
prism = np.zeros((n, n, n), dtype=bool)
for zz in range(2, n - 2):
    prism[:, :, zz] = hex_mask

# Gradient using amber #F5B027
z_idx = np.indices((n, n, n))[2]
colors = np.empty(prism.shape + (4,), dtype=np.float32)
colors[..., 3] = 0

norm_z = z_idx / (n - 1)
# Amber with intensity variation
colors[prism, 0] = 0.96
colors[prism, 1] = 0.69 - 0.2 * np.abs(norm_z[prism] - 0.5)
colors[prism, 2] = 0.15
colors[prism, 3] = 0.88

fig = plt.figure(figsize=(10, 8), facecolor='#020B14')
ax = fig.add_subplot(111, projection='3d', facecolor='#020B14')

ax.voxels(prism, facecolors=colors, edgecolors='#1e293b', linewidth=0.2)

ax.set_xlabel('X', fontsize=11, color='#94a3b8', labelpad=10)
ax.set_ylabel('Y', fontsize=11, color='#94a3b8', labelpad=10)
ax.set_zlabel('Z', fontsize=11, color='#94a3b8', labelpad=10)
ax.set_title('Hexagonal Prism Voxels', fontsize=14, color='white', fontweight='bold', pad=20)

ax.tick_params(colors='#64748b', labelsize=8)
ax.xaxis.pane.fill = False
ax.yaxis.pane.fill = False
ax.zaxis.pane.fill = False
ax.xaxis.pane.set_edgecolor('#1e293b')
ax.yaxis.pane.set_edgecolor('#1e293b')
ax.zaxis.pane.set_edgecolor('#1e293b')
ax.grid(True, alpha=0.2, color='#475569')

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

3D Charts

Did this help you?

Support PyLucid to keep it free & growing

Support