issue_953.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import numpy as np
  2. from colorcet import bmy
  3. from vedo import Points, Grid, show
  4. def add_reconst(name, i=2):
  5. p = Points(np_pts)
  6. bb = list(p.bounds())
  7. if bb[0] == bb[1]:
  8. bb[1] += 1
  9. bb[0] -= 1
  10. if bb[2] == bb[3]:
  11. bb[3] += 1
  12. bb[2] -= 1
  13. if bb[4] == bb[5]:
  14. bb[5] += 1
  15. bb[4] -= 1
  16. m = p.reconstruct_surface(bounds=bb)
  17. m.cmap(bmy, m.vertices[:, i]).add_scalarbar()
  18. names.append(name)
  19. pts.append(p)
  20. mesh.append(m)
  21. names = []
  22. pts = []
  23. mesh = []
  24. grid = Grid(res=(20, 20))
  25. # grid with constant z=0
  26. np_pts = grid.clone().vertices
  27. add_reconst("z=0")
  28. # grid with constant z=1
  29. np_pts = grid.clone().z(1).vertices
  30. add_reconst("z=1")
  31. # grid with varying z
  32. np_pts = grid.clone().vertices
  33. np_pts[:, 2] = np.sin(np_pts[:, 0])
  34. add_reconst("sin z")
  35. # constant y
  36. np_pts = grid.clone().rotate_x(90).vertices
  37. add_reconst("y=0", 1)
  38. # constant x
  39. np_pts = grid.clone().rotate_y(90).vertices
  40. add_reconst("x=0", 0)
  41. # rotated plan
  42. np_pts = grid.clone().rotate_x(90).rotate_y(40).rotate_z(60).vertices
  43. add_reconst("tilted")
  44. show([t for t in zip(names, pts, mesh)], N=len(mesh), sharecam=False, axes=1)