trail.py 552 B

12345678910111213141516171819202122
  1. """Add a trailing line to a moving object"""
  2. from vedo import Plotter, sin, Sphere, Point
  3. s = Sphere().c("green").bc("tomato")
  4. s.cut_with_plane([-0.8, 0, 0]) # cut left part of sphere
  5. p = Point([-2,0,0]).ps(12).color("black")
  6. # add a trail to point p with 50 segments
  7. p.add_trail(lw=3, n=50)
  8. plt = Plotter(axes=6, interactive=False)
  9. plt.show(s, p, __doc__)
  10. for i in range(150):
  11. p.pos(-2+i/100.0, sin(i/5.0)/15, 0).update_trail()
  12. plt.azimuth(-0.2)
  13. plt.render()
  14. # stay interactive and after pressing q close
  15. plt.interactive().close()