gyroid.py 824 B

12345678910111213141516171819202122
  1. """A textured gyroid shape cut by a sphere"""
  2. from vedo import *
  3. # Equation of a "gyroid" (https://en.wikipedia.org/wiki/Gyroid)
  4. x, y, z = np.mgrid[:30,:30,:30] * 0.4
  5. U = sin(x)*cos(y) + sin(y)*cos(z) + sin(z)*cos(x)
  6. # Create a Volume, take the isosurface at 0, smooth and subdivide it
  7. gyr = Volume(U).isosurface(0).smooth().subdivide()
  8. # Intersect it with a sphere made of quads
  9. sph = Sphere(pos=(15,15,15), r=14, quads=True, res=30).triangulate()
  10. printc("Please wait a few secs while I'm cutting your gyroid", c='y')
  11. gxs = gyr.boolean('intersect', sph)
  12. gxs.texture('https://vedo.embl.es/examples/data/images/marblings.jpg')
  13. plt = Plotter(bg='wheat', bg2='lightblue', axes=5)
  14. plt.add_ambient_occlusion(10)
  15. plt.show(gxs, __doc__, zoom=1.4)
  16. # Video('gyroid.mp4').action().close().interactive() # shoot video
  17. plt.close()