Inner SurfaceΒΆ

../../_images/inner_surface.png ../../_images/inner_surface_cmap.png
import numpy as np
import matplotlib.pyplot as plt
import s3dlib.surface as s3d
import s3dlib.cmap_utilities as cmu

#.. Visualization of an inner surface

# 2. Setup and map surface .........................................

nrad,nang,minrad= 30, 120, 0.7

surface = s3d.SphericalSurface.grid(nrad,nang,'r',minrad=minrad,color='burlywood')
innerSurface = s3d.SphericalSurface.grid(nrad,nang,'r',minrad=minrad,color='salmon').domain(.98)
surface1 = surface + innerSurface.evert()

bcmap = cmu.binary_cmap('salmon', 'burlywood', name='salm_burl' )
surface2 = s3d.SphericalSurface.grid(nrad,nang,'r',minrad=minrad,cmap=bcmap)

# 3. Construct figure, add surface, and plot ......................
minmax = (-1,1)
fig = plt.figure(figsize=plt.figaspect(0.5))
ax1 = fig.add_subplot(121, projection='3d', aspect='equal')
ax1.set(xlim=minmax, ylim=minmax, zlim=minmax)
ax1.set_axis_off()
ax2 = fig.add_subplot(122, projection='3d', aspect='equal')
ax2.set(xlim=minmax, ylim=minmax, zlim=minmax)
ax2.set_axis_off()

ax1.set_title('\nTwo Surfaces',fontsize='x-large')
ax1.add_collection3d(surface1.shade(ax=ax2))

ax2.set_title('\nBinary Colormap',fontsize='x-large')
surface2.map_cmap_from_normals(direction=ax2)
ax2.add_collection3d(surface2.shade(ax=ax2))

fig.tight_layout(pad=0)
plt.show()