If you're new to Python
and VPython: Introduction

A VPython tutorial

Pictures of 3D objects

What's new in VPython 6

VPython web site
VPython license
Python web site
Math module (sqrt etc.)
Numpy module (arrays)

Leaving a Trail

This is documentation for Classic VPython (VPython 6), which continues to be available but is no longer supported. See vpython.org for information on installing VPython 7 or using GlowScript VPython. Documentation is available at glowscript.org by clicking Help.

You can leave a trail behind a moving object simply by specifying make_trail=True:

ball = sphere(make_trail=True)

Each time you change ball.pos, this new position is added to a curve, thereby leaving a trail behind the moving sphere. This works with arrow, box, cone, cylinder, ellipsoid, pyramid, ring, and sphere.

You can specify using a points object rather than a curve object for displaying the trail, and you can specify how many points to skip or retain:

ball = sphere(make_trail=True, trail_type="points",
              interval=10, retain=50)

The trail of this sphere will show individual points rather than a continuous line, it will display points at every 10th sphere location, and it will retain only the most recent 50 of these points.

At any time during the moving of the object, you can specify ball.make_trail=False, in which case no more points are added to the ball's trail until you set ball.make_trail=True again. Note however that with the default trail_type="curve", when you resume adding points to the curve there will be a line drawn from the last location to the current location.

When you create a sphere with make_trail=True or make_trail=False, a curve or points object is created as a trail_object attribute of the sphere object. If you say ball.trail_object.color=color.orange, you will change the color of the curve or points to orange.


make_trail Must be mentioned when creating the moving object; if False, no points will be added to the trail until you say ball.make_trail = True (assuming the moving object is named ball)

trail_type Default is "curve", but can be "points"

interval If interval=10, a point is added to the trail only every 10th move of the object

retain If retain=50, only the 50 most recently added points will be retained

trail_object The curve or points object; ball.trail_object.color=color.orange will change the color of the trail to orange