File: trail.py

package info (click to toggle)
vedo 2026.6.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 10,528 kB
  • sloc: python: 46,376; javascript: 1,900; xml: 437; sh: 110; makefile: 6
file content (22 lines) | stat: -rw-r--r-- 570 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
"""Add a trailing line to a moving object"""
from vedo import Plotter, sin, Sphere, Point


s = Sphere().c("green").bc("tomato")
s.cut_with_plane([-0.8, 0, 0])  # cut left part of sphere

p = Point([-2,0,0]).ps(12).color("black")

# Add a finite-length trail to visualize recent trajectory.
p.add_trail(lw=3, n=50)

plt = Plotter(axes=6, interactive=False)
plt.show(s, p, __doc__)

for i in range(150):
    p.pos(-2+i/100.0, sin(i/5.0)/15, 0).update_trail()
    plt.azimuth(-0.2)
    plt.render()

# stay interactive and after pressing q close
plt.interactive().close()