Random Grid GeometryΒΆ

../../_images/bubbles1.png
import numpy as np
import matplotlib.pyplot as plt
import s3dlib.surface as s3d

#.. Summer Bubbles
# 1. Define function to examine .....................................

def bubble(rtp) :
    r,t,p = rtp
    R = np.ones(len(r))-0.5*r**4
    return R,t,p

# 2. Setup and map surf ............................................
rez, seed = 1, 314

surface = s3d.SphericalSurface.rand(rez,seed)
surface.map_cmap_from_op(cmap='summer')
surface.triangulate(5)
surface.map_geom_from_op(bubble)

# 3. Construct figure, add surfaces, and plot ......................

fig = plt.figure(figsize=plt.figaspect(1))
fig.text(0.03,0.02,str(surface), ha='left', va='bottom',
    fontsize='smaller', multialignment='left', color='yellowgreen')

ax = plt.axes(projection='3d', aspect='equal', facecolor='k')
ax.set_axis_off()
s3d.auto_scale(ax,surface,uscale=.75)
ax.add_collection3d(surface.shade().hilite(focus=2))

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