Inner/Outer Surface ColormapΒΆ

../../_images/bin_surf1.png

This technique can be used to visualize the front and back of an orientable surface.

  • mapping from normals uses the colormap half corresponding the surface side which is facing the view, based on the face normals relative to the view direction (direction=ax)
  • shading also uses the relative direction to the view. In this case, the lighting source direction is the default since the direction argument has not been set.
../../_images/bin_surf_cmap.png
import numpy as np
from matplotlib import pyplot as plt
import s3dlib.surface as s3d
import s3dlib.cmap_utilities as cmu

#.. Binary colormap used to visualize the inner/outer surfaces.

# 1. Define function to examine .....................................

def twistFunction(rtz,twists=6) :
    r,t,z = rtz
    # Note: sliced surface needed due to discontinuity @ t=0 if twists is odd
    thickness = 0.33
    w = thickness*z 
    phi = 0.5*t*twists
    R = 1 + w * np.cos(phi)
    Z = w * np.sin(phi)
    return R,t,Z

# 2. Setup and map surfaces .........................................
rez = 5
bcmap = cmu.binary_cmap('silver', 'sandybrown', name='slvr_brwn' )

surface = s3d.CylindricalSurface(rez, basetype='squ_s', cmap=bcmap)
surface.map_geom_from_op( twistFunction )

# 3. Construct figures, add surface, plot ...........................
minmax = (-.9,.9)

fig = plt.figure(figsize=plt.figaspect(1))
ax = plt.axes(projection='3d')
ax.set(xlim=minmax, ylim=minmax, zlim=minmax)
ax.set_axis_off()
ax.view_init(azim=-70)

surface.map_cmap_from_normals(direction=ax)
ax.add_collection3d(surface.shade(ax=ax).hilite(ax=ax))

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