lin_interpolate.py 678 B

12345678910111213141516171819
  1. """Interpolate linearly
  2. [(0, 0, 0), (2, 2, 0)] # at these positions,
  3. [(0.2,0,0), (0,0,0.2)] # these are the specified vectors
  4. """
  5. from vedo import lin_interpolate, Arrow, show
  6. positions = [(0, 0, 0), (2, 2, 0)] # at these positions,
  7. directions = [(0.2,0,0), (0,0,0.2)] # these are the specified vectors
  8. # now use lin_interpolate to interpolate linearly any other point in space
  9. # (points far from both positions will get close to the directions average)
  10. arrs = []
  11. for x in range(0,10):
  12. for y in range(0,10):
  13. p = [x/5, y/5, 0]
  14. v = lin_interpolate(p, positions, directions)
  15. arrs.append(Arrow(p, p+v, s=0.001))
  16. show(arrs, __doc__, axes=1).close()