728x90
반응형
SMALL
Trajectory
ball = sphere(make_trail=True) # simple moving object
ball = sphere(make_trail=True, trail_type="points",
interval=10, retain=50)
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. If interval is 0, no trail is shown. If trail_type is "points", the default interval = 1; interval must have a nonzero value because the points need to be accurately spaced in order to look right. If trail_type is "curve" (the default), and no interval is specified, updates to the trail are made every time a new image is rendered, typically about 30 to 60 times a second. This usually looks fine. pps If trail_type is "curve", and no interval is specified, pps=15 means "add a point to the curve approximately 15 times per second". retain If retain=50, only the 50 most recently added points will be retained trail_color The color of the curve or points (default is the object's color). If you change this during the motion, later portions of the trail will have this color. trail_radius The radius of the curve or points. The default for the "curve" option is 0, which makes a thin curve (this works best in the xy plane; if it doesn't give the result you want, set trail_radius to the desired value). The default for the "points" option is 0.2 times the radius, 0.1 times the height or size.y, of the size of the moving object at the time your create that object. If you don't assign your own size or radius to an object until after you've created it, you may also need to set trail_radius at that time. If you change trail_radius during the motion, later portions of the trail will have this radius. clear_trail() Clears all points from the existing trail before adding more. Note that setting make_trail to False stops adding more points. |
Trail
attach_trail(ball) # a curve to be drawn along the path of the moving object
# By default, the radius of the cross-section of the curve is 0.1 times the size.y of the object
attach_trail(ball, radius=0.1,
color=color.white)
# specify that only the most recent N points are displayed, which has the effect of giving the object something like a comet's tail
attach_trail(ball, retain=30)
# By default, points are added to the trail every time the scene is rendered, which is typically about 30 times per second. No trail is started until you explicitly specify a position of the ball. You can limit the number of points per second ("pps") to be added to the trail. In the following case, 5 points are added to the trail per second (the maximum value of pps that makes sense is about 30)
attach_trail(ball, pps=5)
# By default, the trail is a curve (connected points), but you can make a trail of separated spheres:
attach_trail(ball, type='points')
# Instead of specifying an object whose position is used to add points to the curve or set of spheres, you can specify a function which yields a vector to be used as a position
def center():
return (ball1.pos+ball2.pos)/2
attach_trail(center)
# start, stop, clear
b = attach_trail(ball)
...
b.stop()
...
b.start()
...
b.clear()
Arrow
# arrow will have shaftwidth=0.3, and its axis is determined by 1000*ball.axis
attach_arrow(ball, "axis", scale=1000,
shaftwidth=0.3, color=color.green)
# The default value of scale is 1, the default color of the arrow is the color of the ball, and the default shaftwidth is 0.5*ball.size.y
attach_arrow(ball, "velocity")
# modify the appearance of the arrow later by doing
myarrow = attach_arrow(ball, "velocity", color=color.green)
...
myarrow.color = color.red # later, change the color of the arrow.
# start and stop
myarrow = attach_arrow(ball, "velocity")
...
myarrow.stop()
...
myarrow.start()
Light
# light that is bound to a moving object
a = attach_light(ball, offset=vec(5,1,0), color=color.green)
# The default value of the offset is vec(0,0,0)
https://www.glowscript.org/docs/VPythonDocs/trail.html
728x90
반응형
LIST
'Python Library > VPython' 카테고리의 다른 글
Web VPython (0) | 2022.07.06 |
---|---|
[VPython] Sharing / Backup (0) | 2022.01.18 |
[VPython] Miscellaneous (3) (0) | 2022.01.18 |
[VPython] Miscellaneous (2) (0) | 2022.01.18 |
[VPython] Miscellaneous (1) (0) | 2022.01.18 |