interpolate_scalar3.py 678 B

12345678910111213141516
  1. """Interpolate the arrays of a source Mesh (RandomHills)
  2. onto another (ellipsoid) by averaging closest point values"""
  3. from vedo import ParametricShape, Sphere, show
  4. # RandomHills already contains the height as a scalar defined on vertices
  5. h = ParametricShape('RandomHills')
  6. h.cmap('hsv', vmin=0, vmax=6)
  7. h.add_scalarbar3d(title='RandomHills height scalar value')
  8. # interpolate such values on a completely different Mesh.
  9. # pick n=4 closest points and assign an ave value based on shepard kernel.
  10. s = Sphere().scale([1,1,0.5]).pos(-.1,1.5,0.3).alpha(1).lw(1)
  11. s.interpolate_data_from(h, n=4, kernel='gaussian')
  12. s.cmap('hsv', vmin=0, vmax=6)
  13. show(h,s, __doc__, axes=1).close()