Question
I started the code but something is wrong, can you help me Step 1: Move the ball so that it is in the center of
I started the code but something is wrong, can you help me
Step 1: Move the ball so that it is in the center of the box.
Step 2: Change the radius of the ball, but make sure it still fits within the box.
Step 3: Move the ball to the left side of the box.
Step 4: Change the color of the ball to green.
Step 5: Create a new sphere with a color other than green and add it to the box. Make sure to name this object something other than ball1.
Step 6: Add an object of your choice using one of the links below. (These links will also be useful for your first homework assignment.) box sphere ring cylinder arrow cone pyramid.
Step 7: Adjust the position and dimensions of your chosen shape until it is entirely inside the box.
Step 8: Remove the hashtags in front of the while loop (shown below). These hashtags were put in place so that the computer would originally ignore these lines of code. However, you will need to activate these lines to continue.
Step 9: Run the simulation and watch what the while loop does.
Step 10: A while loop is created to run while a given condition is true. Change the condition so that the moving ball stops inside the box.
Web VPython 3.2 scene = canvas() ball = sphere(pos=vector(0,0,0), # position of sphere's center (x,y,z) radius=0.5, # radius of sphere color=color.green, # color of sphere make_trail=True) # leaves trail, if object moves
container=box(pos=vector(2,0,0), # position of box's center (x,y,z) size=vector(2,2,2), # size of box (x length, y length, z length) color=color.magenta, # color of box opacity=0.4) # transparency of box, 1 solid, 0 see through
while ball.pos.x < 0: #rate(100) #ball1.pos.x = ball1.pos.x + 0.01 cricle = ring(pos=vector(3,0,-2), # position of box's center (x,y,z) radius=0.4, # radius of ring color=color.red, # color of ring make_trail=True) # leaves trail, if object moves
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started