The following is the 3rd program of VPython, demonstrating how to create object in this work space. I know you can hardly read the code, to have a better viewing experience, please choose Full Screen at the upper left hand corner.
First of all, I want to create an object in spherical shape, with the x-y-z coordinate location in the Origin depicted in vector form, and a rectangular box with the vector location as follow:
sphere_location = vector(0,0,0) #vector has x,y,z coordinate
box_location = vector(4,2,3)
However, there is nothing can be shown right now, we need to specify the size of these two objects. For the sphere, I assign its position as sphere_location, with radius of 0.5, and its colour would be in blue. For the box's position I assign it as box_location, with the size represented in vector in x-y-z coordinate (0.5, 0.1, 1.0) as shown below, with the colour in red.
sphere(pos=sphere_location ,radius=0.5, color=color.blue)
#we define pos = the shape's positon, radius,
#first object
box(pos=box_location, size=vector(0.5, 0.1, 1.0), color=color.red )
#size = widthm, height, depth
#second object
After that, you can see the objects! Now I want to make three more objects. However, name cannot be duplicated, so I now assign the 3 objects called my_sphere, sphere and my_box. Make sure they should not be the same size and position vector, or they may be overlapping.
my_box= box(pos=vector(4,5,3), size=vector(0.5, 1, 1.5), color=color.orange )To print the following code, just let you know that, it's done!
#third object
my_sphere = sphere(pos=vector(0,2,4) ,radius=0.7, color=color.green)
#fourth object
your_sphere = sphere(pos=vector(0,4,5) ,radius=0.8, color=color.green)
#fifth object
your_sphere.color = color.yellow
#change the object's color
#dot indicates a property of the object
print("End of program.")
Feel free to edit the code to see what changes you can make to this simulation!