June 2025
Intermediate to advanced
515 pages
17h 5m
English
The following basic shapes can be created using VPython: cuboid, sphere, cylinder, cone, pyramid, ellipsoid, and circular ring. The general syntax for creating a body object is:
obj=body(pos=vec(x0,y0,z0),axis=vec(x,y,z),size=vec(a,b,c),color=color.red)
The first parameter specifies the position of the body in 3D space. The default setting for the position is pos=vector(0,0,0). The position can be changed within the animation loop using obj.pos=vector(x,y,z). If only the position in x-direction needs to be changed, the obj.pos.x= value statement is sufficient.
The axis vector defines the orientation of the body object. For example, if vector (1,0,0) is assigned to axis, the body will be aligned in the ...
Read now
Unlock full access